Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ CreateDirectory() [2/2]

static unsafe void System.IO.FileSystem.CreateDirectory ( string fullPath,
byte[] securityDescriptor = null )
inlinestatic

Definition at line 108 of file FileSystem.cs.

109 {
111 {
112 return;
113 }
115 bool flag = false;
116 int num = fullPath.Length;
117 if (num >= 2 && PathInternal.EndsInDirectorySeparator(fullPath.AsSpan()))
118 {
119 num--;
120 }
121 int rootLength = PathInternal.GetRootLength(fullPath.AsSpan());
122 if (num > rootLength)
123 {
124 int num2 = num - 1;
125 while (num2 >= rootLength && !flag)
126 {
127 string text = fullPath.Substring(0, num2 + 1);
128 if (!DirectoryExists(text))
129 {
130 list.Add(text);
131 }
132 else
133 {
134 flag = true;
135 }
136 while (num2 > rootLength && !PathInternal.IsDirectorySeparator(fullPath[num2]))
137 {
138 num2--;
139 }
140 num2--;
141 }
142 }
143 int count = list.Count;
144 bool flag2 = true;
145 int num3 = 0;
146 string path = fullPath;
148 {
150 sECURITY_ATTRIBUTES.nLength = (uint)sizeof(Interop.Kernel32.SECURITY_ATTRIBUTES);
151 sECURITY_ATTRIBUTES.lpSecurityDescriptor = (IntPtr)ptr;
153 while (list.Count > 0)
154 {
155 string text2 = list[list.Count - 1];
156 list.RemoveAt(list.Count - 1);
158 if (!flag2 && num3 == 0)
159 {
161 if (lastError != 183)
162 {
163 num3 = lastError;
164 }
165 else if (FileExists(text2) || (!DirectoryExists(text2, out lastError) && lastError == 5))
166 {
167 num3 = lastError;
168 path = text2;
169 }
170 }
171 }
172 }
173 if (count == 0 && !flag)
174 {
175 string pathRoot = Path.GetPathRoot(fullPath);
177 {
178 throw Win32Marshal.GetExceptionForWin32Error(3, pathRoot);
179 }
180 }
181 else if (!flag2 && num3 != 0)
182 {
183 throw Win32Marshal.GetExceptionForWin32Error(num3, path);
184 }
185 }
static bool CreateDirectory(string path, ref SECURITY_ATTRIBUTES lpSecurityAttributes)
Definition Interop.cs:192
void Add(TKey key, TValue value)
static bool DirectoryExists(string fullPath)
Definition FileSystem.cs:9
static bool FileExists(string fullPath)
Definition FileSystem.cs:26

References System.Collections.Generic.Dictionary< TKey, TValue >.Add(), System.count, System.Collections.Generic.Dictionary< TKey, TValue >.Count, Interop.Kernel32.CreateDirectory(), System.IO.FileSystem.DirectoryExists(), System.IO.PathInternal.EndsInDirectorySeparator(), System.IO.FileSystem.FileExists(), System.IO.Win32Marshal.GetExceptionForWin32Error(), System.Runtime.InteropServices.Marshal.GetLastWin32Error(), System.IO.Path.GetPathRoot(), System.IO.PathInternal.GetRootLength(), System.IO.PathInternal.IsDirectorySeparator(), System.list, and System.text.