mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Cleanup of quickscan
This commit is contained in:
@@ -2038,7 +2038,6 @@ namespace SabreTools.Library.DatFiles
|
|||||||
{
|
{
|
||||||
// Set the archive flags
|
// Set the archive flags
|
||||||
archive.AvailableHashes = hashes;
|
archive.AvailableHashes = hashes;
|
||||||
archive.QuickScan = hashes == Hash.CRC;
|
|
||||||
|
|
||||||
// Skip if we're treating archives as files and skipping files
|
// Skip if we're treating archives as files and skipping files
|
||||||
if (asFiles.HasFlag(TreatAsFile.Archive) && skipFileType == SkipFileType.File)
|
if (asFiles.HasFlag(TreatAsFile.Archive) && skipFileType == SkipFileType.File)
|
||||||
@@ -2614,7 +2613,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
// Now get all extracted items from the archive
|
// Now get all extracted items from the archive
|
||||||
if (archive != null)
|
if (archive != null)
|
||||||
{
|
{
|
||||||
archive.QuickScan = quickScan;
|
archive.AvailableHashes = quickScan ? Hash.CRC : Hash.Standard;
|
||||||
entries = archive.GetChildren();
|
entries = archive.GetChildren();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,11 +11,6 @@ namespace SabreTools.Library.FileTypes
|
|||||||
{
|
{
|
||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Determines if archives pull information from headers alone
|
|
||||||
/// </summary>
|
|
||||||
public bool QuickScan { get; set; } = false;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines if dates are read or written
|
/// Determines if dates are read or written
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ using System.Linq;
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
using SabreTools.Library.Data;
|
using SabreTools.Library.Data;
|
||||||
|
using SabreTools.Library.DatFiles;
|
||||||
using SabreTools.Library.DatItems;
|
using SabreTools.Library.DatItems;
|
||||||
using SabreTools.Library.IO;
|
using SabreTools.Library.IO;
|
||||||
using SabreTools.Library.Tools;
|
using SabreTools.Library.Tools;
|
||||||
@@ -221,7 +222,7 @@ namespace SabreTools.Library.FileTypes
|
|||||||
BaseFile gzipEntryRom = new BaseFile();
|
BaseFile gzipEntryRom = new BaseFile();
|
||||||
|
|
||||||
// Perform a quickscan, if flagged to
|
// Perform a quickscan, if flagged to
|
||||||
if (QuickScan)
|
if (this.AvailableHashes == Hash.CRC)
|
||||||
{
|
{
|
||||||
gzipEntryRom.Filename = gamename;
|
gzipEntryRom.Filename = gamename;
|
||||||
using (BinaryReader br = new BinaryReader(FileExtensions.TryOpenRead(this.Filename)))
|
using (BinaryReader br = new BinaryReader(FileExtensions.TryOpenRead(this.Filename)))
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using SabreTools.Library.Data;
|
using SabreTools.Library.Data;
|
||||||
|
using SabreTools.Library.DatFiles;
|
||||||
using SabreTools.Library.DatItems;
|
using SabreTools.Library.DatItems;
|
||||||
using SabreTools.Library.IO;
|
using SabreTools.Library.IO;
|
||||||
using SharpCompress.Archives;
|
using SharpCompress.Archives;
|
||||||
@@ -189,7 +190,7 @@ namespace SabreTools.Library.FileTypes
|
|||||||
BaseFile rarEntryRom = new BaseFile();
|
BaseFile rarEntryRom = new BaseFile();
|
||||||
|
|
||||||
// Perform a quickscan, if flagged to
|
// Perform a quickscan, if flagged to
|
||||||
if (QuickScan)
|
if (this.AvailableHashes == Hash.CRC)
|
||||||
{
|
{
|
||||||
rarEntryRom.Size = entry.Size;
|
rarEntryRom.Size = entry.Size;
|
||||||
rarEntryRom.CRC = BitConverter.GetBytes(entry.Crc);
|
rarEntryRom.CRC = BitConverter.GetBytes(entry.Crc);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using SabreTools.Library.Data;
|
using SabreTools.Library.Data;
|
||||||
|
using SabreTools.Library.DatFiles;
|
||||||
using SabreTools.Library.DatItems;
|
using SabreTools.Library.DatItems;
|
||||||
using SabreTools.Library.IO;
|
using SabreTools.Library.IO;
|
||||||
using SabreTools.Library.Tools;
|
using SabreTools.Library.Tools;
|
||||||
@@ -299,7 +300,7 @@ namespace SabreTools.Library.FileTypes
|
|||||||
BaseFile zipEntryRom = new BaseFile();
|
BaseFile zipEntryRom = new BaseFile();
|
||||||
|
|
||||||
// Perform a quickscan, if flagged to
|
// Perform a quickscan, if flagged to
|
||||||
if (QuickScan)
|
if (this.AvailableHashes == Hash.CRC)
|
||||||
{
|
{
|
||||||
zipEntryRom.Size = (long)zf.UncompressedSize(i);
|
zipEntryRom.Size = (long)zf.UncompressedSize(i);
|
||||||
zipEntryRom.CRC = zf.CRC32(i);
|
zipEntryRom.CRC = zf.CRC32(i);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using SabreTools.Library.Data;
|
using SabreTools.Library.Data;
|
||||||
|
using SabreTools.Library.DatFiles;
|
||||||
using SabreTools.Library.DatItems;
|
using SabreTools.Library.DatItems;
|
||||||
using SabreTools.Library.IO;
|
using SabreTools.Library.IO;
|
||||||
using SabreTools.Library.Tools;
|
using SabreTools.Library.Tools;
|
||||||
@@ -194,7 +195,7 @@ namespace SabreTools.Library.FileTypes
|
|||||||
BaseFile tarEntryRom = new BaseFile();
|
BaseFile tarEntryRom = new BaseFile();
|
||||||
|
|
||||||
// Perform a quickscan, if flagged to
|
// Perform a quickscan, if flagged to
|
||||||
if (QuickScan)
|
if (this.AvailableHashes == Hash.CRC)
|
||||||
{
|
{
|
||||||
tarEntryRom.Size = entry.Size;
|
tarEntryRom.Size = entry.Size;
|
||||||
tarEntryRom.CRC = BitConverter.GetBytes(entry.Crc);
|
tarEntryRom.CRC = BitConverter.GetBytes(entry.Crc);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.IO;
|
|||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
using SabreTools.Library.Data;
|
using SabreTools.Library.Data;
|
||||||
|
using SabreTools.Library.DatFiles;
|
||||||
using SabreTools.Library.DatItems;
|
using SabreTools.Library.DatItems;
|
||||||
using SabreTools.Library.IO;
|
using SabreTools.Library.IO;
|
||||||
using SabreTools.Library.Tools;
|
using SabreTools.Library.Tools;
|
||||||
@@ -209,31 +210,32 @@ namespace SabreTools.Library.FileTypes
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Perform a quickscan, if flagged to
|
// Create a blank item for the entry
|
||||||
if (QuickScan)
|
BaseFile xzEntryRom = new BaseFile();
|
||||||
{
|
|
||||||
BaseFile tempRom = new BaseFile()
|
|
||||||
{
|
|
||||||
Filename = gamename,
|
|
||||||
};
|
|
||||||
BinaryReader br = new BinaryReader(FileExtensions.TryOpenRead(this.Filename));
|
|
||||||
br.BaseStream.Seek(-8, SeekOrigin.End);
|
|
||||||
tempRom.CRC = br.ReadBytesBigEndian(4);
|
|
||||||
tempRom.Size = br.ReadInt32BigEndian();
|
|
||||||
br.Dispose();
|
|
||||||
|
|
||||||
_children.Add(tempRom);
|
// Perform a quickscan, if flagged to
|
||||||
|
if (this.AvailableHashes == Hash.CRC)
|
||||||
|
{
|
||||||
|
xzEntryRom.Filename = gamename;
|
||||||
|
using (BinaryReader br = new BinaryReader(FileExtensions.TryOpenRead(this.Filename)))
|
||||||
|
{
|
||||||
|
br.BaseStream.Seek(-8, SeekOrigin.End);
|
||||||
|
xzEntryRom.CRC = br.ReadBytesBigEndian(4);
|
||||||
|
xzEntryRom.Size = br.ReadInt32BigEndian();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// Otherwise, use the stream directly
|
// Otherwise, use the stream directly
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var xzStream = new XZStream(File.OpenRead(this.Filename));
|
var xzStream = new XZStream(File.OpenRead(this.Filename));
|
||||||
BaseFile xzEntryRom = xzStream.GetInfo(hashes: this.AvailableHashes);
|
xzEntryRom = xzStream.GetInfo(hashes: this.AvailableHashes);
|
||||||
xzEntryRom.Filename = gamename;
|
xzEntryRom.Filename = gamename;
|
||||||
xzEntryRom.Parent = gamename;
|
|
||||||
_children.Add(xzEntryRom);
|
|
||||||
xzStream.Dispose();
|
xzStream.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fill in comon details and add to the list
|
||||||
|
xzEntryRom.Parent = gamename;
|
||||||
|
_children.Add(xzEntryRom);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ using System.IO;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using SabreTools.Library.Data;
|
using SabreTools.Library.Data;
|
||||||
|
using SabreTools.Library.DatFiles;
|
||||||
using SabreTools.Library.DatItems;
|
using SabreTools.Library.DatItems;
|
||||||
using SabreTools.Library.IO;
|
using SabreTools.Library.IO;
|
||||||
using SabreTools.Library.Tools;
|
using SabreTools.Library.Tools;
|
||||||
@@ -300,7 +301,7 @@ namespace SabreTools.Library.FileTypes
|
|||||||
BaseFile zipEntryRom = new BaseFile();
|
BaseFile zipEntryRom = new BaseFile();
|
||||||
|
|
||||||
// Perform a quickscan, if flagged to
|
// Perform a quickscan, if flagged to
|
||||||
if (QuickScan)
|
if (this.AvailableHashes == Hash.CRC)
|
||||||
{
|
{
|
||||||
zipEntryRom.Size = (long)zf.UncompressedSize(i);
|
zipEntryRom.Size = (long)zf.UncompressedSize(i);
|
||||||
zipEntryRom.CRC = zf.CRC32(i);
|
zipEntryRom.CRC = zf.CRC32(i);
|
||||||
|
|||||||
Reference in New Issue
Block a user