Slightly better entry generation

This commit is contained in:
Matt Nadareski
2020-10-04 14:14:57 -07:00
parent bfab4a61e9
commit 4f162fc91d
4 changed files with 53 additions and 68 deletions

View File

@@ -190,30 +190,29 @@ namespace SabreTools.Library.FileTypes
TarArchive ta = TarArchive.Open(FileExtensions.TryOpenRead(this.Filename));
foreach (TarArchiveEntry entry in ta.Entries.Where(e => e != null && !e.IsDirectory))
{
// Create a blank item for the entry
BaseFile tarEntryRom = new BaseFile();
// Perform a quickscan, if flagged to
if (QuickScan)
{
found.Add(new BaseFile
{
Filename = entry.Key,
Size = entry.Size,
CRC = BitConverter.GetBytes(entry.Crc),
Date = (entry.LastModifiedTime != null ? entry.LastModifiedTime?.ToString("yyyy/MM/dd hh:mm:ss") : null),
Parent = gamename,
});
tarEntryRom.Size = entry.Size;
tarEntryRom.CRC = BitConverter.GetBytes(entry.Crc);
}
// Otherwise, use the stream directly
else
{
Stream entryStream = entry.OpenEntryStream();
BaseFile tarEntryRom = entryStream.GetInfo(size: entry.Size);
tarEntryRom.Filename = entry.Key;
tarEntryRom.Parent = gamename;
tarEntryRom.Date = entry.LastModifiedTime?.ToString("yyyy/MM/dd hh:mm:ss");
found.Add(tarEntryRom);
entryStream.Dispose();
using (Stream entryStream = entry.OpenEntryStream())
{
tarEntryRom = entryStream.GetInfo(size: entry.Size);
}
}
// Fill in comon details and add to the list
tarEntryRom.Filename = entry.Key;
tarEntryRom.Parent = gamename;
tarEntryRom.Date = entry.LastModifiedTime?.ToString("yyyy/MM/dd hh:mm:ss");
found.Add(tarEntryRom);
}
// Dispose of the archive