| 191 | } |
| 192 | |
| 193 | std::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 | } |
no test coverage detected