mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Slightly better entry generation
This commit is contained in:
@@ -185,30 +185,29 @@ namespace SabreTools.Library.FileTypes
|
|||||||
SharpCompress.Archives.Rar.RarArchive ra = SharpCompress.Archives.Rar.RarArchive.Open(FileExtensions.TryOpenRead(this.Filename));
|
SharpCompress.Archives.Rar.RarArchive ra = SharpCompress.Archives.Rar.RarArchive.Open(FileExtensions.TryOpenRead(this.Filename));
|
||||||
foreach (RarArchiveEntry entry in ra.Entries.Where(e => e != null && !e.IsDirectory))
|
foreach (RarArchiveEntry entry in ra.Entries.Where(e => e != null && !e.IsDirectory))
|
||||||
{
|
{
|
||||||
|
// Create a blank item for the entry
|
||||||
|
BaseFile rarEntryRom = new BaseFile();
|
||||||
|
|
||||||
// Perform a quickscan, if flagged to
|
// Perform a quickscan, if flagged to
|
||||||
if (QuickScan)
|
if (QuickScan)
|
||||||
{
|
{
|
||||||
found.Add(new BaseFile
|
rarEntryRom.Size = entry.Size;
|
||||||
{
|
rarEntryRom.CRC = BitConverter.GetBytes(entry.Crc);
|
||||||
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,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
// Otherwise, use the stream directly
|
// Otherwise, use the stream directly
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Stream entryStream = entry.OpenEntryStream();
|
using (Stream entryStream = entry.OpenEntryStream())
|
||||||
BaseFile rarEntryRom = entryStream.GetInfo(size: entry.Size);
|
{
|
||||||
rarEntryRom.Filename = entry.Key;
|
rarEntryRom = entryStream.GetInfo(size: entry.Size);
|
||||||
rarEntryRom.Parent = gamename;
|
}
|
||||||
rarEntryRom.Date = entry.LastModifiedTime?.ToString("yyyy/MM/dd hh:mm:ss");
|
|
||||||
found.Add(rarEntryRom);
|
|
||||||
entryStream.Dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fill in comon details and add to the list
|
||||||
|
rarEntryRom.Filename = entry.Key;
|
||||||
|
rarEntryRom.Parent = gamename;
|
||||||
|
rarEntryRom.Date = entry.LastModifiedTime?.ToString("yyyy/MM/dd hh:mm:ss");
|
||||||
|
found.Add(rarEntryRom);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispose of the archive
|
// Dispose of the archive
|
||||||
|
|||||||
@@ -295,30 +295,25 @@ namespace SabreTools.Library.FileTypes
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a blank item for the entry
|
||||||
|
BaseFile zipEntryRom = new BaseFile();
|
||||||
|
|
||||||
// Perform a quickscan, if flagged to
|
// Perform a quickscan, if flagged to
|
||||||
if (QuickScan)
|
if (QuickScan)
|
||||||
{
|
{
|
||||||
string newname = zf.Filename(i);
|
zipEntryRom.Size = (long)zf.UncompressedSize(i);
|
||||||
long newsize = (long)zf.UncompressedSize(i);
|
zipEntryRom.CRC = zf.CRC32(i);
|
||||||
byte[] newcrc = zf.CRC32(i);
|
|
||||||
|
|
||||||
found.Add(new BaseFile
|
|
||||||
{
|
|
||||||
Filename = newname,
|
|
||||||
Size = newsize,
|
|
||||||
CRC = newcrc,
|
|
||||||
|
|
||||||
Parent = gamename,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
// Otherwise, use the stream directly
|
// Otherwise, use the stream directly
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BaseFile zipEntryRom = readStream.GetInfo(size: (long)zf.UncompressedSize(i), keepReadOpen: true);
|
zipEntryRom = readStream.GetInfo(size: (long)zf.UncompressedSize(i), keepReadOpen: true);
|
||||||
zipEntryRom.Filename = zf.Filename(i);
|
|
||||||
zipEntryRom.Parent = gamename;
|
|
||||||
found.Add(zipEntryRom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fill in comon details and add to the list
|
||||||
|
zipEntryRom.Filename = zf.Filename(i);
|
||||||
|
zipEntryRom.Parent = gamename;
|
||||||
|
found.Add(zipEntryRom);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispose of the archive
|
// Dispose of the archive
|
||||||
|
|||||||
@@ -190,30 +190,29 @@ namespace SabreTools.Library.FileTypes
|
|||||||
TarArchive ta = TarArchive.Open(FileExtensions.TryOpenRead(this.Filename));
|
TarArchive ta = TarArchive.Open(FileExtensions.TryOpenRead(this.Filename));
|
||||||
foreach (TarArchiveEntry entry in ta.Entries.Where(e => e != null && !e.IsDirectory))
|
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
|
// Perform a quickscan, if flagged to
|
||||||
if (QuickScan)
|
if (QuickScan)
|
||||||
{
|
{
|
||||||
found.Add(new BaseFile
|
tarEntryRom.Size = entry.Size;
|
||||||
{
|
tarEntryRom.CRC = BitConverter.GetBytes(entry.Crc);
|
||||||
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,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
// Otherwise, use the stream directly
|
// Otherwise, use the stream directly
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Stream entryStream = entry.OpenEntryStream();
|
using (Stream entryStream = entry.OpenEntryStream())
|
||||||
BaseFile tarEntryRom = entryStream.GetInfo(size: entry.Size);
|
{
|
||||||
tarEntryRom.Filename = entry.Key;
|
tarEntryRom = entryStream.GetInfo(size: entry.Size);
|
||||||
tarEntryRom.Parent = gamename;
|
}
|
||||||
tarEntryRom.Date = entry.LastModifiedTime?.ToString("yyyy/MM/dd hh:mm:ss");
|
|
||||||
found.Add(tarEntryRom);
|
|
||||||
entryStream.Dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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
|
// Dispose of the archive
|
||||||
|
|||||||
@@ -296,34 +296,26 @@ namespace SabreTools.Library.FileTypes
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a blank item for the entry
|
||||||
|
BaseFile zipEntryRom = new BaseFile();
|
||||||
|
|
||||||
// Perform a quickscan, if flagged to
|
// Perform a quickscan, if flagged to
|
||||||
if (QuickScan)
|
if (QuickScan)
|
||||||
{
|
{
|
||||||
string newname = zf.Filename(i);
|
zipEntryRom.Size = (long)zf.UncompressedSize(i);
|
||||||
long newsize = (long)zf.UncompressedSize(i);
|
zipEntryRom.CRC = zf.CRC32(i);
|
||||||
byte[] newcrc = zf.CRC32(i);
|
|
||||||
string convertedDate = zf.LastModified(i).ToString("yyyy/MM/dd hh:mm:ss");
|
|
||||||
|
|
||||||
found.Add(new BaseFile
|
|
||||||
{
|
|
||||||
Filename = newname,
|
|
||||||
Size = newsize,
|
|
||||||
CRC = newcrc,
|
|
||||||
Date = convertedDate,
|
|
||||||
|
|
||||||
Parent = gamename,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
// Otherwise, use the stream directly
|
// Otherwise, use the stream directly
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
BaseFile zipEntryRom = readStream.GetInfo(size: (long)zf.UncompressedSize(i), keepReadOpen: true);
|
zipEntryRom = readStream.GetInfo(size: (long)zf.UncompressedSize(i), keepReadOpen: true);
|
||||||
zipEntryRom.Filename = zf.Filename(i);
|
|
||||||
zipEntryRom.Parent = gamename;
|
|
||||||
string convertedDate = zf.LastModified(i).ToString("yyyy/MM/dd hh:mm:ss");
|
|
||||||
zipEntryRom.Date = convertedDate;
|
|
||||||
found.Add(zipEntryRom);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fill in comon details and add to the list
|
||||||
|
zipEntryRom.Filename = zf.Filename(i);
|
||||||
|
zipEntryRom.Parent = gamename;
|
||||||
|
zipEntryRom.Date = zf.LastModified(i).ToString("yyyy/MM/dd hh:mm:ss");
|
||||||
|
found.Add(zipEntryRom);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dispose of the archive
|
// Dispose of the archive
|
||||||
|
|||||||
Reference in New Issue
Block a user