Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DriveInfoInternal.cs
Go to the documentation of this file.
1namespace System.IO;
2
3internal static class DriveInfoInternal
4{
5 public static string[] GetLogicalDrives()
6 {
7 int logicalDrives = global::Interop.Kernel32.GetLogicalDrives();
8 if (logicalDrives == 0)
9 {
11 }
12 uint num = (uint)logicalDrives;
13 int num2 = 0;
14 while (num != 0)
15 {
16 if ((num & (true ? 1u : 0u)) != 0)
17 {
18 num2++;
19 }
20 num >>= 1;
21 }
22 string[] array = new string[num2];
23 Span<char> span = stackalloc char[3] { 'A', ':', '\\' };
24 num = (uint)logicalDrives;
25 num2 = 0;
26 while (num != 0)
27 {
28 if ((num & (true ? 1u : 0u)) != 0)
29 {
30 array[num2++] = span.ToString();
31 }
32 num >>= 1;
33 span[0] += '\u0001';
34 }
35 return array;
36 }
37
38 public static string NormalizeDriveName(string driveName)
39 {
40 string text;
41 if (driveName.Length == 1)
42 {
43 text = driveName + ":\\";
44 }
45 else
46 {
47 text = Path.GetPathRoot(driveName);
48 if (string.IsNullOrEmpty(text) || text.StartsWith("\\\\", StringComparison.Ordinal))
49 {
51 }
52 }
53 if (text.Length == 2 && text[1] == ':')
54 {
55 text += "\\";
56 }
57 char c = driveName[0];
58 if ((c < 'A' || c > 'Z') && (c < 'a' || c > 'z'))
59 {
61 }
62 return text;
63 }
64}
static string[] GetLogicalDrives()
static string NormalizeDriveName(string driveName)
static ? string GetPathRoot(string? path)
Definition Path.cs:1008
static Exception GetExceptionForLastWin32Error(string path="")
static string Arg_MustBeDriveLetterOrRootDir
Definition SR.cs:14
Definition SR.cs:7
override string ToString()
Definition Span.cs:261