MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / sdl_safe_copy_file

Function sdl_safe_copy_file

include/Helpers/StringHelpers.cpp:193–204  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191}
192
193std::filesystem::path sdl_safe_copy_file(const std::filesystem::path& toPath, const std::filesystem::path& fileToCopy, const std::string& fileName, const std::string& fileExtension) {
194 std::vector<std::string> toFolderListNames;
195 try {
196 toFolderListNames = glob_path_as_string_list(toPath, "*", 0, [&](const auto& p){ return p.stem().string();});
197 } catch(...) {
198 SDL_CreateDirectory(toPath.string().c_str());
199 }
200 std::string newFileName = ensure_string_unique(toFolderListNames, std::filesystem::path(fileName).stem().string());
201 std::filesystem::path newPath = toPath / (newFileName + "." + fileExtension);
202 SDL_CopyFile(fileToCopy.string().c_str(), newPath.string().c_str());
203 return newPath;
204}

Calls 4

glob_path_as_string_listFunction · 0.85
ensure_string_uniqueFunction · 0.85
c_strMethod · 0.80
stringMethod · 0.45

Tested by

no test coverage detected