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