| 468 | } |
| 469 | |
| 470 | void TFsPath::CopyTo(const TString& newPath, bool force) const { |
| 471 | if (IsDirectory()) { |
| 472 | if (force) { |
| 473 | TFsPath(newPath).MkDirs(); |
| 474 | } else if (!TFsPath(newPath).IsDirectory()) { |
| 475 | ythrow TIoException() << "Target path is not a directory " << newPath; |
| 476 | } |
| 477 | TVector<TFsPath> children; |
| 478 | List(children); |
| 479 | for (auto&& i : children) { |
| 480 | i.CopyTo(newPath + "/" + i.GetName(), force); |
| 481 | } |
| 482 | } else { |
| 483 | if (force) { |
| 484 | TFsPath(newPath).Parent().MkDirs(); |
| 485 | } else { |
| 486 | if (!TFsPath(newPath).Parent().IsDirectory()) { |
| 487 | ythrow TIoException() << "Parent (" << TFsPath(newPath).Parent() << ") of a target path is not a directory " << newPath; |
| 488 | } |
| 489 | if (TFsPath(newPath).Exists()) { |
| 490 | ythrow TIoException() << "Path already exists " << newPath; |
| 491 | } |
| 492 | } |
| 493 | NFs::Copy(Path_, newPath); |
| 494 | } |
| 495 | } |
| 496 | |
| 497 | void TFsPath::ForceRenameTo(const TString& newPath) const { |
| 498 | try { |
nothing calls this directly
no test coverage detected