示例#1
0
        public bool IsKMST1125WzFormat(string fileName)
        {
            if (!string.Equals(Path.GetExtension(fileName), ".wz", StringComparison.OrdinalIgnoreCase))
            {
                return(false);
            }

            string iniFile = Path.ChangeExtension(fileName, ".ini");

            if (!File.Exists(iniFile))
            {
                return(false);
            }

            // check if the file is an empty wzfile
            using (var file = new Wz_File(fileName, this))
            {
                if (!file.Loaded)
                {
                    return(false);
                }
                var tempNode = new Wz_Node();
                if (!this.encryption.encryption_detected)
                {
                    this.encryption.DetectEncryption(file);
                }
                file.FileStream.Position = file.Header.DataStartPosition;
                file.GetDirTree(tempNode);
                return(file.ImageCount == 0);
            }
        }
示例#2
0
        public Wz_File LoadFile(string fileName, Wz_Node node, bool useBaseWz = false, bool loadWzAsFolder = false)
        {
            Wz_File file = null;

            try
            {
                file = new Wz_File(fileName, this);
                if (!file.Loaded)
                {
                    throw new Exception("The file is not a valid wz file.");
                }
                this.wz_files.Add(file);
                file.TextEncoding = this.TextEncoding;
                if (!this.encryption.encryption_detected)
                {
                    this.encryption.DetectEncryption(file);
                }
                node.Value = file;
                file.Node  = node;
                file.FileStream.Position = file.Header.DataStartPosition;
                file.GetDirTree(node, useBaseWz, loadWzAsFolder);
                file.DetectWzType();
                file.DetectWzVersion();
                return(file);
            }
            catch
            {
                if (file != null)
                {
                    file.Close();
                    this.wz_files.Remove(file);
                }
                throw;
            }
        }
示例#3
0
        public void LoadFile(string fileName, Wz_Node node, bool useBaseWz)
        {
            Wz_File file;

            try
            {
                file = new Wz_File(fileName, this);
                file.TextEncoding = this.TextEncoding;
                if (!this.encryption.encryption_detected)
                {
                    this.encryption.DetectEncryption(file);
                }
                this.wz_files.Add(file);
                node.Value = file;
                file.Node  = node;
                file.FileStream.Position = 62;
                file.GetDirTree(node, useBaseWz);
                file.DetectWzType();
                file.DetectWzVersion();
            }
            catch
            {
                throw;
            }
        }