mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[DatFile, ArchiveTools, FileTools] Fix DFD
This commit is contained in:
@@ -815,45 +815,17 @@ namespace SabreTools.Library.Tools
|
||||
MachineName = gamename,
|
||||
});
|
||||
}
|
||||
// Otherwise, extract to a stream
|
||||
// Otherwise, use the stream directly
|
||||
else
|
||||
{
|
||||
MemoryStream entryStream = new MemoryStream();
|
||||
|
||||
// If the stream is smaller than the buffer, just run one loop through to avoid issues
|
||||
if (streamsize < _bufferSize)
|
||||
{
|
||||
byte[] ibuffer = new byte[streamsize];
|
||||
int ilen = readStream.Read(ibuffer, 0, (int)streamsize);
|
||||
entryStream.Write(ibuffer, 0, ilen);
|
||||
entryStream.Flush();
|
||||
}
|
||||
// Otherwise, we do the normal loop
|
||||
else
|
||||
{
|
||||
byte[] ibuffer = new byte[_bufferSize];
|
||||
int ilen;
|
||||
while (streamsize > _bufferSize)
|
||||
{
|
||||
ilen = readStream.Read(ibuffer, 0, _bufferSize);
|
||||
entryStream.Write(ibuffer, 0, ilen);
|
||||
entryStream.Flush();
|
||||
streamsize -= _bufferSize;
|
||||
}
|
||||
|
||||
ilen = readStream.Read(ibuffer, 0, (int)streamsize);
|
||||
entryStream.Write(ibuffer, 0, ilen);
|
||||
entryStream.Flush();
|
||||
}
|
||||
zr = zf.CloseReadStream();
|
||||
|
||||
// Get and add the extended Rom information
|
||||
Rom zipEntryRom = FileTools.GetStreamInfo(entryStream, entryStream.Length, omitFromScan: omitFromScan);
|
||||
Rom zipEntryRom = FileTools.GetStreamInfo(readStream, (long)zf.Entries[i].UncompressedSize, omitFromScan: omitFromScan);
|
||||
zipEntryRom.Name = zf.Entries[i].FileName;
|
||||
zipEntryRom.MachineName = gamename;
|
||||
string convertedDate = Style.ConvertMsDosTimeFormatToDateTime(zf.Entries[i].LastMod).ToString("yyyy/MM/dd hh:mm:ss");
|
||||
zipEntryRom.Date = (date ? convertedDate : null);
|
||||
found.Add(zipEntryRom);
|
||||
zr = zf.CloseReadStream();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -758,13 +758,20 @@ namespace SabreTools.Library.Tools
|
||||
xxHash.Init();
|
||||
|
||||
// Seek to the starting position, if one is set
|
||||
if (offset < 0)
|
||||
try
|
||||
{
|
||||
input.Seek(offset, SeekOrigin.End);
|
||||
if (offset < 0)
|
||||
{
|
||||
input.Seek(offset, SeekOrigin.End);
|
||||
}
|
||||
else if (offset > 0)
|
||||
{
|
||||
input.Seek(offset, SeekOrigin.Begin);
|
||||
}
|
||||
}
|
||||
else
|
||||
catch (NotImplementedException)
|
||||
{
|
||||
input.Seek(offset, SeekOrigin.Begin);
|
||||
Globals.Logger.Warning("Stream does not support seeking. Stream position not changed");
|
||||
}
|
||||
|
||||
byte[] buffer = new byte[8 * 1024];
|
||||
@@ -845,8 +852,15 @@ namespace SabreTools.Library.Tools
|
||||
}
|
||||
finally
|
||||
{
|
||||
// Seek to the beginning of the stream
|
||||
input.Seek(0, SeekOrigin.Begin);
|
||||
// Seek to the beginning of the stream if possible
|
||||
try
|
||||
{
|
||||
input.Seek(0, SeekOrigin.Begin);
|
||||
}
|
||||
catch (NotImplementedException)
|
||||
{
|
||||
Globals.Logger.Verbose("Stream does not support seeking. Stream position not changed");
|
||||
}
|
||||
|
||||
if (!keepReadOpen)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user