コード例 #1
0
ファイル: Pac.cs プロジェクト: refox1/NisAnim
        public Pac(string filePath)
            : base(filePath)
        {
            using (EndianBinaryReader reader = new EndianBinaryReader(File.Open(filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Endian.BigEndian))
            {
                rawData = new MemoryStream(reader.ReadBytes((int)reader.BaseStream.Length), 0, (int)reader.BaseStream.Length, false, true);

                reader.BaseStream.Seek(0, SeekOrigin.Begin);

                NumFiles    = reader.ReadUInt32();
                Unknown0x04 = reader.ReadUInt32();
                Unknown0x08 = reader.ReadUInt32();
                Unknown0x0C = reader.ReadUInt32();

                Files = new PacFile[NumFiles];
                for (int i = 0; i < Files.Length; i++)
                {
                    Files[i] = new PacFile(this, reader);
                }

                FileSize = reader.BaseStream.Length;

                foreach (PacFile file in Files)
                {
                    file.SetLength(Files);
                }

                DataStartPosition = reader.BaseStream.Position;
            }
        }
コード例 #2
0
ファイル: Pac.cs プロジェクト: refox1/NisAnim
 public void ExtractFile(PacFile file, string path)
 {
     using (MemoryStream stream = file.GetStream(rawData))
     {
         stream.Seek(0, SeekOrigin.Begin);
         using (EndianBinaryReader reader = new EndianBinaryReader(stream))
         {
             File.WriteAllBytes(path, reader.ReadBytes((int)reader.BaseStream.Length));
         }
     }
 }