MCPcopy Create free account
hub / github.com/Singular/Singular / ProgramPath

Function ProgramPath

ppcc/adlib/os.cc:434–456  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

432}
433
434Str *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
458bool MakeDir(const char *path, bool recursive) {
459 if (!recursive)

Callers 2

MainFunction · 0.85
TestOutputExecutableFunction · 0.85

Calls 11

FileStatFunction · 0.85
NormalizePathFunction · 0.85
AbsolutePathFunction · 0.85
GetEnvFunction · 0.85
AFunction · 0.85
starts_withMethod · 0.80
splitMethod · 0.80
lenMethod · 0.45
cloneMethod · 0.45
atMethod · 0.45
addMethod · 0.45

Tested by 2

MainFunction · 0.68
TestOutputExecutableFunction · 0.68