diff --git a/BurnOutSharp/BurnOutSharp.csproj b/BurnOutSharp/BurnOutSharp.csproj index 288c9d20..dfd4dad2 100644 --- a/BurnOutSharp/BurnOutSharp.csproj +++ b/BurnOutSharp/BurnOutSharp.csproj @@ -54,6 +54,7 @@ + diff --git a/BurnOutSharp/Progress.cs b/BurnOutSharp/Progress.cs new file mode 100644 index 00000000..34c408ad --- /dev/null +++ b/BurnOutSharp/Progress.cs @@ -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; + } + } +} diff --git a/BurnOutSharp/ProtectionFind.cs b/BurnOutSharp/ProtectionFind.cs index 9a8ab4d6..99b8d03e 100644 --- a/BurnOutSharp/ProtectionFind.cs +++ b/BurnOutSharp/ProtectionFind.cs @@ -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) /// - public static Dictionary Scan(string path, IProgress progress = null) + public static Dictionary Scan(string path, IProgress progress = null) { var protections = new Dictionary(); // 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(); } - // Checkpoint - progress?.Report(1); - return protections; }