Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
DriveInfo.cs
Go to the documentation of this file.
5
6namespace System.IO;
7
8public sealed class DriveInfo : ISerializable
9{
10 private readonly string _name;
11
12 public string Name => _name;
13
14 public bool IsReady => Directory.Exists(Name);
15
17
18 public DriveType DriveType => (DriveType)global::Interop.Kernel32.GetDriveType(Name);
19
20 public unsafe string DriveFormat
21 {
22 get
23 {
24 char* ptr = stackalloc char[261];
26 {
27 if (!global::Interop.Kernel32.GetVolumeInformation(Name, null, 0, null, null, out var _, ptr, 261))
28 {
30 }
31 }
32 return new string(ptr);
33 }
34 }
35
37 {
38 get
39 {
40 uint lpOldMode;
41 bool flag = global::Interop.Kernel32.SetThreadErrorMode(1u, out lpOldMode);
42 try
43 {
44 if (!global::Interop.Kernel32.GetDiskFreeSpaceEx(Name, out var freeBytesForUser, out var _, out var _))
45 {
47 }
48 return freeBytesForUser;
49 }
50 finally
51 {
52 if (flag)
53 {
54 global::Interop.Kernel32.SetThreadErrorMode(lpOldMode, out var _);
55 }
56 }
57 }
58 }
59
60 public long TotalFreeSpace
61 {
62 get
63 {
64 uint lpOldMode;
65 bool flag = global::Interop.Kernel32.SetThreadErrorMode(1u, out lpOldMode);
66 try
67 {
68 if (!global::Interop.Kernel32.GetDiskFreeSpaceEx(Name, out var _, out var _, out var freeBytes))
69 {
71 }
72 return freeBytes;
73 }
74 finally
75 {
76 if (flag)
77 {
78 global::Interop.Kernel32.SetThreadErrorMode(lpOldMode, out var _);
79 }
80 }
81 }
82 }
83
84 public long TotalSize
85 {
86 get
87 {
88 global::Interop.Kernel32.SetThreadErrorMode(1u, out var lpOldMode);
89 try
90 {
91 if (!global::Interop.Kernel32.GetDiskFreeSpaceEx(Name, out var _, out var totalBytes, out var _))
92 {
94 }
95 return totalBytes;
96 }
97 finally
98 {
99 global::Interop.Kernel32.SetThreadErrorMode(lpOldMode, out var _);
100 }
101 }
102 }
103
104 public unsafe string VolumeLabel
105 {
106 get
107 {
108 char* ptr = stackalloc char[261];
110 {
111 if (!global::Interop.Kernel32.GetVolumeInformation(Name, ptr, 261, null, null, out var _, null, 0))
112 {
114 }
115 }
116 return new string(ptr);
117 }
118 [SupportedOSPlatform("windows")]
120 set
121 {
122 uint lpOldMode;
123 bool flag = global::Interop.Kernel32.SetThreadErrorMode(1u, out lpOldMode);
124 try
125 {
126 if (!global::Interop.Kernel32.SetVolumeLabel(Name, value))
127 {
129 if (lastPInvokeError == 5)
130 {
132 }
134 }
135 }
136 finally
137 {
138 if (flag)
139 {
140 global::Interop.Kernel32.SetThreadErrorMode(lpOldMode, out var _);
141 }
142 }
143 }
144 }
145
146 public DriveInfo(string driveName)
147 {
148 if (driveName == null)
149 {
150 throw new ArgumentNullException("driveName");
151 }
153 }
154
159
160 public override string ToString()
161 {
162 return Name;
163 }
164
165 private static string NormalizeDriveName(string driveName)
166 {
168 }
169
170 public static DriveInfo[] GetDrives()
171 {
173 DriveInfo[] array = new DriveInfo[logicalDrives.Length];
174 for (int i = 0; i < logicalDrives.Length; i++)
175 {
176 array[i] = new DriveInfo(logicalDrives[i]);
177 }
178 return array;
179 }
180}
static bool Exists([NotNullWhen(true)] string? path)
Definition Directory.cs:43
static string[] GetLogicalDrives()
static string NormalizeDriveName(string driveName)
override string ToString()
Definition DriveInfo.cs:160
static DriveInfo[] GetDrives()
Definition DriveInfo.cs:170
DirectoryInfo RootDirectory
Definition DriveInfo.cs:16
DriveType DriveType
Definition DriveInfo.cs:18
DriveInfo(string driveName)
Definition DriveInfo.cs:146
readonly string _name
Definition DriveInfo.cs:10
static string NormalizeDriveName(string driveName)
Definition DriveInfo.cs:165
unsafe string DriveFormat
Definition DriveInfo.cs:21
unsafe string VolumeLabel
Definition DriveInfo.cs:105
static Exception GetExceptionForLastWin32DriveError(string driveName)
Definition Error.cs:7
static Exception GetExceptionForWin32DriveError(int errorCode, string driveName)
Definition Error.cs:13
static string InvalidOperation_SetVolumeLabelFailed
Definition SR.cs:16
Definition SR.cs:7
void GetObjectData(SerializationInfo info, StreamingContext context)
static System.IO.DisableMediaInsertionPrompt Create()