| 363 | |
| 364 | |
| 365 | static bool MakeDirRec(Str *path) { |
| 366 | FileInfo info; |
| 367 | path = path->clone(); |
| 368 | for (Int i = 1; i < path->len();) { |
| 369 | Int p = path->find(PathSeparator, i); |
| 370 | if (p == NOWHERE) |
| 371 | break; |
| 372 | path->at(p) = '\0'; |
| 373 | if (FileStat(info, path, true)) { |
| 374 | if (!info.is_dir) |
| 375 | return false; |
| 376 | } else if (mkdir(path->c_str(), 0777) < 0) { |
| 377 | return false; |
| 378 | } |
| 379 | path->at(p) = PathSeparator[0]; |
| 380 | i = p+1; |
| 381 | } |
| 382 | if (FileStat(info, path, true)) { |
| 383 | if (!info.is_dir) |
| 384 | return false; |
| 385 | } else if (mkdir(path->c_str(), 0777) < 0) { |
| 386 | return false; |
| 387 | } |
| 388 | return true; |
| 389 | } |
| 390 | |
| 391 | Str *AbsolutePath(Str *path) { |
| 392 | if (path->starts_with(PathSeparator)) { |