| 43 | } |
| 44 | |
| 45 | void NFs::RemoveRecursive(const TString& path) { |
| 46 | static const TStringBuf errStr = "error while removing "; |
| 47 | |
| 48 | if (!NFs::Exists(path)) { |
| 49 | return; |
| 50 | } |
| 51 | |
| 52 | if (!TFileStat(path).IsDir()) { |
| 53 | if (!NFs::Remove(path)) { |
| 54 | ythrow TSystemError() << errStr << path << " with cwd (" << NFs::CurrentWorkingDirectory() << ")"; |
| 55 | } |
| 56 | } |
| 57 | |
| 58 | TDirIterator dir(path); |
| 59 | |
| 60 | for (auto it = dir.begin(); it != dir.end(); ++it) { |
| 61 | switch (it->fts_info) { |
| 62 | case FTS_DOT: |
| 63 | case FTS_D: |
| 64 | break; |
| 65 | default: |
| 66 | if (!NFs::Remove(it->fts_path)) { |
| 67 | ythrow TSystemError() << errStr << it->fts_path << " with cwd (" << NFs::CurrentWorkingDirectory() << ")"; |
| 68 | } |
| 69 | break; |
| 70 | } |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | bool NFs::MakeDirectory(const TString& path, EFilePermissions mode) { |
| 75 | #if defined(_win_) |