MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / RecursiveCreateDir

Method RecursiveCreateDir

tensorflow/core/debug/debug_io_utils.cc:657–689  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

655}
656
657Status DebugFileIO::RecursiveCreateDir(Env* env, const string& dir) {
658 if (env->FileExists(dir).ok() && env->IsDirectory(dir).ok()) {
659 // The path already exists as a directory. Return OK right away.
660 return Status::OK();
661 }
662
663 string parent_dir(io::Dirname(dir));
664 if (!env->FileExists(parent_dir).ok()) {
665 // The parent path does not exist yet, create it first.
666 Status s = RecursiveCreateDir(env, parent_dir); // Recursive call
667 if (!s.ok()) {
668 return Status(
669 error::FAILED_PRECONDITION,
670 strings::StrCat("Failed to create directory ", parent_dir));
671 }
672 } else if (env->FileExists(parent_dir).ok() &&
673 !env->IsDirectory(parent_dir).ok()) {
674 // The path exists, but it is a file.
675 return Status(error::FAILED_PRECONDITION,
676 strings::StrCat("Failed to create directory ", parent_dir,
677 " because the path exists as a file "));
678 }
679
680 env->CreateDir(dir).IgnoreError();
681 // Guard against potential race in creating directories by doing a check
682 // after the CreateDir call.
683 if (env->FileExists(dir).ok() && env->IsDirectory(dir).ok()) {
684 return Status::OK();
685 } else {
686 return Status(error::ABORTED,
687 strings::StrCat("Failed to create directory ", parent_dir));
688 }
689}
690
691// Default total disk usage limit: 100 GBytes
692const uint64 DebugFileIO::kDefaultGlobalDiskBytesLimit = 107374182400L;

Callers

nothing calls this directly

Calls 8

DirnameFunction · 0.85
StatusClass · 0.50
StrCatFunction · 0.50
okMethod · 0.45
FileExistsMethod · 0.45
IsDirectoryMethod · 0.45
IgnoreErrorMethod · 0.45
CreateDirMethod · 0.45

Tested by

no test coverage detected