Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
FileSystemInfo.cs
Go to the documentation of this file.
3
4namespace System.IO;
5
7{
8 protected string FullPath;
9
10 protected string OriginalPath;
11
12 internal string _name;
13
14 private string _linkTarget;
15
16 private bool _linkTargetIsValid;
17
19
20 private int _dataInitialized = -1;
21
22 public virtual string FullName => FullPath;
23
24 public string Extension
25 {
26 get
27 {
28 int length = FullPath.Length;
29 int num = length;
30 while (--num >= 0)
31 {
32 char c = FullPath[num];
33 if (c == '.')
34 {
35 return FullPath.Substring(num, length - num);
36 }
38 {
39 break;
40 }
41 }
42 return string.Empty;
43 }
44 }
45
46 public virtual string Name => _name;
47
48 public virtual bool Exists
49 {
50 get
51 {
52 try
53 {
54 return ExistsCore;
55 }
56 catch
57 {
58 return false;
59 }
60 }
61 }
62
64 {
65 get
66 {
68 }
69 set
70 {
72 }
73 }
74
76 {
77 get
78 {
80 }
81 set
82 {
84 }
85 }
86
88 {
89 get
90 {
92 }
93 set
94 {
96 }
97 }
98
100 {
101 get
102 {
104 }
105 set
106 {
108 }
109 }
110
112 {
113 get
114 {
116 }
117 set
118 {
120 }
121 }
122
124 {
125 get
126 {
128 }
129 set
130 {
132 }
133 }
134
135 public string? LinkTarget
136 {
137 get
138 {
140 {
141 return _linkTarget;
142 }
144 _linkTargetIsValid = true;
145 return _linkTarget;
146 }
147 }
148
150 {
151 get
152 {
154 return (FileAttributes)_data.dwFileAttributes;
155 }
156 set
157 {
159 _dataInitialized = -1;
160 }
161 }
162
163 internal bool ExistsCore
164 {
165 get
166 {
167 if (_dataInitialized == -1)
168 {
169 RefreshCore();
170 }
171 if (_dataInitialized != 0)
172 {
173 return false;
174 }
175 if (_data.dwFileAttributes != -1)
176 {
177 return this is DirectoryInfo == ((_data.dwFileAttributes & 0x10) == 16);
178 }
179 return false;
180 }
181 }
182
184 {
185 get
186 {
188 return _data.ftCreationTime.ToDateTimeOffset();
189 }
190 set
191 {
193 _dataInitialized = -1;
194 }
195 }
196
198 {
199 get
200 {
202 return _data.ftLastAccessTime.ToDateTimeOffset();
203 }
204 set
205 {
207 _dataInitialized = -1;
208 }
209 }
210
212 {
213 get
214 {
216 return _data.ftLastWriteTime.ToDateTimeOffset();
217 }
218 set
219 {
221 _dataInitialized = -1;
222 }
223 }
224
225 internal long LengthCore
226 {
227 get
228 {
230 return (long)((ulong)_data.nFileSizeHigh << 32) | ((long)_data.nFileSizeLow & 0xFFFFFFFFL);
231 }
232 }
233
234 internal string NormalizedPath
235 {
236 get
237 {
239 {
240 return FullPath;
241 }
243 }
244 }
245
250
251 internal void Invalidate()
252 {
253 _linkTargetIsValid = false;
255 }
256
258 {
260 }
261
262 public abstract void Delete();
263
270
275
276 public override string ToString()
277 {
278 return OriginalPath ?? string.Empty;
279 }
280
281 protected FileSystemInfo()
282 {
283 }
284
286 {
287 FileSystemInfo fileSystemInfo = (findData.IsDirectory ? ((FileSystemInfo)new DirectoryInfo(fullPath, null, findData.FileName.ToString(), isNormalized: true)) : ((FileSystemInfo)new FileInfo(fullPath, null, findData.FileName.ToString(), isNormalized: true)));
289 return fileSystemInfo;
290 }
291
292 internal void InvalidateCore()
293 {
294 _dataInitialized = -1;
295 }
296
298 {
299 _data.dwFileAttributes = (int)info->FileAttributes;
300 _data.ftCreationTime = *(Interop.Kernel32.FILE_TIME*)(&info->CreationTime);
301 _data.ftLastAccessTime = *(Interop.Kernel32.FILE_TIME*)(&info->LastAccessTime);
302 _data.ftLastWriteTime = *(Interop.Kernel32.FILE_TIME*)(&info->LastWriteTime);
303 _data.nFileSizeHigh = (uint)(info->EndOfFile >> 32);
304 _data.nFileSizeLow = (uint)info->EndOfFile;
306 }
307
309 {
310 if (_dataInitialized == -1)
311 {
313 RefreshCore();
314 }
315 if (_dataInitialized != 0)
316 {
318 }
319 }
320
321 public void Refresh()
322 {
323 _linkTargetIsValid = false;
324 RefreshCore();
325 }
326
331}
DateTimeOffset LastWriteTimeCore
DateTimeOffset LastAccessTimeCore
FileSystemInfo(SerializationInfo info, StreamingContext context)
static unsafe FileSystemInfo Create(string fullPath, ref FileSystemEntry findData)
void CreateAsSymbolicLink(string pathToTarget)
virtual void GetObjectData(SerializationInfo info, StreamingContext context)
override string ToString()
FileSystemInfo? ResolveLinkTarget(bool returnFinalTarget)
unsafe void Init(Interop.NtDll.FILE_FULL_DIR_INFORMATION *info)
DateTimeOffset CreationTimeCore
Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA _data
static FileSystemInfo ResolveLinkTarget(string linkPath, bool returnFinalTarget, bool isDirectory)
static void SetCreationTime(string fullPath, DateTimeOffset time, bool asDirectory)
static void SetLastWriteTime(string fullPath, DateTimeOffset time, bool asDirectory)
static int FillAttributeInfo(string path, ref global::Interop.Kernel32.WIN32_FILE_ATTRIBUTE_DATA data, bool returnErrorOnNotFound)
Definition FileSystem.cs:36
static void VerifyValidPath(string path, string argName)
Definition FileSystem.cs:10
static void SetAttributes(string fullPath, FileAttributes attributes)
static string GetLinkTarget(string linkPath, bool isDirectory)
static void CreateSymbolicLink(string path, string pathToTarget, bool isDirectory)
static void SetLastAccessTime(string fullPath, DateTimeOffset time, bool asDirectory)
static DateTimeOffset GetUtcDateTimeOffset(DateTime dateTime)
Definition File.cs:143
static bool IsDirectorySeparator(char c)
static bool EndsWithPeriodOrSpace(string path)
static string EnsureExtendedPrefix(string path)
static readonly char VolumeSeparatorChar
Definition Path.cs:75
static Exception GetExceptionForWin32Error(int errorCode, string path="")
DateTime ToUniversalTime()
Definition DateTime.cs:1134
DateTime ToLocalTime()
Definition DateTime.cs:1068