mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[ArchiveTools, SimpleSort] Fix reading info from archive header
This commit is contained in:
@@ -200,20 +200,19 @@ namespace SabreTools.Helper
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
reader = ReaderFactory.Open(File.OpenRead(input));
|
reader = ReaderFactory.Open(File.OpenRead(input));
|
||||||
logger.Log("Found archive of type: " + at);
|
|
||||||
|
|
||||||
if (at == ArchiveType.Zip || at == ArchiveType.SevenZip || at == ArchiveType.Rar)
|
if (at == ArchiveType.Zip || at == ArchiveType.SevenZip || at == ArchiveType.Rar)
|
||||||
{
|
{
|
||||||
// Create the temp directory
|
// Create the temp directory
|
||||||
Directory.CreateDirectory(tempdir);
|
Directory.CreateDirectory(tempdir);
|
||||||
|
|
||||||
IArchiveEntry entry;
|
while (reader.MoveToNextEntry())
|
||||||
while ((entry = reader.Entry as IArchiveEntry) != null)
|
|
||||||
{
|
{
|
||||||
if (entry.Key.Contains(entryname))
|
logger.Log("Current entry name: '" + reader.Entry.Key + "'");
|
||||||
|
if (reader.Entry != null && reader.Entry.Key.Contains(entryname))
|
||||||
{
|
{
|
||||||
entry.WriteToDirectory(tempdir);
|
reader.WriteEntryToFile(tempdir + Path.DirectorySeparatorChar + reader.Entry.Key);
|
||||||
outfile = tempdir + Path.DirectorySeparatorChar + entry.Key;
|
outfile = tempdir + Path.DirectorySeparatorChar + reader.Entry.Key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -259,19 +258,24 @@ namespace SabreTools.Helper
|
|||||||
|
|
||||||
if (at != ArchiveType.Tar)
|
if (at != ArchiveType.Tar)
|
||||||
{
|
{
|
||||||
IArchiveEntry entry;
|
while (reader.MoveToNextEntry())
|
||||||
while ((entry = reader.Entry as IArchiveEntry) != null)
|
|
||||||
{
|
{
|
||||||
|
if (reader.Entry != null && !reader.Entry.IsDirectory)
|
||||||
|
{
|
||||||
|
logger.Log("Entry found: '" + reader.Entry.Key + "': " + reader.Entry.Size + ", " + reader.Entry.Crc.ToString("X").ToLowerInvariant());
|
||||||
|
|
||||||
roms.Add(new RomData
|
roms.Add(new RomData
|
||||||
{
|
{
|
||||||
Name = entry.Key,
|
Type = "rom",
|
||||||
|
Name = reader.Entry.Key,
|
||||||
Game = gamename,
|
Game = gamename,
|
||||||
Size = entry.Size,
|
Size = reader.Entry.Size,
|
||||||
CRC = entry.Crc.ToString("X"),
|
CRC = reader.Entry.Crc.ToString("X").ToLowerInvariant(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
logger.Error(ex.ToString());
|
logger.Error(ex.ToString());
|
||||||
|
|||||||
@@ -401,13 +401,15 @@ namespace SabreTools
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// TODO: Implement flag for external scanning only
|
/// TODO: Implement flag for external scanning only
|
||||||
bool externalScan = false;
|
bool externalScan = true;
|
||||||
if (externalScan)
|
if (externalScan)
|
||||||
{
|
{
|
||||||
|
_logger.Log("Beginning quick scan of contents from '" + input + "'");
|
||||||
List<RomData> internalRomData = ArchiveTools.GetArchiveFileInfo(input, _logger);
|
List<RomData> internalRomData = ArchiveTools.GetArchiveFileInfo(input, _logger);
|
||||||
|
_logger.Log(internalRomData.Count + " entries found in '" + input + "'");
|
||||||
|
|
||||||
// If the list is populated, then the file was a filled archive
|
// If the list is populated, then the file was a filled archive
|
||||||
if (internalRomData.Count >= 0)
|
if (internalRomData.Count > 0)
|
||||||
{
|
{
|
||||||
foreach (RomData rom in internalRomData)
|
foreach (RomData rom in internalRomData)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user