-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNtfsReaderFastNodeProvider.cs
More file actions
45 lines (39 loc) · 1.29 KB
/
Copy pathNtfsReaderFastNodeProvider.cs
File metadata and controls
45 lines (39 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Filesystem.Ntfs;
namespace c2flux
{
internal static class NtfsReaderFastNodeProvider
{
public static List<INode> GetNodes(
NtfsReader reader,
string rootPath,
out bool fastNodeEnumerationUsed)
{
if (reader == null)
throw new ArgumentNullException(nameof(reader));
string driveRoot = Path.GetPathRoot(rootPath);
if (!string.IsNullOrWhiteSpace(driveRoot) &&
string.Equals(
NormalizeDriveRoot(rootPath),
NormalizeDriveRoot(driveRoot),
StringComparison.OrdinalIgnoreCase))
{
fastNodeEnumerationUsed = true;
return reader.GetNodesUnfiltered();
}
fastNodeEnumerationUsed = false;
return reader.GetNodes(rootPath);
}
private static string NormalizeDriveRoot(string path)
{
if (string.IsNullOrWhiteSpace(path))
return string.Empty;
return path.TrimEnd(
Path.DirectorySeparatorChar,
Path.AltDirectorySeparatorChar) +
Path.DirectorySeparatorChar;
}
}
}