| 22 | } |
| 23 | |
| 24 | static bool copyFileAddSuffixImpl(std::filesystem::path const& source, std::filesystem::path const& destination) |
| 25 | { |
| 26 | auto const fileName = source.filename().wstring(); |
| 27 | auto const fileNameWithoutExtension = source.stem().wstring(); |
| 28 | auto const extension = source.extension().wstring(); |
| 29 | std::error_code ec; |
| 30 | for(int suffix = 1;;++suffix) |
| 31 | { |
| 32 | auto fullPath = std::format(LR"({}\{}({}){})", destination.wstring(), fileNameWithoutExtension, suffix, extension); |
| 33 | if(!std::filesystem::exists(fullPath)) |
| 34 | { |
| 35 | std::filesystem::copy(source, fullPath); |
| 36 | return bool{ ec }; |
| 37 | } |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | void CopyAddSuffix(std::filesystem::path const& source, std::filesystem::path const& destination, bool isMove) |
| 42 | { |