Archive: Ensure o call private directory directly while loading and saving.

This commit is contained in:
Ray Koopa 2020-07-01 13:54:07 +02:00
parent b89ea5d7e9
commit f8b1b84f21

View File

@ -93,7 +93,7 @@ namespace Syroot.Worms
if (!stream.CanSeek)
throw new ArgumentException("Stream requires to be seekable.", nameof(stream));
Clear();
_entries.Clear();
using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
// Read the header.
@ -123,7 +123,7 @@ namespace Syroot.Worms
int length = reader.ReadInt32();
string name = reader.ReadString(StringCoding.ZeroTerminated);
using (reader.TemporarySeek(offset, SeekOrigin.Begin))
Add(name, reader.ReadBytes(length));
_entries.Add(name, reader.ReadBytes(length));
} while (nextEntryOffset != 0);
}
}
@ -157,7 +157,7 @@ namespace Syroot.Worms
// Write the data and build the hash table and file entries.
List<HashTableEntry>[] hashTable = new List<HashTableEntry>[_hashSize];
foreach (KeyValuePair<string, byte[]> item in this)
foreach (KeyValuePair<string, byte[]> item in _entries)
{
HashTableEntry entry = new HashTableEntry()
{