Esempio n. 1
0
        public override void Load(string filePath)
        {
            RootFolder = new NTXFolder(this);

            using (var fs = File.OpenRead(filePath))
                using (var br = new BinaryReader(fs))
                {
                    while (br.PeekChar() >= 0)
                    {
                        string name   = Encoding.ASCII.GetString(br.ReadBytes(64)).Split('\0')[0];
                        int    length = br.ReadInt32();
                        fs.Seek(4, SeekOrigin.Current);
                        byte[] data = br.ReadBytes(length);

                        var newFile = new NTXFile(RootFolder as NTXFolder, name, data);
                        RootFolder.Files.Add(newFile);
                        FileList.Add(newFile);
                    }
                }
        }
Esempio n. 2
0
        public override void Save(string filePath)
        {
            RootFolder = new NTXFolder(this);

            using (var fs = File.OpenWrite(filePath))
                using (var bw = new BinaryWriter(fs))
                {
                    foreach (var file in FileList)
                    {
                        var ntxFile = file as NTXFile;

                        var nameBlock = new byte[64];
                        var nameBytes = Encoding.ASCII.GetBytes(file.Name);
                        Buffer.BlockCopy(nameBytes, 0, nameBlock, 0, nameBytes.Length);
                        bw.Write(nameBlock);

                        bw.Write(ntxFile.Data.Length);
                        bw.Write(0);
                        bw.Write(ntxFile.Data);
                    }
                }
        }
Esempio n. 3
0
 public NTXFile(NTXFolder parent, string name, byte[] data) : base(parent, name)
 {
     Data = data;
 }
Esempio n. 4
0
 public NTXFolder(NTX lof, NTXFolder parent, string name) : base(lof, parent, name)
 {
 }