MCPcopy Create free account
hub / github.com/HO-COOH/FastCopy / copyFileAddSuffixImpl

Function copyFileAddSuffixImpl

FastCopy/Fallback.cpp:24–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers 1

CopyAddSuffixFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected