MCPcopy Create free account
hub / github.com/catboost/catboost / MakeDirectoryRecursive

Method MakeDirectoryRecursive

util/system/fs.cpp:83–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

81}
82
83bool NFs::MakeDirectoryRecursive(const TString& path, EFilePermissions mode, bool alwaysCreate) {
84 if (NFs::Exists(path) && TFileStat(path).IsDir()) {
85 if (alwaysCreate) {
86 ythrow TIoException() << "path " << path << " already exists"
87 << " with cwd (" << NFs::CurrentWorkingDirectory() << ")";
88 }
89 return true;
90 } else {
91 // NOTE: recursion is finite due to existence of "." and "/"
92 if (!NFs::MakeDirectoryRecursive(TFsPath(path).Parent(), mode, false)) {
93 return false;
94 }
95
96 bool isDirMade = NFs::MakeDirectory(path, mode);
97 if (!isDirMade && alwaysCreate) {
98 ythrow TIoException() << "failed to create " << path << " with cwd (" << NFs::CurrentWorkingDirectory() << ")";
99 }
100
101 return TFileStat(path).IsDir();
102 }
103}
104
105bool NFs::Rename(const TString& oldPath, const TString& newPath) {
106#if defined(_win_)

Callers

nothing calls this directly

Calls 6

TFileStatClass · 0.85
MakeDirectoryRecursiveFunction · 0.85
MakeDirectoryFunction · 0.85
IsDirMethod · 0.80
ParentMethod · 0.80
TFsPathClass · 0.70

Tested by

no test coverage detected