annotate dmd/FileName.d @ 0:10317f0c89a5

Initial commit
author korDen
date Sat, 24 Oct 2009 08:42:06 +0400
parents
children 7427ded8caf7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
1 module dmd.FileName;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
2
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
3 import dmd.String;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
4 import dmd.Array;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
5 import dmd.OutBuffer;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
6 import dmd.File;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
7
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
8 import core.stdc.stdlib : malloc, alloca;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
9 import core.stdc.string : memcpy, strlen;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
10 import core.stdc.ctype : isspace;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
11
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
12 import std.contracts : assumeUnique;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
13 import std.string : cmp, icmp;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
14 import std.file : mkdirRecurse;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
15
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
16 import core.sys.windows.windows;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
17
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
18 class FileName : String
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
19 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
20 this(string str)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
21 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
22 super(str);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
23 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
24
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
25 this(string path, string name)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
26 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
27 super(combine(path, name));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
28 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
29
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
30 hash_t hashCode()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
31 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
32 version (_WIN32) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
33 // We need a different hashCode because it must be case-insensitive
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
34 size_t len = str.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
35 hash_t hash = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
36 ubyte* s = cast(ubyte*)str.ptr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
37
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
38 for (;;)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
39 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
40 switch (len)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
41 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
42 case 0:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
43 return hash;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
44
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
45 case 1:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
46 hash *= 37;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
47 hash += *(cast(ubyte*)s) | 0x20;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
48 return hash;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
49
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
50 case 2:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
51 hash *= 37;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
52 hash += *(cast(ushort*)s) | 0x2020;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
53 return hash;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
54
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
55 case 3:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
56 hash *= 37;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
57 hash += (*cast(ushort*)s) << 8 +
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
58 ((cast(ubyte*)s)[2]) | 0x202020;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
59 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
60
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
61 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
62 hash *= 37;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
63 hash += (*cast(int*)s) | 0x20202020;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
64 s += 4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
65 len -= 4;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
66 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
67 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
68 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
69 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
70 // darwin HFS is case insensitive, though...
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
71 return super.hashCode();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
72 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
73 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
74
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
75 bool opEquals(Object obj)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
76 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
77 return opCmp(obj) == 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
78 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
79
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
80 static int equals(string name1, string name2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
81 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
82 return compare(name1, name2) == 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
83 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
84
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
85 int opCmp(Object obj)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
86 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
87 return compare(str, (cast(FileName)obj).str);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
88 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
89
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
90 static int compare(string name1, string name2)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
91 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
92 version (_WIN32) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
93 return icmp(name1, name2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
94 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
95 return cmp(name1, name2);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
96 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
97 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
98
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
99 static bool absolute(string name)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
100 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
101 version (_WIN32) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
102 return (*name == '\\') ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
103 (*name == '/') ||
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
104 (*name && name[1] == ':');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
105 } else version (POSIX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
106 return (*name == '/');
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
107 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
108 static assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
109 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
110 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
111
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
112 /********************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
113 * Return filename extension (read-only).
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
114 * Points past '.' of extension.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
115 * If there isn't one, return NULL.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
116 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
117 static string ext(string str)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
118 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
119 foreach_reverse (i, c; str)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
120 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
121 switch (c)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
122 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
123 case '.':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
124 return str[i+1..$];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
125 version (POSIX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
126 case '/':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
127 return null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
128 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
129 version (_WIN32) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
130 case '\\':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
131 case ':':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
132 case '/':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
133 return null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
134
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
135 } default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
136 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
137 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
138 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
139
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
140 return null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
141 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
142
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
143 string ext()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
144 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
145 return ext(str);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
146 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
147
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
148 /********************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
149 * Return filename with extension removed.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
150 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
151
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
152 static string removeExt(string str)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
153 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
154 string e = ext(str);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
155 if (e !is null)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
156 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
157 size_t len = (e.ptr - str.ptr - 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
158 return str[0..len];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
159 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
160
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
161 return str;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
162 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
163
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
164 /********************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
165 * Return filename name excluding path (read-only).
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
166 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
167
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
168 static string name(string str)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
169 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
170 foreach_reverse(i, c; str)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
171 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
172 switch (c)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
173 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
174 version (POSIX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
175 case '/':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
176 return str[i+1..$];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
177 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
178 version (_WIN32) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
179 case '/':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
180 case '\\':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
181 return str[i+1..$];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
182 case ':':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
183 /* The ':' is a drive letter only if it is the second
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
184 * character or the last character,
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
185 * otherwise it is an ADS (Alternate Data Stream) separator.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
186 * Consider ADS separators as part of the file name.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
187 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
188 if (i == 1 || i == str.length - 1)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
189 return str[i+1..$];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
190 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
191 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
192 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
193 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
194 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
195
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
196 return str;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
197 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
198
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
199 string name()
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
200 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
201 return name(str);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
202 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
203
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
204 /**************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
205 * Return path portion of str.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
206 * Path will does not include trailing path separator.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
207 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
208
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
209 static string path(string str)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
210 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
211 auto n = name(str).ptr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
212
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
213 if (n > str.ptr)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
214 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
215 auto p = n - 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
216 version (POSIX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
217 if (*p == '/')
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
218 n--;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
219 } else version (_WIN32) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
220 if (*p == '\\' || *p == '/')
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
221 n--;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
222 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
223 static assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
224 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
225 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
226
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
227 size_t pathlen = n - str.ptr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
228 return str[0..pathlen];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
229 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
230
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
231 /**************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
232 * Replace filename portion of path.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
233 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
234
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
235 static string replaceName(string path, string name)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
236 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
237 if (absolute(name))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
238 return name;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
239
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
240 string n = FileName.name(path);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
241 if (n is path)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
242 return name;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
243
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
244 size_t pathlen = n.ptr - path.ptr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
245 size_t namelen = name.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
246
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
247 char* f = cast(char*)malloc(pathlen + 1 + namelen + 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
248 memcpy(f, path.ptr, pathlen);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
249 version (POSIX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
250 if (path[pathlen - 1] != '/')
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
251 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
252 f[pathlen] = '/';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
253 pathlen++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
254 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
255 } else version (_WIN32) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
256 if (path[pathlen - 1] != '\\' &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
257 path[pathlen - 1] != '/' &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
258 path[pathlen - 1] != ':')
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
259 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
260 f[pathlen] = '\\';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
261 pathlen++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
262 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
263 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
264 static assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
265 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
266 memcpy(f + pathlen, name.ptr, namelen + 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
267
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
268 return assumeUnique(f[0..pathlen+namelen]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
269 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
270
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
271 static string combine(string path, string name)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
272 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
273 size_t pathlen;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
274 size_t namelen;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
275
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
276 if (path.length == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
277 return name;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
278
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
279 pathlen = path.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
280 namelen = name.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
281
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
282 char* f = cast(char*)malloc(pathlen + 1 + namelen + 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
283
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
284 memcpy(f, path.ptr, pathlen);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
285
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
286 version (POSIX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
287 if (path[pathlen - 1] != '/')
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
288 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
289 f[pathlen] = '/';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
290 pathlen++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
291 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
292 } else version (_WIN32) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
293 if (path[pathlen - 1] != '\\' &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
294 path[pathlen - 1] != '/' &&
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
295 path[pathlen - 1] != ':')
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
296 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
297 f[pathlen] = '\\';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
298 pathlen++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
299 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
300 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
301 static assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
302 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
303 memcpy(f + pathlen, name.ptr, namelen + 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
304
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
305 return assumeUnique(f[0..pathlen+namelen]);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
306 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
307
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
308 static string[] splitPath(const(char)[] spath)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
309 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
310 char c = 0; // unnecessary initializer is for VC /W4
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
311
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
312 scope OutBuffer buf = new OutBuffer();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
313 string[] array;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
314
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
315 if (spath !is null)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
316 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
317 const(char)* p = spath.ptr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
318 int len = spath.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
319 do
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
320 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
321 char instring = 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
322
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
323 while (len > 0 && isspace(*p)) { // skip leading whitespace
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
324 p++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
325 --len;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
326 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
327
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
328 buf.reserve(len + 1); // guess size of path
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
329 for (; len; p++, len--)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
330 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
331 c = *p;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
332 switch (c)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
333 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
334 case '"':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
335 instring ^= 1; // toggle inside/outside of string
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
336 continue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
337
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
338 version (MACINTOSH) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
339 case ',':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
340 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
341 version (_WIN32) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
342 case ';':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
343 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
344 version (POSIX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
345 case ':':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
346 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
347 p++;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
348 break; // note that ; cannot appear as part
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
349 // of a path, quotes won't protect it
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
350
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
351 case 0x1A: // ^Z means end of file
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
352 //case 0:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
353 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
354
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
355 case '\r':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
356 continue; // ignore carriage returns
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
357
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
358 version (POSIX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
359 case '~':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
360 buf.writestring(getenv("HOME"));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
361 continue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
362 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
363
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
364 version (disabled) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
365 case ' ':
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
366 case '\t': // tabs in filenames?
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
367 if (!instring) // if not in string
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
368 break; // treat as end of path
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
369 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
370 default:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
371 buf.writeByte(c);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
372 continue;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
373 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
374 break;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
375 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
376 if (buf.offset) // if path is not empty
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
377 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
378 //buf.writeByte(0); // to asciiz
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
379 array ~= buf.extractString();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
380 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
381 } while (len > 0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
382 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
383
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
384 return array;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
385 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
386
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
387 static FileName defaultExt(string name, string ext)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
388 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
389 string e = FileName.ext(name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
390 if (e !is null) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
391 // if already has an extension
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
392 return new FileName(name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
393 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
394
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
395 size_t len = name.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
396 size_t extlen = ext.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
397 char* s = cast(char*)malloc(len + 1 + extlen + 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
398 memcpy(s, name.ptr, len);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
399 s[len] = '.';
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
400 memcpy(s + len + 1, ext.ptr, extlen + 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
401
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
402 return new FileName(assumeUnique(s[0..len+1+extlen]));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
403 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
404
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
405 static FileName forceExt(string name, string ext)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
406 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
407 string e = FileName.ext(name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
408 if (e !is null) // if already has an extension
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
409 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
410 size_t len = e.ptr - name.ptr;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
411 size_t extlen = ext.length;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
412
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
413 char* s = cast(char*)malloc(len + extlen + 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
414 memcpy(s, name.ptr, len);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
415 memcpy(s + len, ext.ptr, extlen + 1);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
416 return new FileName(assumeUnique(s[0..len+extlen]));
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
417 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
418
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
419 return defaultExt(name, ext); // doesn't have one
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
420 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
421
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
422 /******************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
423 * Return true if extensions match.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
424 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
425
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
426 bool equalsExt(string ext)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
427 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
428 string e = FileName.ext();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
429 if (e.length == 0 && ext.length == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
430 return true;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
431
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
432 if (e.length == 0 || ext.length == 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
433 return false;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
434
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
435 version (POSIX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
436 return cmp(e,ext) == 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
437 } else version (_WIN32) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
438 return icmp(e,ext) == 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
439 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
440 static assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
441 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
442 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
443
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
444 /*************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
445 * Copy file from this to to.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
446 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
447
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
448 void CopyTo(FileName to)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
449 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
450 scope File file = new File(this);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
451
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
452 version (_WIN32) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
453 file.touchtime = malloc(WIN32_FIND_DATA.sizeof); // keep same file time
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
454 } else version (POSIX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
455 file.touchtime = malloc(stat.sizeof); // keep same file time
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
456 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
457 static assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
458 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
459 file.readv();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
460 file.name = to;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
461 file.writev();
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
462 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
463
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
464 /*************************************
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
465 * Search Path for file.
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
466 * Input:
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
467 * cwd if true, search current directory before searching path
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
468 */
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
469
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
470 static string searchPath(Array path, string name, bool cwd)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
471 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
472 if (absolute(name)) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
473 return exists(name) ? name : null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
474 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
475
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
476 if (cwd) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
477 if (exists(name)) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
478 return name;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
479 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
480 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
481
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
482 if (path !is null) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
483 foreach (i; 0..path.dim)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
484 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
485 String p = cast(String)path.data[i];
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
486 string n = combine(p.str, name);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
487
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
488 if (exists(n))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
489 return n;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
490 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
491 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
492
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
493 return null;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
494 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
495
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
496 static int exists(string name)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
497 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
498 version (POSIX) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
499 stat st;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
500
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
501 if (stat(name, &st) < 0)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
502 return 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
503 if (S_ISDIR(st.st_mode))
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
504 return 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
505 return 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
506 } else version (_WIN32) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
507 HANDLE h = CreateFileA(toStringz(name), GENERIC_READ, FILE_SHARE_READ, null, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, HANDLE.init); ///
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
508 if (h == INVALID_HANDLE_VALUE) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
509 return 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
510 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
511
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
512 CloseHandle(h);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
513
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
514 DWORD dw = GetFileAttributesA(name.ptr); /// CARE!
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
515 if (dw == -1L) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
516 assert(false);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
517 return 0;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
518 } else if (dw & FILE_ATTRIBUTE_DIRECTORY) {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
519 return 2;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
520 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
521 return 1;
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
522 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
523 } else {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
524 static assert(0);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
525 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
526 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
527
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
528 static void ensurePathExists(string path)
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
529 {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
530 try {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
531 mkdirRecurse(path);
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
532 } catch {
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
533 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
534 }
10317f0c89a5 Initial commit
korDen
parents:
diff changeset
535 }