mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Simplify GetInfo
This commit is contained in:
@@ -2219,7 +2219,8 @@ namespace SabreTools.Library.DatFiles
|
|||||||
private void ProcessFile(string item, string basePath, Hash omitFromScan, bool addDate, TreatAsFiles asFiles)
|
private void ProcessFile(string item, string basePath, Hash omitFromScan, bool addDate, TreatAsFiles asFiles)
|
||||||
{
|
{
|
||||||
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, omitFromScan, addDate, Header.HeaderSkipper, asFiles);
|
BaseFile baseFile = FileExtensions.GetInfo(item, addDate, Header.HeaderSkipper, asFiles);
|
||||||
|
baseFile.RemoveHashes(omitFromScan);
|
||||||
ProcessFileHelper(item, DatItem.Create(baseFile), basePath, string.Empty);
|
ProcessFileHelper(item, DatItem.Create(baseFile), basePath, string.Empty);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2619,10 +2620,8 @@ namespace SabreTools.Library.DatFiles
|
|||||||
if (entries == null && File.Exists(file))
|
if (entries == null && File.Exists(file))
|
||||||
{
|
{
|
||||||
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
|
// TODO: All instances of Hash.DeepHashes should be made into 0x0 eventually
|
||||||
BaseFile internalFileInfo = FileExtensions.GetInfo(
|
BaseFile internalFileInfo = FileExtensions.GetInfo(file, asFiles: asFiles);
|
||||||
file,
|
internalFileInfo.RemoveHashes(quickScan ? Hash.SecureHashes : Hash.DeepHashes);
|
||||||
omitFromScan: (quickScan ? Hash.SecureHashes : Hash.DeepHashes),
|
|
||||||
asFiles: asFiles);
|
|
||||||
|
|
||||||
DatItem internalDatItem = null;
|
DatItem internalDatItem = null;
|
||||||
if (internalFileInfo.Type == FileType.AaruFormat)
|
if (internalFileInfo.Type == FileType.AaruFormat)
|
||||||
|
|||||||
@@ -268,7 +268,8 @@ namespace SabreTools.Library.FileTypes
|
|||||||
_children = new List<BaseFile>();
|
_children = new List<BaseFile>();
|
||||||
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, omitFromScan: omitFromScan, date: date);
|
BaseFile nf = FileExtensions.GetInfo(file, date: date);
|
||||||
|
nf.RemoveHashes(omitFromScan);
|
||||||
_children.Add(nf);
|
_children.Add(nf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -339,12 +339,11 @@ namespace SabreTools.Library.IO
|
|||||||
/// Retrieve file information for a single file
|
/// Retrieve file information for a single file
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="input">Filename to get information from</param>
|
/// <param name="input">Filename to get information from</param>
|
||||||
/// <param name="omitFromScan">Hash flag saying what hashes should not be calculated (defaults to none)</param>
|
|
||||||
/// <param name="date">True if the file Date should be included, false otherwise (default)</param>
|
/// <param name="date">True if the file Date should be included, false otherwise (default)</param>
|
||||||
/// <param name="header">Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise</param>
|
/// <param name="header">Populated string representing the name of the skipper to use, a blank string to use the first available checker, null otherwise</param>
|
||||||
/// <param name="asFiles">TreatAsFiles representing special format scanning</param>
|
/// <param name="asFiles">TreatAsFiles representing special format scanning</param>
|
||||||
/// <returns>Populated BaseFile object if success, empty one on error</returns>
|
/// <returns>Populated BaseFile object if success, empty one on error</returns>
|
||||||
public static BaseFile GetInfo(string input, Hash omitFromScan = 0x0, bool date = false, string header = null, TreatAsFiles asFiles = 0x00)
|
public static BaseFile GetInfo(string input, bool date = false, string header = null, TreatAsFiles asFiles = 0x00)
|
||||||
{
|
{
|
||||||
// Add safeguard if file doesn't exist
|
// Add safeguard if file doesn't exist
|
||||||
if (!File.Exists(input))
|
if (!File.Exists(input))
|
||||||
@@ -405,7 +404,6 @@ namespace SabreTools.Library.IO
|
|||||||
inputStream.Dispose();
|
inputStream.Dispose();
|
||||||
|
|
||||||
// Add unique data from the file
|
// Add unique data from the file
|
||||||
baseFile.RemoveHashes(omitFromScan);
|
|
||||||
baseFile.Filename = Path.GetFileName(input);
|
baseFile.Filename = Path.GetFileName(input);
|
||||||
baseFile.Date = (date ? new FileInfo(input).LastWriteTime.ToString("yyyy/MM/dd HH:mm:ss") : string.Empty);
|
baseFile.Date = (date ? new FileInfo(input).LastWriteTime.ToString("yyyy/MM/dd HH:mm:ss") : string.Empty);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user