mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[ArchiveTools, FileTools] Pattern size safety of other archives off Zip
This commit is contained in:
@@ -640,19 +640,16 @@ namespace SabreTools.Library.Tools
|
|||||||
MachineName = gamename,
|
MachineName = gamename,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Otherwise, extract to a stream
|
// Otherwise, use the stream directly
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Create and populate the entry stream
|
Stream entryStream = entry.OpenEntryStream();
|
||||||
MemoryStream entryStream = new MemoryStream();
|
Rom sevenZipEntryRom = FileTools.GetStreamInfo(entryStream, entry.Size, omitFromScan: omitFromScan);
|
||||||
entry.WriteTo(entryStream);
|
|
||||||
|
|
||||||
// Get and add the extended Rom information
|
|
||||||
Rom sevenZipEntryRom = FileTools.GetStreamInfo(entryStream, entryStream.Length, omitFromScan: omitFromScan);
|
|
||||||
sevenZipEntryRom.Name = entry.Key;
|
sevenZipEntryRom.Name = entry.Key;
|
||||||
sevenZipEntryRom.MachineName = gamename;
|
sevenZipEntryRom.MachineName = gamename;
|
||||||
sevenZipEntryRom.Date = (date && entry.LastModifiedTime != null ? entry.LastModifiedTime?.ToString("yyyy/MM/dd hh:mm:ss") : null);
|
sevenZipEntryRom.Date = (date && entry.LastModifiedTime != null ? entry.LastModifiedTime?.ToString("yyyy/MM/dd hh:mm:ss") : null);
|
||||||
found.Add(sevenZipEntryRom);
|
found.Add(sevenZipEntryRom);
|
||||||
|
entryStream.Dispose();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -676,22 +673,15 @@ namespace SabreTools.Library.Tools
|
|||||||
|
|
||||||
found.Add(tempRom);
|
found.Add(tempRom);
|
||||||
}
|
}
|
||||||
// Otherwise, extract to a stream
|
// Otherwise, use the stream directly
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Create and populate the entry stream
|
|
||||||
MemoryStream outstream = new MemoryStream();
|
|
||||||
GZipStream gzstream = new GZipStream(FileTools.TryOpenRead(input), Ionic.Zlib.CompressionMode.Decompress);
|
GZipStream gzstream = new GZipStream(FileTools.TryOpenRead(input), Ionic.Zlib.CompressionMode.Decompress);
|
||||||
gzstream.CopyTo(outstream);
|
Rom gzipEntryRom = FileTools.GetStreamInfo(gzstream, gzstream.Length, omitFromScan: omitFromScan);
|
||||||
|
|
||||||
// Get and add the extended Rom information
|
|
||||||
Rom gzipEntryRom = FileTools.GetStreamInfo(outstream, outstream.Length, omitFromScan: omitFromScan);
|
|
||||||
gzipEntryRom.Name = gzstream.FileName;
|
gzipEntryRom.Name = gzstream.FileName;
|
||||||
gzipEntryRom.MachineName = gamename;
|
gzipEntryRom.MachineName = gamename;
|
||||||
gzipEntryRom.Date = (date && gzstream.LastModified != null ? gzstream.LastModified?.ToString("yyyy/MM/dd hh:mm:ss") : null);
|
gzipEntryRom.Date = (date && gzstream.LastModified != null ? gzstream.LastModified?.ToString("yyyy/MM/dd hh:mm:ss") : null);
|
||||||
found.Add(gzipEntryRom);
|
found.Add(gzipEntryRom);
|
||||||
|
|
||||||
// Dispose of the archive
|
|
||||||
gzstream.Dispose();
|
gzstream.Dispose();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -715,19 +705,16 @@ namespace SabreTools.Library.Tools
|
|||||||
MachineName = gamename,
|
MachineName = gamename,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Otherwise, extract to a stream
|
// Otherwise, use the stream directly
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Create and populate the entry stream
|
Stream entryStream = entry.OpenEntryStream();
|
||||||
MemoryStream entryStream = new MemoryStream();
|
Rom rarEntryRom = FileTools.GetStreamInfo(entryStream, entry.Size, omitFromScan: omitFromScan);
|
||||||
entry.WriteTo(entryStream);
|
rarEntryRom.Name = entry.Key;
|
||||||
|
rarEntryRom.MachineName = gamename;
|
||||||
// Get and add the extended Rom information
|
rarEntryRom.Date = entry.LastModifiedTime?.ToString("yyyy/MM/dd hh:mm:ss");
|
||||||
Rom sevenZipEntryRom = FileTools.GetStreamInfo(entryStream, entryStream.Length, omitFromScan: omitFromScan);
|
found.Add(rarEntryRom);
|
||||||
sevenZipEntryRom.Name = entry.Key;
|
entryStream.Dispose();
|
||||||
sevenZipEntryRom.MachineName = gamename;
|
|
||||||
sevenZipEntryRom.Date = entry.LastModifiedTime?.ToString("yyyy/MM/dd hh:mm:ss");
|
|
||||||
found.Add(sevenZipEntryRom);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -754,19 +741,16 @@ namespace SabreTools.Library.Tools
|
|||||||
MachineName = gamename,
|
MachineName = gamename,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// Otherwise, extract to a stream
|
// Otherwise, use the stream directly
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Create and populate the entry stream
|
Stream entryStream = entry.OpenEntryStream();
|
||||||
MemoryStream entryStream = new MemoryStream();
|
Rom tarEntryRom = FileTools.GetStreamInfo(entryStream, entry.Size, omitFromScan: omitFromScan);
|
||||||
entry.WriteTo(entryStream);
|
tarEntryRom.Name = entry.Key;
|
||||||
|
tarEntryRom.MachineName = gamename;
|
||||||
// Get and add the extended Rom information
|
tarEntryRom.Date = entry.LastModifiedTime?.ToString("yyyy/MM/dd hh:mm:ss");
|
||||||
Rom sevenZipEntryRom = FileTools.GetStreamInfo(entryStream, entryStream.Length, omitFromScan: omitFromScan);
|
found.Add(tarEntryRom);
|
||||||
sevenZipEntryRom.Name = entry.Key;
|
entryStream.Dispose();
|
||||||
sevenZipEntryRom.MachineName = gamename;
|
|
||||||
sevenZipEntryRom.Date = entry.LastModifiedTime?.ToString("yyyy/MM/dd hh:mm:ss");
|
|
||||||
found.Add(sevenZipEntryRom);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -818,7 +802,6 @@ namespace SabreTools.Library.Tools
|
|||||||
// Otherwise, use the stream directly
|
// Otherwise, use the stream directly
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Get and add the extended Rom information
|
|
||||||
Rom zipEntryRom = FileTools.GetStreamInfo(readStream, (long)zf.Entries[i].UncompressedSize, omitFromScan: omitFromScan);
|
Rom zipEntryRom = FileTools.GetStreamInfo(readStream, (long)zf.Entries[i].UncompressedSize, omitFromScan: omitFromScan);
|
||||||
zipEntryRom.Name = zf.Entries[i].FileName;
|
zipEntryRom.Name = zf.Entries[i].FileName;
|
||||||
zipEntryRom.MachineName = gamename;
|
zipEntryRom.MachineName = gamename;
|
||||||
|
|||||||
@@ -769,6 +769,10 @@ namespace SabreTools.Library.Tools
|
|||||||
input.Seek(offset, SeekOrigin.Begin);
|
input.Seek(offset, SeekOrigin.Begin);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (NotSupportedException)
|
||||||
|
{
|
||||||
|
Globals.Logger.Verbose("Stream does not support seeking. Stream position not changed");
|
||||||
|
}
|
||||||
catch (NotImplementedException)
|
catch (NotImplementedException)
|
||||||
{
|
{
|
||||||
Globals.Logger.Warning("Stream does not support seeking. Stream position not changed");
|
Globals.Logger.Warning("Stream does not support seeking. Stream position not changed");
|
||||||
@@ -857,6 +861,10 @@ namespace SabreTools.Library.Tools
|
|||||||
{
|
{
|
||||||
input.Seek(0, SeekOrigin.Begin);
|
input.Seek(0, SeekOrigin.Begin);
|
||||||
}
|
}
|
||||||
|
catch (NotSupportedException)
|
||||||
|
{
|
||||||
|
Globals.Logger.Verbose("Stream does not support seeking. Stream position not changed");
|
||||||
|
}
|
||||||
catch (NotImplementedException)
|
catch (NotImplementedException)
|
||||||
{
|
{
|
||||||
Globals.Logger.Verbose("Stream does not support seeking. Stream position not changed");
|
Globals.Logger.Verbose("Stream does not support seeking. Stream position not changed");
|
||||||
|
|||||||
Reference in New Issue
Block a user