anshdadhich commited on
Commit
8f85f2c
·
verified ·
1 Parent(s): 8eb8349

Upload FastSeekWpf/Core/SearchEngine.cs

Browse files
Files changed (1) hide show
  1. FastSeekWpf/Core/SearchEngine.cs +7 -4
FastSeekWpf/Core/SearchEngine.cs CHANGED
@@ -150,7 +150,7 @@ public static class SearchEngine
150
  foreach (var (idx, baseRank) in candidates[..candidateCount])
151
  {
152
  var entry = store.Entries[idx];
153
- string fullPath = BuildPathFast(store, entry.FileRef, pathBuilder);
154
  string fullPathLower = fullPath.ToLowerInvariant();
155
 
156
  if (excludedDirs.Count > 0)
@@ -223,7 +223,7 @@ public static class SearchEngine
223
  if (!name.EndsWith(dotExt)) continue;
224
 
225
  var entry = store.Entries[i];
226
- string fullPath = BuildPathFast(store, entry.FileRef, pathBuilder);
227
  string fullPathLower = fullPath.ToLowerInvariant();
228
 
229
  bool excluded = false;
@@ -254,12 +254,13 @@ public static class SearchEngine
254
  return results;
255
  }
256
 
257
- private static string BuildPathFast(IndexStore store, ulong fileRef, StringBuilder sb)
258
  {
259
  sb.Clear();
260
  string[] components = new string[64];
261
  int compCount = 0;
262
  ulong current = fileRef;
 
263
 
264
  for (int i = 0; i < 64; i++)
265
  {
@@ -269,11 +270,13 @@ public static class SearchEngine
269
  int eIdx = (int)idx;
270
  components[compCount++] = store.NameAt(eIdx);
271
  var entry = store.Entries[eIdx];
 
272
  if (entry.ParentRef == current) break;
273
  current = entry.ParentRef;
274
  }
275
 
276
- sb.Append(store.DriveRoot);
 
277
  for (int i = compCount - 1; i >= 0; i--)
278
  {
279
  if (sb.Length > 0 && sb[sb.Length - 1] != '\\' && sb[sb.Length - 1] != '/')
 
150
  foreach (var (idx, baseRank) in candidates[..candidateCount])
151
  {
152
  var entry = store.Entries[idx];
153
+ string fullPath = BuildPathFast(store, entry.FileRef, pathBuilder, entry.DriveIdx);
154
  string fullPathLower = fullPath.ToLowerInvariant();
155
 
156
  if (excludedDirs.Count > 0)
 
223
  if (!name.EndsWith(dotExt)) continue;
224
 
225
  var entry = store.Entries[i];
226
+ string fullPath = BuildPathFast(store, entry.FileRef, pathBuilder, entry.DriveIdx);
227
  string fullPathLower = fullPath.ToLowerInvariant();
228
 
229
  bool excluded = false;
 
254
  return results;
255
  }
256
 
257
+ private static string BuildPathFast(IndexStore store, ulong fileRef, StringBuilder sb, byte startDriveIdx)
258
  {
259
  sb.Clear();
260
  string[] components = new string[64];
261
  int compCount = 0;
262
  ulong current = fileRef;
263
+ byte driveIdx = startDriveIdx;
264
 
265
  for (int i = 0; i < 64; i++)
266
  {
 
270
  int eIdx = (int)idx;
271
  components[compCount++] = store.NameAt(eIdx);
272
  var entry = store.Entries[eIdx];
273
+ driveIdx = entry.DriveIdx;
274
  if (entry.ParentRef == current) break;
275
  current = entry.ParentRef;
276
  }
277
 
278
+ string driveRoot = driveIdx < store.DriveRoots.Count ? store.DriveRoots[driveIdx] : "C:\\";
279
+ sb.Append(driveRoot);
280
  for (int i = compCount - 1; i >= 0; i--)
281
  {
282
  if (sb.Length > 0 && sb[sb.Length - 1] != '\\' && sb[sb.Length - 1] != '/')