I’m trying to write something that moves files across volumes on all platforms. Currently, I use the rename(…) function to move the files, and this works, even across volumes/drives on Windows. However, on Linux, I get an EXDEV error (via strace), killing my app 🙁
It appears that I may need to call ‘mv’ via system(…) but this seems very hacky. That, or integrate boost into my app, which is not a trivial operation.
Are there any other options available to me?
Thank you for your time.
If you want to write something that is required to be cross-platform and not rely on system-specific implementations – you must stick to the standard. While newer the C++11 standard may allow additional features to help you with that, a trivial solution would be to just implement a plain copy from one
fstreamto another.