Esempio n. 1
0
        public PackFile(string filename)
        {
            this.FileName = filename;

            using (FileStream s = File.Open(filename, FileMode.Open, FileAccess.Read))
                using (BinaryReader reader = new BEBinaryReader(s)) {
                    while (true)
                    {
                        header = reader.ReadInt32();
                        //if (header == 0) break;
                        int files = reader.ReadInt32();
                        //packData.header.i3 = reader.ReadInt32();
                        if (files == 0)
                        {
                            break;
                        }

                        for (int i = 0; i < files; i++)
                        {
                            string readName = reader.ReadString();

                            FileData fileDat = new FileData();
                            fileDat.offset   = reader.ReadInt32();
                            fileDat.size     = reader.ReadInt32();
                            fileDat.i3       = reader.ReadInt32();
                            fileDat.filename = filename;

                            Files.Add(readName, fileDat);
                        }
                    }
                }
        }
Esempio n. 2
0
 public void WritePackToDirectory(string directory)
 {
     for (int i = 0; i < files; i++)
     {
         using (FileStream s = File.Open(filename, FileMode.Open, FileAccess.Read))
             using (BinaryReader reader = new BEBinaryReader(s))
                 using (FileStream outfile = File.Open(directory + Path.DirectorySeparatorChar + filenames[i], FileMode.Create, FileAccess.Write))
                 {
                     s.Seek(fileData[i].offset, SeekOrigin.Begin);
                     byte[] file = reader.ReadBytes(fileData[i].size);
                     outfile.Write(file, 0, file.Length);
                 }
     }
 }
Esempio n. 3
0
        public void Extract(string directory)
        {
            using (FileStream s = File.Open(FileName, FileMode.Open, FileAccess.Read))
                using (BinaryReader reader = new BEBinaryReader(s))

                    foreach (KeyValuePair <String, FileData> entry in Files)
                    {
                        using (FileStream outfile = File.Open(directory + Path.DirectorySeparatorChar + entry.Key, FileMode.Create, FileAccess.Write)) {
                            s.Seek(entry.Value.offset, SeekOrigin.Begin);
                            byte[] file = reader.ReadBytes(entry.Value.size);
                            outfile.Write(file, 0, file.Length);
                        }
                    }
        }
Esempio n. 4
0
        public byte[] GetFile(string fileName)
        {
            if (!Files.Keys.Contains(fileName))
            {
                return(null);
            }

            FileData fData = Files[fileName];

            using (FileStream s = File.Open(FileName, FileMode.Open, FileAccess.Read))
                using (BinaryReader reader = new BEBinaryReader(s)) {
                    s.Seek(fData.offset, SeekOrigin.Begin);
                    byte[] file = reader.ReadBytes(fData.size);
                    return(file);
                }
        }
Esempio n. 5
0
        public void Extract(string fileName, string directory)
        {
            if (!Files.Keys.Contains(fileName))
            {
                return;
            }

            FileData fData = Files[fileName];

            using (FileStream s = File.Open(FileName, FileMode.Open, FileAccess.Read))
                using (BinaryReader reader = new BEBinaryReader(s))
                    using (FileStream outfile = File.Open(directory + Path.DirectorySeparatorChar + fileName, FileMode.Create, FileAccess.Write)) {
                        s.Seek(fData.offset, SeekOrigin.Begin);
                        byte[] file = reader.ReadBytes(fData.size);
                        outfile.Write(file, 0, file.Length);
                    }
        }
Esempio n. 6
0
        public PackFile(string filename)
        {
            this.filename = filename;
            int files    = 5;
            int subpacks = 2;

            using (FileStream s = File.Open(filename, FileMode.Open, FileAccess.Read))
                using (BinaryReader reader = new BEBinaryReader(s))
                {
                    while (true)
                    {
                        header = reader.ReadInt32();
                        if (header == 0)
                        {
                            break;
                        }
                        filesInPack = reader.ReadInt32();
                        //packData.header.i3 = reader.ReadInt32();


                        files = filesInPack;

                        for (int i = 0; i < files; i++)
                        {
                            string readName = reader.ReadString();
                            filenames.Add(readName);



                            FileData fileDat = new FileData();
                            fileDat.offset = reader.ReadInt32();
                            fileDat.size   = reader.ReadInt32();
                            fileDat.i3     = reader.ReadInt32();
                            fileData.Add(fileDat);

                            this.files++;
                        }

                        s.Seek(header, SeekOrigin.Begin);
                    }
                }
        }