{
try {
std::filesystem::path fromPath = HUDFilePath.toStdString();
std::filesystem::path toPath = DownloadFilePath.toStdString();
std::filesystem::copy(fromPath, toPath, std::filesystem::copy_options::recursive);
return true;
} catch (const std::filesystem::filesystem_error& e) {
qDebug() << "Failed trying to copy files: " << e.what();
return false;
} catch (const std::exception& e) {
qDebug() << "Failed due to exception: " << e.what();
return false;
} catch (...) {
qDebug() << "Failed due to an unknown exception.";
return false;
}
}```
is this the correct way copy a directory (with subdirectories and subfiles) into another given path?
#The correct way to recursively copy a directory to another.
21 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
i should clarify HUDfilePath is the folder i want to copy and DownloadFilePath is the to path
I tried running and it gave me an error, but this function is embedded in other shite, so just wanting to make sure that this is the correct way to do this.
Error on compiling or at runtime?
runtime
i cant even send the function its nested into its too big lol
but i thought it would be easier to figure out atleast if this function works as it should
I am quite certain that you should set the copy options before doing the copy operation
how would one do that?
Swap the order the lines are in
std::filesystem::copy(std::filesystem::copy_options::recursive, fromPath, toPath,); like this?
sry if i dont really understand
Oh, sorry
My bad
This is what it looks like on my screen. I thought that they were seperate statements
haha
It should be fine as is 🙂