@@ -33,6 +33,7 @@ public static class ProtectionFind
33
33
/// Scan a path to find any known copy protection(s)
34
34
/// </summary>
35
35
/// <param name="path">Path to scan for protection(s)</param>
36
+ /// <param name="progress">Optional progress indicator that will return a float in the range from 0 to 1</param>
36
37
/// <returns>Dictionary of filename to protection mappings, if possible</returns>
37
38
/// <remarks>
38
39
/// TODO: Sector scanning?
@@ -51,10 +52,13 @@ public static class ProtectionFind
51
52
/// - The Bongle (http://web.archive.org/web/19990508193708/www.hideseek.com/products.htm)
52
53
/// - The Copy-Protected CD (http://web.archive.org/web/19990508193708/www.hideseek.com/products.htm)
53
54
/// </remarks>
54
- public static Dictionary < string , string > Scan ( string path )
55
+ public static Dictionary < string , string > Scan ( string path , IProgress < float > progress = null )
55
56
{
56
57
var protections = new Dictionary < string , string > ( ) ;
57
58
59
+ // Checkpoint
60
+ progress ? . Report ( 0 ) ;
61
+
58
62
// Create mappings for checking against
59
63
var mappings = CreateFilenameProtectionMapping ( ) ;
60
64
@@ -97,8 +101,14 @@ public static Dictionary<string, string> Scan(string path)
97
101
protections [ path ] = "Zzxzz" ;
98
102
99
103
// Loop through all files and scan them
100
- foreach ( string file in files )
104
+ for ( int i = 0 ; i < files . Length ; i ++ )
101
105
{
106
+ // Get the current file
107
+ string file = files [ i ] ;
108
+
109
+ // Checkpoint
110
+ progress ? . Report ( i / files . Length ) ;
111
+
102
112
// If the file is in the list of known files, add that to the protections found
103
113
if ( mappings . ContainsKey ( Path . GetFileName ( file ) ) )
104
114
protections [ file ] = mappings [ Path . GetFileName ( file ) ] ;
@@ -120,6 +130,9 @@ public static Dictionary<string, string> Scan(string path)
120
130
protections = new Dictionary < string , string > ( ) ;
121
131
}
122
132
133
+ // Checkpoint
134
+ progress ? . Report ( 1 ) ;
135
+
123
136
return protections ;
124
137
}
125
138
0 commit comments