This commit is contained in:
Your Name
2025-04-25 21:12:07 +12:00
parent 63b9980a61
commit 65b6e2b193
5 changed files with 81 additions and 0 deletions

View File

@@ -4,6 +4,7 @@
#include <fstream>
#include <vector>
#include <algorithm>
#include <filesystem>
namespace dropshell {
void maketitle(const std::string& title) {
@@ -139,4 +140,22 @@ int str2int(const std::string &str)
}
}
void recursive_copy(const std::string & source, const std::string & destination) {
try {
if (std::filesystem::is_directory(source)) {
if (!std::filesystem::exists(destination)) {
std::filesystem::create_directory(destination);
}
for (const auto& entry : std::filesystem::directory_iterator(source)) {
recursive_copy(entry.path(), destination / entry.path().filename());
}
} else if (std::filesystem::is_regular_file(source)) {
std::filesystem::copy(source, destination, std::filesystem::copy_options::overwrite_existing);
}
} catch (const std::filesystem::filesystem_error& ex) {
std::cerr << "Error copying " << source << " to " << destination << ": " << ex.what() << std::endl;
}
}
} // namespace dropshell

View File

@@ -24,4 +24,6 @@ std::vector<std::string> string2multi(std::string values);
int str2int(const std::string & str);
void recursive_copy(const std::string & source, const std::string & destination);
} // namespace dropshell