[ArchiveTools, SimpleSort] Fix reading info from archive header

This commit is contained in:
Matt Nadareski
2016-06-15 15:44:11 -07:00
parent e9cb58464f
commit 18d01080f9
2 changed files with 22 additions and 16 deletions

View File

@@ -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());

View File

@@ -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)
{ {