Beispiel #1
0
        public void LoadFromFile(string filePath, FileStream fileStream)
        {
            FilePath    = filePath;
            FileName    = Path.GetFileNameWithoutExtension(FilePath);
            FilePointer = 0;

            // Get file size
            RealFileSize    = fileStream.Length;
            VirtualFileSize = RealFileSize;

            // Read header to determine where the data starts & so we can read all of the headers
            DwPackHeader header = new DwPackHeader();

            fileStream.Read(SpanHelper.AsSpan <DwPackHeader, byte>(ref header));

            // Read the rest of the header data
            var length = sizeof(DwPackHeader) + (sizeof(DwPackEntry) * header.FileCount);
            var buffer = (byte *)Marshal.AllocHGlobal(length);

            fileStream.Seek(0, SeekOrigin.Begin);
            fileStream.Read(new Span <byte>(buffer, length));
            Native = new DwPackPtr(buffer);

            for (int i = 0; i < Native.Header->FileCount; i++)
            {
                var entry = new VirtualDwPackEntry(mLogger, this, Native.Entries + i, i);
                Entries.Add(entry);
                mMapper.Map(DataBaseOffset + entry.Native->DataOffset, entry.Native->CompressedSize, true);
            }
        }
        public void LoadFromFile(string filePath, FileStream fileStream)
        {
            // Get file size
            RealFileSize    = fileStream.Length;
            VirtualFileSize = RealFileSize;

            // Read header to determine where the data starts & so we can read all of the headers
            DwPackHeader header = new DwPackHeader();

            fileStream.Read(SpanHelper.AsSpan <DwPackHeader, byte>(ref header));

            // Read the rest of the header data
            var length = sizeof(DwPackHeader) + (sizeof(DwPackEntry) * header.FileCount);
            var buffer = (byte *)Marshal.AllocHGlobal(length);

            fileStream.Seek(0, SeekOrigin.Begin);
            fileStream.Read(new Span <byte>(buffer, length));
            Native = new DwPackPtr(buffer);
            LoadEntries();
        }