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

Function MakeDirRec

ppcc/adlib/os.cc:365–389  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

363
364
365static 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
391Str *AbsolutePath(Str *path) {
392 if (path->starts_with(PathSeparator)) {

Callers 1

MakeDirFunction · 0.85

Calls 6

FileStatFunction · 0.85
c_strMethod · 0.80
cloneMethod · 0.45
lenMethod · 0.45
findMethod · 0.45
atMethod · 0.45

Tested by

no test coverage detected