Exemple #1
0
        public File(string source)
        {
            if (!System.IO.File.Exists(source))
            {
                return;
            }
            _source       = source;
            bigHeader     = new byte[0x10];
            refPackHeader = new byte[0x08];
            preBuffer     = new byte[0x00800000];
            stream        = new FileStream(source, FileMode.Open, FileAccess.Read, FileShare.Read);
            stream.Read(bigHeader, 0, 0x10);
            stream.Position = 0;
            uint headerSize = HeaderSize;

            stream.Read((bigHeader = new byte[headerSize]), 0, (int)headerSize);
            Files = new PackedFile[FileCount];
            int position = 0x10;

            for (int idx = 0; idx < FileCount; ++idx)
            {
                Files[idx]        = new PackedFile();
                Files[idx].Offset = FileHelper.Invert(FileHelper.GetUInt(position, bigHeader));
                position         += 0x04;
                Files[idx].Size   = FileHelper.Invert(FileHelper.GetUInt(position, bigHeader));
                position         += 0x04;
                Files[idx].Name   = FileHelper.GetString(position, bigHeader);
                position         += Files[idx].Name.Length + 1;
            }
        }
Exemple #2
0
 public bool Contains(PackedFile file)
 {
     for (int idx = 0; idx < Files.Length; ++idx)
     {
         if (file == Files[idx])
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #3
0
 public uint GetFileSize(PackedFile file)
 {
     stream.Position = file.Offset;
     stream.Read(refPackHeader, 0, 0x08);
     if (IsFileCompressed())
     {
         int size = (((refPackHeader[0x02] << 0x08) + refPackHeader[0x03]) << 0x08) + refPackHeader[0x04];
         if ((refPackHeader[0x00] & 0x80) != 0)
         {
             size = (size << 0x08) + refPackHeader[0x05];
         }
         return((uint)size);
     }
     return(file.Size);
 }
Exemple #4
0
 public byte[] GetFile(PackedFile file, uint length, uint offset = 0)
 {
     byte[] result;
     stream.Position = file.Offset;
     stream.Read(refPackHeader, 0, 0x02);
     if (IsFileCompressed())
     {
         result = Decompress(file.Offset, length, offset);
     }
     else
     {
         result          = new byte[length];
         stream.Position = file.Offset + offset;
         stream.Read(result, 0, (int)length);
     }
     return(result);
 }
Exemple #5
0
 public bool GetIsFileCompressed(PackedFile file)
 {
     stream.Position = file.Offset;
     stream.Read(refPackHeader, 0, 0x08);
     return(IsFileCompressed());
 }