mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Reduce complexity of DFD logging
This commit is contained in:
@@ -1,7 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
#if NET40_OR_GREATER || NETCOREAPP
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
#endif
|
#endif
|
||||||
@@ -73,10 +72,6 @@ namespace SabreTools.DatTools
|
|||||||
/// <param name="asFile">TreatAsFile representing CHD and Archive scanning</param>
|
/// <param name="asFile">TreatAsFile representing CHD and Archive scanning</param>
|
||||||
public bool PopulateFromDir(DatFile datFile, string basePath, TreatAsFile asFile = 0x00)
|
public bool PopulateFromDir(DatFile datFile, string basePath, TreatAsFile asFile = 0x00)
|
||||||
{
|
{
|
||||||
// Set the progress variables
|
|
||||||
long totalSize = 0;
|
|
||||||
long currentSize = 0;
|
|
||||||
|
|
||||||
InternalStopwatch watch = new($"Populating DAT from {basePath}");
|
InternalStopwatch watch = new($"Populating DAT from {basePath}");
|
||||||
|
|
||||||
// Process the input
|
// Process the input
|
||||||
@@ -87,30 +82,18 @@ namespace SabreTools.DatTools
|
|||||||
// Get a list of all files to process
|
// Get a list of all files to process
|
||||||
string[] files = IOExtensions.SafeGetFiles(basePath, "*", SearchOption.AllDirectories);
|
string[] files = IOExtensions.SafeGetFiles(basePath, "*", SearchOption.AllDirectories);
|
||||||
|
|
||||||
// Loop through and add the file sizes
|
// Set intiial progress values
|
||||||
#if NET452_OR_GREATER || NETCOREAPP
|
long totalCount = files.Length;
|
||||||
Parallel.ForEach(files, Core.Globals.ParallelOptions, item =>
|
long currentCount = 0;
|
||||||
#elif NET40_OR_GREATER
|
_staticLogger.User(totalCount, currentCount);
|
||||||
Parallel.ForEach(files, item =>
|
|
||||||
#else
|
|
||||||
foreach (var item in files)
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
Interlocked.Add(ref totalSize, new FileInfo(item).Length);
|
|
||||||
#if NET40_OR_GREATER || NETCOREAPP
|
|
||||||
});
|
|
||||||
#else
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Process the files in the main folder or any subfolder
|
// Process the files in the main folder or any subfolder
|
||||||
_staticLogger.User(totalSize, currentSize);
|
|
||||||
foreach (string item in files)
|
foreach (string item in files)
|
||||||
{
|
{
|
||||||
currentSize += new FileInfo(item).Length;
|
currentCount++;
|
||||||
|
|
||||||
CheckFileForHashes(datFile, item, basePath, asFile);
|
CheckFileForHashes(datFile, item, basePath, asFile);
|
||||||
_staticLogger.User(totalSize, currentSize, item);
|
|
||||||
|
_staticLogger.User(totalCount, currentCount, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now find all folders that are empty, if we are supposed to
|
// Now find all folders that are empty, if we are supposed to
|
||||||
@@ -121,12 +104,14 @@ namespace SabreTools.DatTools
|
|||||||
{
|
{
|
||||||
_staticLogger.Verbose($"File found: {basePath}");
|
_staticLogger.Verbose($"File found: {basePath}");
|
||||||
|
|
||||||
totalSize = new FileInfo(basePath).Length;
|
// Set intiial progress values
|
||||||
_staticLogger.User(totalSize, currentSize);
|
long totalCount = 1;
|
||||||
|
_staticLogger.User(totalCount, 0);
|
||||||
|
|
||||||
string? parentPath = Path.GetDirectoryName(Path.GetDirectoryName(basePath));
|
string? parentPath = Path.GetDirectoryName(Path.GetDirectoryName(basePath));
|
||||||
CheckFileForHashes(datFile, basePath, parentPath, asFile);
|
CheckFileForHashes(datFile, basePath, parentPath, asFile);
|
||||||
_staticLogger.User(totalSize, totalSize, basePath);
|
|
||||||
|
_staticLogger.User(totalCount, totalCount, basePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
watch.Stop();
|
watch.Stop();
|
||||||
|
|||||||
Reference in New Issue
Block a user