Upload FastSeekWpf/Core/MftReader.cs
Browse files
FastSeekWpf/Core/MftReader.cs
CHANGED
|
@@ -44,7 +44,7 @@ public class MftReader : IDisposable
|
|
| 44 |
|
| 45 |
/// <summary>
|
| 46 |
/// Try direct sequential read of $MFT for maximum speed.
|
| 47 |
-
/// Returns
|
| 48 |
/// </summary>
|
| 49 |
public ScanResult? ScanDirect()
|
| 50 |
{
|
|
@@ -84,7 +84,7 @@ public class MftReader : IDisposable
|
|
| 84 |
bool ok = Win32Api.ReadFile(
|
| 85 |
mftHandle, buffer, leftover, (uint)(buffer.Length - leftover), out bytesRead, IntPtr.Zero);
|
| 86 |
|
| 87 |
-
if (ok
|
| 88 |
break;
|
| 89 |
|
| 90 |
int total = leftover + (int)bytesRead;
|
|
@@ -106,7 +106,7 @@ public class MftReader : IDisposable
|
|
| 106 |
offset += recordSize.Value;
|
| 107 |
}
|
| 108 |
|
| 109 |
-
// Align
|
| 110 |
offset = total - (total % recordSize.Value);
|
| 111 |
|
| 112 |
leftover = total - offset;
|
|
|
|
| 44 |
|
| 45 |
/// <summary>
|
| 46 |
/// Try direct sequential read of $MFT for maximum speed.
|
| 47 |
+
/// Returns None if direct access is unavailable (matches Rust Option<ScanResult>).
|
| 48 |
/// </summary>
|
| 49 |
public ScanResult? ScanDirect()
|
| 50 |
{
|
|
|
|
| 84 |
bool ok = Win32Api.ReadFile(
|
| 85 |
mftHandle, buffer, leftover, (uint)(buffer.Length - leftover), out bytesRead, IntPtr.Zero);
|
| 86 |
|
| 87 |
+
if (!ok || bytesRead == 0)
|
| 88 |
break;
|
| 89 |
|
| 90 |
int total = leftover + (int)bytesRead;
|
|
|
|
| 106 |
offset += recordSize.Value;
|
| 107 |
}
|
| 108 |
|
| 109 |
+
// Align down to record boundary (matches Rust: offset = total - (total % record_size))
|
| 110 |
offset = total - (total % recordSize.Value);
|
| 111 |
|
| 112 |
leftover = total - offset;
|