| 432 | } |
| 433 | |
| 434 | Str *ProgramPath() { |
| 435 | Str *arg0 = new Str(ArgV[0]); |
| 436 | Str *result = arg0; |
| 437 | if (arg0) { |
| 438 | if (FileStat(result, true)) { |
| 439 | return NormalizePath(AbsolutePath(result)); |
| 440 | } |
| 441 | if (!arg0->starts_with(PathSeparator)) { |
| 442 | Str *path = GetEnv("PATH"); |
| 443 | StrArr *paths = path ? path->split(':') : A(); |
| 444 | for (Int i = 0; i < paths->len(); i++) { |
| 445 | Str *p = paths->at(i)->clone(); |
| 446 | p->add(PathSeparator); |
| 447 | p->add(arg0); |
| 448 | if (FileStat(p, true)) { |
| 449 | result = p; |
| 450 | break; |
| 451 | } |
| 452 | } |
| 453 | } |
| 454 | } |
| 455 | return result ? NormalizePath(AbsolutePath(result)) : result; |
| 456 | } |
| 457 | |
| 458 | bool MakeDir(const char *path, bool recursive) { |
| 459 | if (!recursive) |