Yay
This commit is contained in:
@@ -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
|
@@ -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
|
Reference in New Issue
Block a user