| 81 | } |
| 82 | |
| 83 | bool 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 | |
| 105 | bool NFs::Rename(const TString& oldPath, const TString& newPath) { |
| 106 | #if defined(_win_) |
nothing calls this directly
no test coverage detected