anshdadhich commited on
Commit
a012a68
·
verified ·
1 Parent(s): 5c76d7c

Upload FastSeekWpf/App.xaml.cs

Browse files
Files changed (1) hide show
  1. FastSeekWpf/App.xaml.cs +8 -15
FastSeekWpf/App.xaml.cs CHANGED
@@ -6,7 +6,6 @@ using System.Linq;
6
  using System.Runtime.InteropServices;
7
  using System.Text;
8
  using System.Threading;
9
- using System.Threading.Tasks;
10
  using System.Windows;
11
  using System.Windows.Interop;
12
  using FastSeekWpf.Core;
@@ -145,33 +144,27 @@ public partial class App : Application
145
  {
146
  using var reader = new MftReader(drive);
147
 
148
- // Try direct first
149
- try
 
150
  {
151
- scan = reader.ScanDirect();
152
  method = "direct";
153
  Logger.Log($"Direct scan OK for {drive.Letter}: {scan.Records.Count} records");
154
  }
155
- catch (Exception ex1)
156
  {
157
- errorMsg = $"direct: {ex1.Message}";
158
- Logger.Log($"Direct scan failed for {drive.Letter}: {ex1.Message}");
159
  }
160
 
161
  // Fallback
162
  if (scan == null || scan.Records.Count == 0)
163
  {
164
- try
 
165
  {
166
- scan = reader.Scan();
167
  method = "fallback";
168
  Logger.Log($"Fallback scan OK for {drive.Letter}: {scan.Records.Count} records");
169
  }
170
- catch (Exception ex2)
171
- {
172
- errorMsg = (errorMsg != null ? errorMsg + " | " : "") + $"fallback: {ex2.Message}";
173
- Logger.Log($"Fallback scan failed for {drive.Letter}: {ex2.Message}");
174
- }
175
  }
176
 
177
  if (scan != null && scan.Records.Count > 0)
@@ -182,7 +175,7 @@ public partial class App : Application
182
  }
183
  else
184
  {
185
- PrintError($" {drive.Letter}: 0 records — {errorMsg ?? "unknown failure"}");
186
  }
187
  }
188
  catch (Exception ex)
 
6
  using System.Runtime.InteropServices;
7
  using System.Text;
8
  using System.Threading;
 
9
  using System.Windows;
10
  using System.Windows.Interop;
11
  using FastSeekWpf.Core;
 
144
  {
145
  using var reader = new MftReader(drive);
146
 
147
+ // Try direct first (matches Rust: reader.scan_direct())
148
+ scan = reader.ScanDirect();
149
+ if (scan != null)
150
  {
 
151
  method = "direct";
152
  Logger.Log($"Direct scan OK for {drive.Letter}: {scan.Records.Count} records");
153
  }
154
+ else
155
  {
156
+ Logger.Log($"Direct scan unavailable for {drive.Letter}, trying fallback");
 
157
  }
158
 
159
  // Fallback
160
  if (scan == null || scan.Records.Count == 0)
161
  {
162
+ scan = reader.Scan();
163
+ if (scan != null && scan.Records.Count > 0)
164
  {
 
165
  method = "fallback";
166
  Logger.Log($"Fallback scan OK for {drive.Letter}: {scan.Records.Count} records");
167
  }
 
 
 
 
 
168
  }
169
 
170
  if (scan != null && scan.Records.Count > 0)
 
175
  }
176
  else
177
  {
178
+ PrintError($" {drive.Letter}: 0 records — {errorMsg ?? "could not read MFT (run as Admin?)"}");
179
  }
180
  }
181
  catch (Exception ex)