mirror of
https://github.com/SabreTools/BinaryObjectScanner.git
synced 2026-04-20 05:02:50 +00:00
Better progress indicator
This commit is contained in:
@@ -54,6 +54,7 @@
|
||||
<ItemGroup>
|
||||
<Compile Include="CaseInsensitiveDictionary.cs" />
|
||||
<Compile Include="EVORE.cs" />
|
||||
<Compile Include="Progress.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="ProtectionFind.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
16
BurnOutSharp/Progress.cs
Normal file
16
BurnOutSharp/Progress.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
namespace BurnOutSharp
|
||||
{
|
||||
public class Progress
|
||||
{
|
||||
public string Filename { get; private set; }
|
||||
public float Percentage { get; private set; }
|
||||
public string Protection { get; private set; }
|
||||
|
||||
public Progress(string filename, float percentage, string protection)
|
||||
{
|
||||
this.Filename = filename;
|
||||
this.Percentage = percentage;
|
||||
this.Protection = protection;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -52,12 +52,12 @@ namespace BurnOutSharp
|
||||
/// - The Bongle (http://web.archive.org/web/19990508193708/www.hideseek.com/products.htm)
|
||||
/// - The Copy-Protected CD (http://web.archive.org/web/19990508193708/www.hideseek.com/products.htm)
|
||||
/// </remarks>
|
||||
public static Dictionary<string, string> Scan(string path, IProgress<float> progress = null)
|
||||
public static Dictionary<string, string> Scan(string path, IProgress<Progress> progress = null)
|
||||
{
|
||||
var protections = new Dictionary<string, string>();
|
||||
|
||||
// Checkpoint
|
||||
progress?.Report(0);
|
||||
progress?.Report(new Progress(null, 0, null));
|
||||
|
||||
// Create mappings for checking against
|
||||
var mappings = CreateFilenameProtectionMapping();
|
||||
@@ -77,6 +77,9 @@ namespace BurnOutSharp
|
||||
string protectionname = ScanInFile(path)?.Replace("" + (char)0x00, "");
|
||||
if (!String.IsNullOrEmpty(protectionname))
|
||||
protections[path] = protectionname;
|
||||
|
||||
// Checkpoint
|
||||
progress?.Report(new Progress(path, 1, protectionname));
|
||||
}
|
||||
// If we have a directory
|
||||
else if (Directory.Exists(path))
|
||||
@@ -106,9 +109,6 @@ namespace BurnOutSharp
|
||||
// Get the current file
|
||||
string file = files[i];
|
||||
|
||||
// Checkpoint
|
||||
progress?.Report(i / files.Length);
|
||||
|
||||
// If the file is in the list of known files, add that to the protections found
|
||||
if (mappings.ContainsKey(Path.GetFileName(file)))
|
||||
protections[file] = mappings[Path.GetFileName(file)];
|
||||
@@ -121,6 +121,9 @@ namespace BurnOutSharp
|
||||
string protectionname = ScanInFile(file)?.Replace("" + (char)0x00, "");
|
||||
if (!String.IsNullOrEmpty(protectionname))
|
||||
protections[file] = protectionname;
|
||||
|
||||
// Checkpoint
|
||||
progress?.Report(new Progress(file, i / files.Length, protectionname));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -130,9 +133,6 @@ namespace BurnOutSharp
|
||||
protections = new Dictionary<string, string>();
|
||||
}
|
||||
|
||||
// Checkpoint
|
||||
progress?.Report(1);
|
||||
|
||||
return protections;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user