How can I copy a directory using Boost Filesystem?
I have tried boost::filesystem::copy_directory() but that only creates the target directory and does not copy the contents.
How can I copy a directory using Boost Filesystem? I have tried boost::filesystem::copy_directory() but
Share
Usage:
copyDir(boost::filesystem::path("/home/nijansen/test"), boost::filesystem::path("/home/nijansen/test_copy"));(Unix)copyDir(boost::filesystem::path("C:\\Users\\nijansen\\test"), boost::filesystem::path("C:\\Users\\nijansen\\test2"));(Windows)As far as I see, the worst that can happen is that nothing happens, but I won’t promise anything! Use at your own risk.
Please note that the directory you’re copying to must not exist. If directories within the directory you are trying to copy can’t be read (think rights management), they will be skipped, but the other ones should still be copied.
Update
Refactored the function respective to the comments. Furthermore the function now returns a success result. It will return
falseif the requirements for the given directories or any directory within the source directory are not met, but not if a single file could not be copied.