#The correct way to recursively copy a directory to another.

21 messages · Page 1 of 1 (latest)

atomic burrow
#
{
    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?
maiden heathBOT
#

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.

atomic burrow
#

i should clarify HUDfilePath is the folder i want to copy and DownloadFilePath is the to path

atomic burrow
#

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.

white raptor
#

Error on compiling or at runtime?

atomic burrow
#

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

white raptor
#

I am quite certain that you should set the copy options before doing the copy operation

atomic burrow
#

how would one do that?

white raptor
#

Swap the order the lines are in

atomic burrow
#

std::filesystem::copy(std::filesystem::copy_options::recursive, fromPath, toPath,); like this?

#

sry if i dont really understand

white raptor
#

Oh, sorry

#

My bad

#

This is what it looks like on my screen. I thought that they were seperate statements

atomic burrow
#

haha

white raptor
#

It should be fine as is 🙂

atomic burrow
#

okay cool ty

#

!solved