Beispiel #1
0
        public static FSARFile GetFile(Byte[] FilesData, FSARFileEntryInfo FileEntry)
        {
            FSARFile CurFile = new FSARFile();

            CurFile.FileHeader       = FileEntry;
            CurFile.UncompressedData = new Byte[FileEntry.UncompressedSize];

            if (FileEntry.Compressed)
            {
                CurFile.CompressedData = new Byte[FileEntry.CompressedSize - 2];
                FSARHelper.fastCopyBlock(FilesData, (int)FileEntry.DataPos + 2, CurFile.CompressedData, 0, CurFile.CompressedData.Length);
                MemoryStream  CompressedData   = new MemoryStream(CurFile.CompressedData);
                MemoryStream  DecompressedData = new MemoryStream();
                DeflateStream DecompFile       = new DeflateStream(CompressedData, CompressionMode.Decompress);
                DecompFile.CopyTo(DecompressedData);
                CurFile.UncompressedData = DecompressedData.ToArray();

                DecompressedData.Close();
                DecompFile.Close();
                CompressedData.Close();
            }
            else
            {
                FSARHelper.fastCopyBlock(FilesData, (int)FileEntry.DataPos, CurFile.UncompressedData, 0, (int)FileEntry.UncompressedSize);
            }
            return(CurFile);
        }
Beispiel #2
0
        public unsafe static FSARFile GetFile(this FSARFileEntryInfo FileEntry, Byte[] FilesData)
        {
            FSARFile CurFile = new FSARFile();

            CurFile.FileHeader       = FileEntry;
            CurFile.UncompressedData = new Byte[FileEntry.UncompressedSize];

            if (FileEntry.Compressed)
            {
                CurFile.CompressedData   = new Byte[FileEntry.CompressedSize - 2];
                CurFile.UncompressedData = new Byte[FileEntry.UncompressedSize];
                FSARHelper.fastCopyBlock(FilesData, (int)FileEntry.DataPos + 2, CurFile.CompressedData, 0, CurFile.CompressedData.Length);
                byte *CompressedData   = (byte *)Unsafe.AsPointer(ref CurFile.CompressedData[0]);
                byte *UncompressedData = (byte *)Unsafe.AsPointer(ref CurFile.UncompressedData[0]);
                Compression.decompress_deflate(CompressedData, (IntPtr)CurFile.CompressedData.Length, UncompressedData, (IntPtr)CurFile.UncompressedData.Length);
            }
            else
            {
                FSARHelper.fastCopyBlock(FilesData, (int)FileEntry.DataPos, CurFile.UncompressedData, 0, (int)FileEntry.UncompressedSize);
            }
            return(CurFile);
        }