mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Clean up more info instances
This commit is contained in:
@@ -2094,7 +2094,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
|
|
||||||
// If we have an archive and we're supposed to scan it
|
// If we have an archive and we're supposed to scan it
|
||||||
if (archive != null && !asFiles.HasFlag(TreatAsFile.Archive))
|
if (archive != null && !asFiles.HasFlag(TreatAsFile.Archive))
|
||||||
extracted = archive.GetChildren(omitFromScan: omitFromScan, date: addDate);
|
extracted = archive.GetChildren(date: addDate);
|
||||||
|
|
||||||
// If the file should be skipped based on type, do so now
|
// If the file should be skipped based on type, do so now
|
||||||
if ((extracted != null && skipFileType == SkipFileType.Archive)
|
if ((extracted != null && skipFileType == SkipFileType.Archive)
|
||||||
@@ -2109,7 +2109,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
|
|
||||||
// Otherwise, add all of the found items
|
// Otherwise, add all of the found items
|
||||||
else
|
else
|
||||||
ProcessArchive(newItem, newBasePath, addBlanks, archive, extracted);
|
ProcessArchive(newItem, newBasePath, addBlanks, archive, extracted, omitFromScan);
|
||||||
|
|
||||||
// Cue to delete the file if it's a copy
|
// Cue to delete the file if it's a copy
|
||||||
if (copyFiles && item != newItem)
|
if (copyFiles && item != newItem)
|
||||||
@@ -2178,7 +2178,8 @@ namespace SabreTools.Library.DatFiles
|
|||||||
/// <param name="addBlanks">True if blank items should be created for empty folders, false otherwise</param>
|
/// <param name="addBlanks">True if blank items should be created for empty folders, false otherwise</param>
|
||||||
/// <param name="archive">BaseArchive to get blank folders from, if necessary</param>
|
/// <param name="archive">BaseArchive to get blank folders from, if necessary</param>
|
||||||
/// <param name="extracted">List of BaseFiles representing the internal files</param>
|
/// <param name="extracted">List of BaseFiles representing the internal files</param>
|
||||||
private void ProcessArchive(string item, string basePath, bool addBlanks, BaseArchive archive, List<BaseFile> extracted)
|
/// <param name="omitFromScan">Hash flag saying what hashes should not be calculated</param>
|
||||||
|
private void ProcessArchive(string item, string basePath, bool addBlanks, BaseArchive archive, List<BaseFile> extracted, Hash omitFromScan)
|
||||||
{
|
{
|
||||||
// Get the parent path for all items
|
// Get the parent path for all items
|
||||||
string parent = (Path.GetDirectoryName(Path.GetFullPath(item)) + Path.DirectorySeparatorChar).Remove(0, basePath.Length) + Path.GetFileNameWithoutExtension(item);
|
string parent = (Path.GetDirectoryName(Path.GetFullPath(item)) + Path.DirectorySeparatorChar).Remove(0, basePath.Length) + Path.GetFileNameWithoutExtension(item);
|
||||||
@@ -2187,6 +2188,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
Parallel.ForEach(extracted, Globals.ParallelOptions, baseFile =>
|
Parallel.ForEach(extracted, Globals.ParallelOptions, baseFile =>
|
||||||
{
|
{
|
||||||
DatItem datItem = DatItem.Create(baseFile);
|
DatItem datItem = DatItem.Create(baseFile);
|
||||||
|
datItem.RemoveFields(omitFromScan.AsFields());
|
||||||
ProcessFileHelper(item, datItem, basePath, parent);
|
ProcessFileHelper(item, datItem, basePath, parent);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -2220,8 +2222,9 @@ namespace SabreTools.Library.DatFiles
|
|||||||
{
|
{
|
||||||
Globals.Logger.Verbose($"'{Path.GetFileName(item)}' treated like a file");
|
Globals.Logger.Verbose($"'{Path.GetFileName(item)}' treated like a file");
|
||||||
BaseFile baseFile = FileExtensions.GetInfo(item, addDate, Header.HeaderSkipper, asFiles);
|
BaseFile baseFile = FileExtensions.GetInfo(item, addDate, Header.HeaderSkipper, asFiles);
|
||||||
baseFile.RemoveHashes(omitFromScan);
|
DatItem datItem = DatItem.Create(baseFile);
|
||||||
ProcessFileHelper(item, DatItem.Create(baseFile), basePath, string.Empty);
|
datItem.RemoveFields(omitFromScan.AsFields());
|
||||||
|
ProcessFileHelper(item, datItem, basePath, string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -2607,21 +2610,16 @@ namespace SabreTools.Library.DatFiles
|
|||||||
bool isTorrentGzip = tgz.IsTorrent();
|
bool isTorrentGzip = tgz.IsTorrent();
|
||||||
|
|
||||||
// Get the base archive first
|
// Get the base archive first
|
||||||
BaseArchive archive = BaseArchive.Create(file);
|
BaseArchive archive = BaseArchive.Create(file, quickScan);
|
||||||
|
|
||||||
// Now get all extracted items from the archive
|
// Now get all extracted items from the archive
|
||||||
if (archive != null)
|
if (archive != null)
|
||||||
{
|
entries = archive.GetChildren(date: date);
|
||||||
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
|
|
||||||
entries = archive.GetChildren(omitFromScan: (quickScan ? Hash.SecureHashes : Hash.DeepHashes), date: date);
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the entries list is null, we encountered an error or have a file and should scan externally
|
// If the entries list is null, we encountered an error or have a file and should scan externally
|
||||||
if (entries == null && File.Exists(file))
|
if (entries == null && File.Exists(file))
|
||||||
{
|
{
|
||||||
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
|
|
||||||
BaseFile internalFileInfo = FileExtensions.GetInfo(file, asFiles: asFiles);
|
BaseFile internalFileInfo = FileExtensions.GetInfo(file, asFiles: asFiles);
|
||||||
internalFileInfo.RemoveHashes(quickScan ? Hash.SecureHashes : Hash.DeepHashes);
|
|
||||||
|
|
||||||
// Create the correct DatItem
|
// Create the correct DatItem
|
||||||
DatItem internalDatItem;
|
DatItem internalDatItem;
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
|
|
||||||
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;
|
||||||
|
|
||||||
@@ -12,6 +11,8 @@ namespace SabreTools.Library.FileTypes
|
|||||||
{
|
{
|
||||||
#region Protected instance variables
|
#region Protected instance variables
|
||||||
|
|
||||||
|
protected bool QuickScan { get; set; } = false;
|
||||||
|
|
||||||
// Buffer size used by archives
|
// Buffer size used by archives
|
||||||
protected const int _bufferSize = 4096 * 128;
|
protected const int _bufferSize = 4096 * 128;
|
||||||
|
|
||||||
@@ -40,8 +41,9 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// Create an archive object from a filename, if possible
|
/// Create an archive object from a filename, if possible
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input">Name of the file to create the archive from</param>
|
/// <param name="input">Name of the file to create the archive from</param>
|
||||||
|
/// <param name="quickScan">True to use archive header values, false otherwise</param>
|
||||||
/// <returns>Archive object representing the inputs</returns>
|
/// <returns>Archive object representing the inputs</returns>
|
||||||
public static BaseArchive Create(string input)
|
public static BaseArchive Create(string input, bool quickScan = false)
|
||||||
{
|
{
|
||||||
BaseArchive archive = null;
|
BaseArchive archive = null;
|
||||||
|
|
||||||
@@ -81,6 +83,10 @@ namespace SabreTools.Library.FileTypes
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set the quickscan flag
|
||||||
|
if (archive != null)
|
||||||
|
archive.QuickScan = quickScan;
|
||||||
|
|
||||||
return archive;
|
return archive;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -147,11 +153,10 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a list of DatItem objects from the header values in an archive
|
/// Generate a list of DatItem objects from the header values in an archive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="omitFromScan">Hash representing the hashes that should be skipped</param>
|
|
||||||
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
||||||
/// <returns>List of DatItem objects representing the found data</returns>
|
/// <returns>List of DatItem objects representing the found data</returns>
|
||||||
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
||||||
public override abstract List<BaseFile> GetChildren(Hash omitFromScan = Hash.DeepHashes, bool date = false);
|
public override abstract List<BaseFile> GetChildren(bool date = false);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a list of empty folders in an archive
|
/// Generate a list of empty folders in an archive
|
||||||
|
|||||||
@@ -99,35 +99,5 @@ namespace SabreTools.Library.FileTypes
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Manipulation
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Remove hashes from the metadata
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="remove">Hash representing hashes to remove</param>
|
|
||||||
public void RemoveHashes(Hash remove)
|
|
||||||
{
|
|
||||||
if (remove.HasFlag(Hash.CRC))
|
|
||||||
CRC = null;
|
|
||||||
if (remove.HasFlag(Hash.MD5))
|
|
||||||
MD5 = null;
|
|
||||||
#if NET_FRAMEWORK
|
|
||||||
if (remove.HasFlag(Hash.RIPEMD160))
|
|
||||||
RIPEMD160 = null;
|
|
||||||
#endif
|
|
||||||
if (remove.HasFlag(Hash.SHA1))
|
|
||||||
SHA1 = null;
|
|
||||||
if (remove.HasFlag(Hash.SHA256))
|
|
||||||
SHA256 = null;
|
|
||||||
if (remove.HasFlag(Hash.SHA384))
|
|
||||||
SHA384 = null;
|
|
||||||
if (remove.HasFlag(Hash.SHA512))
|
|
||||||
SHA512 = null;
|
|
||||||
if (remove.HasFlag(Hash.SpamSum))
|
|
||||||
SpamSum = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ 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;
|
||||||
@@ -257,11 +256,9 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a list of immediate children from the current folder
|
/// Generate a list of immediate children from the current folder
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="omitFromScan">Hash representing the hashes that should be skipped</param>
|
|
||||||
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
||||||
/// <returns>List of BaseFile objects representing the found data</returns>
|
/// <returns>List of BaseFile objects representing the found data</returns>
|
||||||
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
public virtual List<BaseFile> GetChildren(bool date = false)
|
||||||
public virtual List<BaseFile> GetChildren(Hash omitFromScan = Hash.DeepHashes, bool date = false)
|
|
||||||
{
|
{
|
||||||
if (_children == null || _children.Count == 0)
|
if (_children == null || _children.Count == 0)
|
||||||
{
|
{
|
||||||
@@ -269,7 +266,6 @@ namespace SabreTools.Library.FileTypes
|
|||||||
foreach (string file in Directory.EnumerateFiles(this.Filename, "*", SearchOption.TopDirectoryOnly))
|
foreach (string file in Directory.EnumerateFiles(this.Filename, "*", SearchOption.TopDirectoryOnly))
|
||||||
{
|
{
|
||||||
BaseFile nf = FileExtensions.GetInfo(file, date: date);
|
BaseFile nf = FileExtensions.GetInfo(file, date: date);
|
||||||
nf.RemoveHashes(omitFromScan);
|
|
||||||
_children.Add(nf);
|
_children.Add(nf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -189,11 +189,10 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a list of DatItem objects from the header values in an archive
|
/// Generate a list of DatItem objects from the header values in an archive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="omitFromScan">Hash representing the hashes that should be skipped</param>
|
|
||||||
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
||||||
/// <returns>List of DatItem objects representing the found data</returns>
|
/// <returns>List of DatItem objects representing the found data</returns>
|
||||||
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
||||||
public override List<BaseFile> GetChildren(Hash omitFromScan = Hash.DeepHashes, bool date = false)
|
public override List<BaseFile> GetChildren(bool date = false)
|
||||||
{
|
{
|
||||||
if (_children == null || _children.Count == 0)
|
if (_children == null || _children.Count == 0)
|
||||||
{
|
{
|
||||||
@@ -212,8 +211,8 @@ namespace SabreTools.Library.FileTypes
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// If secure hashes are disabled, do a quickscan
|
// Perform a quickscan, if flagged to
|
||||||
if (omitFromScan == Hash.SecureHashes)
|
if (QuickScan)
|
||||||
{
|
{
|
||||||
BaseFile tempRom = new BaseFile()
|
BaseFile tempRom = new BaseFile()
|
||||||
{
|
{
|
||||||
@@ -234,7 +233,6 @@ namespace SabreTools.Library.FileTypes
|
|||||||
ZipReturn ret = gz.ZipFileOpen(this.Filename);
|
ZipReturn ret = gz.ZipFileOpen(this.Filename);
|
||||||
ret = gz.ZipFileOpenReadStream(0, out Stream gzstream, out ulong streamSize);
|
ret = gz.ZipFileOpenReadStream(0, out Stream gzstream, out ulong streamSize);
|
||||||
BaseFile gzipEntryRom = gzstream.GetInfo();
|
BaseFile gzipEntryRom = gzstream.GetInfo();
|
||||||
gzipEntryRom.RemoveHashes(omitFromScan);
|
|
||||||
gzipEntryRom.Filename = gz.Filename(0);
|
gzipEntryRom.Filename = gz.Filename(0);
|
||||||
gzipEntryRom.Parent = gamename;
|
gzipEntryRom.Parent = gamename;
|
||||||
gzipEntryRom.Date = (date && gz.TimeStamp > 0 ? gz.TimeStamp.ToString() : null);
|
gzipEntryRom.Date = (date && gz.TimeStamp > 0 ? gz.TimeStamp.ToString() : null);
|
||||||
|
|||||||
@@ -78,11 +78,10 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a list of DatItem objects from the header values in an archive
|
/// Generate a list of DatItem objects from the header values in an archive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="omitFromScan">Hash representing the hashes that should be skipped</param>
|
|
||||||
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
||||||
/// <returns>List of DatItem objects representing the found data</returns>
|
/// <returns>List of DatItem objects representing the found data</returns>
|
||||||
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
||||||
public override List<BaseFile> GetChildren(Hash omitFromScan = Hash.DeepHashes, bool date = false)
|
public override List<BaseFile> GetChildren(bool date = false)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,11 +78,10 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a list of DatItem objects from the header values in an archive
|
/// Generate a list of DatItem objects from the header values in an archive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="omitFromScan">Hash representing the hashes that should be skipped</param>
|
|
||||||
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
||||||
/// <returns>List of DatItem objects representing the found data</returns>
|
/// <returns>List of DatItem objects representing the found data</returns>
|
||||||
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
||||||
public override List<BaseFile> GetChildren(Hash omitFromScan = Hash.DeepHashes, bool date = false)
|
public override List<BaseFile> GetChildren(bool date = false)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -175,11 +175,10 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a list of DatItem objects from the header values in an archive
|
/// Generate a list of DatItem objects from the header values in an archive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="omitFromScan">Hash representing the hashes that should be skipped</param>
|
|
||||||
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
||||||
/// <returns>List of DatItem objects representing the found data</returns>
|
/// <returns>List of DatItem objects representing the found data</returns>
|
||||||
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
||||||
public override List<BaseFile> GetChildren(Hash omitFromScan = Hash.DeepHashes, bool date = false)
|
public override List<BaseFile> GetChildren(bool date = false)
|
||||||
{
|
{
|
||||||
List<BaseFile> found = new List<BaseFile>();
|
List<BaseFile> found = new List<BaseFile>();
|
||||||
string gamename = Path.GetFileNameWithoutExtension(this.Filename);
|
string gamename = Path.GetFileNameWithoutExtension(this.Filename);
|
||||||
@@ -189,8 +188,8 @@ 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))
|
||||||
{
|
{
|
||||||
// If secure hashes are disabled, do a quickscan
|
// Perform a quickscan, if flagged to
|
||||||
if (omitFromScan == Hash.SecureHashes)
|
if (QuickScan)
|
||||||
{
|
{
|
||||||
found.Add(new BaseFile
|
found.Add(new BaseFile
|
||||||
{
|
{
|
||||||
@@ -207,7 +206,6 @@ namespace SabreTools.Library.FileTypes
|
|||||||
{
|
{
|
||||||
Stream entryStream = entry.OpenEntryStream();
|
Stream entryStream = entry.OpenEntryStream();
|
||||||
BaseFile rarEntryRom = entryStream.GetInfo(size: entry.Size);
|
BaseFile rarEntryRom = entryStream.GetInfo(size: entry.Size);
|
||||||
rarEntryRom.RemoveHashes(omitFromScan);
|
|
||||||
rarEntryRom.Filename = entry.Key;
|
rarEntryRom.Filename = entry.Key;
|
||||||
rarEntryRom.Parent = gamename;
|
rarEntryRom.Parent = gamename;
|
||||||
rarEntryRom.Date = entry.LastModifiedTime?.ToString("yyyy/MM/dd hh:mm:ss");
|
rarEntryRom.Date = entry.LastModifiedTime?.ToString("yyyy/MM/dd hh:mm:ss");
|
||||||
|
|||||||
@@ -259,11 +259,10 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a list of DatItem objects from the header values in an archive
|
/// Generate a list of DatItem objects from the header values in an archive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="omitFromScan">Hash representing the hashes that should be skipped</param>
|
|
||||||
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
||||||
/// <returns>List of DatItem objects representing the found data</returns>
|
/// <returns>List of DatItem objects representing the found data</returns>
|
||||||
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
||||||
public override List<BaseFile> GetChildren(Hash omitFromScan = Hash.DeepHashes, bool date = false)
|
public override List<BaseFile> GetChildren(bool date = false)
|
||||||
{
|
{
|
||||||
List<BaseFile> found = new List<BaseFile>();
|
List<BaseFile> found = new List<BaseFile>();
|
||||||
string gamename = Path.GetFileNameWithoutExtension(this.Filename);
|
string gamename = Path.GetFileNameWithoutExtension(this.Filename);
|
||||||
@@ -299,8 +298,8 @@ namespace SabreTools.Library.FileTypes
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If secure hashes are disabled, do a quickscan
|
// Perform a quickscan, if flagged to
|
||||||
if (omitFromScan == Hash.SecureHashes)
|
if (QuickScan)
|
||||||
{
|
{
|
||||||
string newname = zf.Filename(i);
|
string newname = zf.Filename(i);
|
||||||
long newsize = (long)zf.UncompressedSize(i);
|
long newsize = (long)zf.UncompressedSize(i);
|
||||||
@@ -319,7 +318,6 @@ namespace SabreTools.Library.FileTypes
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
BaseFile zipEntryRom = readStream.GetInfo(size: (long)zf.UncompressedSize(i), keepReadOpen: true);
|
BaseFile zipEntryRom = readStream.GetInfo(size: (long)zf.UncompressedSize(i), keepReadOpen: true);
|
||||||
zipEntryRom.RemoveHashes(omitFromScan);
|
|
||||||
zipEntryRom.Filename = zf.Filename(i);
|
zipEntryRom.Filename = zf.Filename(i);
|
||||||
zipEntryRom.Parent = gamename;
|
zipEntryRom.Parent = gamename;
|
||||||
found.Add(zipEntryRom);
|
found.Add(zipEntryRom);
|
||||||
|
|||||||
@@ -180,11 +180,10 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a list of DatItem objects from the header values in an archive
|
/// Generate a list of DatItem objects from the header values in an archive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="omitFromScan">Hash representing the hashes that should be skipped</param>
|
|
||||||
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
||||||
/// <returns>List of DatItem objects representing the found data</returns>
|
/// <returns>List of DatItem objects representing the found data</returns>
|
||||||
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
||||||
public override List<BaseFile> GetChildren(Hash omitFromScan = Hash.DeepHashes, bool date = false)
|
public override List<BaseFile> GetChildren(bool date = false)
|
||||||
{
|
{
|
||||||
List<BaseFile> found = new List<BaseFile>();
|
List<BaseFile> found = new List<BaseFile>();
|
||||||
string gamename = Path.GetFileNameWithoutExtension(this.Filename);
|
string gamename = Path.GetFileNameWithoutExtension(this.Filename);
|
||||||
@@ -194,8 +193,8 @@ 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))
|
||||||
{
|
{
|
||||||
// If secure hashes are disabled, do a quickscan
|
// Perform a quickscan, if flagged to
|
||||||
if (omitFromScan == Hash.SecureHashes)
|
if (QuickScan)
|
||||||
{
|
{
|
||||||
found.Add(new BaseFile
|
found.Add(new BaseFile
|
||||||
{
|
{
|
||||||
@@ -212,7 +211,6 @@ namespace SabreTools.Library.FileTypes
|
|||||||
{
|
{
|
||||||
Stream entryStream = entry.OpenEntryStream();
|
Stream entryStream = entry.OpenEntryStream();
|
||||||
BaseFile tarEntryRom = entryStream.GetInfo(size: entry.Size);
|
BaseFile tarEntryRom = entryStream.GetInfo(size: entry.Size);
|
||||||
tarEntryRom.RemoveHashes(omitFromScan);
|
|
||||||
tarEntryRom.Filename = entry.Key;
|
tarEntryRom.Filename = entry.Key;
|
||||||
tarEntryRom.Parent = gamename;
|
tarEntryRom.Parent = gamename;
|
||||||
tarEntryRom.Date = entry.LastModifiedTime?.ToString("yyyy/MM/dd hh:mm:ss");
|
tarEntryRom.Date = entry.LastModifiedTime?.ToString("yyyy/MM/dd hh:mm:ss");
|
||||||
|
|||||||
@@ -181,11 +181,10 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a list of DatItem objects from the header values in an archive
|
/// Generate a list of DatItem objects from the header values in an archive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="omitFromScan">Hash representing the hashes that should be skipped</param>
|
|
||||||
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
||||||
/// <returns>List of DatItem objects representing the found data</returns>
|
/// <returns>List of DatItem objects representing the found data</returns>
|
||||||
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
||||||
public override List<BaseFile> GetChildren(Hash omitFromScan = Hash.DeepHashes, bool date = false)
|
public override List<BaseFile> GetChildren(bool date = false)
|
||||||
{
|
{
|
||||||
if (_children == null || _children.Count == 0)
|
if (_children == null || _children.Count == 0)
|
||||||
{
|
{
|
||||||
@@ -204,8 +203,8 @@ namespace SabreTools.Library.FileTypes
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// If secure hashes are disabled, do a quickscan
|
// Perform a quickscan, if flagged to
|
||||||
if (omitFromScan == Hash.SecureHashes)
|
if (QuickScan)
|
||||||
{
|
{
|
||||||
BaseFile tempRom = new BaseFile()
|
BaseFile tempRom = new BaseFile()
|
||||||
{
|
{
|
||||||
@@ -224,7 +223,6 @@ namespace SabreTools.Library.FileTypes
|
|||||||
{
|
{
|
||||||
var xzStream = new XZStream(File.OpenRead(this.Filename));
|
var xzStream = new XZStream(File.OpenRead(this.Filename));
|
||||||
BaseFile xzEntryRom = xzStream.GetInfo();
|
BaseFile xzEntryRom = xzStream.GetInfo();
|
||||||
xzEntryRom.RemoveHashes(omitFromScan);
|
|
||||||
xzEntryRom.Filename = gamename;
|
xzEntryRom.Filename = gamename;
|
||||||
xzEntryRom.Parent = gamename;
|
xzEntryRom.Parent = gamename;
|
||||||
_children.Add(xzEntryRom);
|
_children.Add(xzEntryRom);
|
||||||
|
|||||||
@@ -78,11 +78,10 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a list of DatItem objects from the header values in an archive
|
/// Generate a list of DatItem objects from the header values in an archive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="omitFromScan">Hash representing the hashes that should be skipped</param>
|
|
||||||
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
||||||
/// <returns>List of DatItem objects representing the found data</returns>
|
/// <returns>List of DatItem objects representing the found data</returns>
|
||||||
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
||||||
public override List<BaseFile> GetChildren(Hash omitFromScan = Hash.DeepHashes, bool date = false)
|
public override List<BaseFile> GetChildren(bool date = false)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -260,11 +260,10 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a list of DatItem objects from the header values in an archive
|
/// Generate a list of DatItem objects from the header values in an archive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="omitFromScan">Hash representing the hashes that should be skipped</param>
|
|
||||||
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
||||||
/// <returns>List of DatItem objects representing the found data</returns>
|
/// <returns>List of DatItem objects representing the found data</returns>
|
||||||
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
||||||
public override List<BaseFile> GetChildren(Hash omitFromScan = Hash.DeepHashes, bool date = false)
|
public override List<BaseFile> GetChildren(bool date = false)
|
||||||
{
|
{
|
||||||
List<BaseFile> found = new List<BaseFile>();
|
List<BaseFile> found = new List<BaseFile>();
|
||||||
string gamename = Path.GetFileNameWithoutExtension(this.Filename);
|
string gamename = Path.GetFileNameWithoutExtension(this.Filename);
|
||||||
@@ -300,8 +299,8 @@ namespace SabreTools.Library.FileTypes
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If secure hashes are disabled, do a quickscan
|
// Perform a quickscan, if flagged to
|
||||||
if (omitFromScan == Hash.SecureHashes)
|
if (QuickScan)
|
||||||
{
|
{
|
||||||
string newname = zf.Filename(i);
|
string newname = zf.Filename(i);
|
||||||
long newsize = (long)zf.UncompressedSize(i);
|
long newsize = (long)zf.UncompressedSize(i);
|
||||||
@@ -322,7 +321,6 @@ namespace SabreTools.Library.FileTypes
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
BaseFile zipEntryRom = readStream.GetInfo(size: (long)zf.UncompressedSize(i), keepReadOpen: true);
|
BaseFile zipEntryRom = readStream.GetInfo(size: (long)zf.UncompressedSize(i), keepReadOpen: true);
|
||||||
zipEntryRom.RemoveHashes(omitFromScan);
|
|
||||||
zipEntryRom.Filename = zf.Filename(i);
|
zipEntryRom.Filename = zf.Filename(i);
|
||||||
zipEntryRom.Parent = gamename;
|
zipEntryRom.Parent = gamename;
|
||||||
string convertedDate = zf.LastModified(i).ToString("yyyy/MM/dd hh:mm:ss");
|
string convertedDate = zf.LastModified(i).ToString("yyyy/MM/dd hh:mm:ss");
|
||||||
|
|||||||
@@ -79,11 +79,10 @@ namespace SabreTools.Library.FileTypes
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generate a list of DatItem objects from the header values in an archive
|
/// Generate a list of DatItem objects from the header values in an archive
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="omitFromScan">Hash representing the hashes that should be skipped</param>
|
|
||||||
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
/// <param name="date">True if entry dates should be included, false otherwise (default)</param>
|
||||||
/// <returns>List of DatItem objects representing the found data</returns>
|
/// <returns>List of DatItem objects representing the found data</returns>
|
||||||
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
/// <remarks>TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually</remarks>
|
||||||
public override List<BaseFile> GetChildren(Hash omitFromScan = Hash.DeepHashes, bool date = false)
|
public override List<BaseFile> GetChildren(bool date = false)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Text.RegularExpressions;
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
using SabreTools.Library.DatFiles;
|
using SabreTools.Library.DatFiles;
|
||||||
using SabreTools.Library.DatItems;
|
using SabreTools.Library.DatItems;
|
||||||
@@ -42,6 +43,35 @@ namespace SabreTools.Library.Tools
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get the fields associated with each hash type
|
||||||
|
/// </summary>
|
||||||
|
public static List<Field> AsFields(this Hash hash)
|
||||||
|
{
|
||||||
|
List<Field> fields = new List<Field>();
|
||||||
|
|
||||||
|
if (hash.HasFlag(Hash.CRC))
|
||||||
|
fields.Add(Field.DatItem_CRC);
|
||||||
|
if (hash.HasFlag(Hash.MD5))
|
||||||
|
fields.Add(Field.DatItem_MD5);
|
||||||
|
#if NET_FRAMEWORK
|
||||||
|
if (hash.HasFlag(Hash.RIPEMD160))
|
||||||
|
fields.Add(Field.DatItem_RIPEMD160);
|
||||||
|
#endif
|
||||||
|
if (hash.HasFlag(Hash.SHA1))
|
||||||
|
fields.Add(Field.DatItem_SHA1);
|
||||||
|
if (hash.HasFlag(Hash.SHA256))
|
||||||
|
fields.Add(Field.DatItem_SHA256);
|
||||||
|
if (hash.HasFlag(Hash.SHA384))
|
||||||
|
fields.Add(Field.DatItem_SHA384);
|
||||||
|
if (hash.HasFlag(Hash.SHA512))
|
||||||
|
fields.Add(Field.DatItem_SHA512);
|
||||||
|
if (hash.HasFlag(Hash.SpamSum))
|
||||||
|
fields.Add(Field.DatItem_SpamSum);
|
||||||
|
|
||||||
|
return fields;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the default OutputFormat associated with each PackingFlag
|
/// Get the default OutputFormat associated with each PackingFlag
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user