如何执行的boost ::文件系统COPY_FILE与覆盖 [英] how to perform boost::filesystem copy_file with overwrite
问题描述
Windows API函数 CopyFile
有一个参数 BOOL bFailIfExists
,允许你控制你是否不愿如果存在覆盖目标文件。
The Windows API function CopyFile
has an argument BOOL bFailIfExists
that allows you to control whether or not you want to overwrite the target file if it exists.
的的boost ::文件系统
COPY_FILE
函数没有这样的说法,如果目标文件存在将失败。有没有办法使用升压COPY_FILE功能和覆盖目标文件,一个优雅的方式?还是更简单地使用Windows API?我目前的目标平台是Windows,但我preFER使用STL和提高尽可能让我的code平台无关。
The boost::filesystem
copy_file
function has no such argument, and will fail if the target file exists. Is there an elegant way to use the boost copy_file function and overwrite the target file? Or is it better to simply use the Windows API? My current target platform is Windows, but I prefer to use STL and boost where possible to keep my code platform independent.
感谢您。
推荐答案
还有第三个枚举参数COPY_FILE,的boost ::文件系统:: copy_option :: overwrite_if_exists
There's a third enum argument to copy_file, boost::filesystem::copy_option::overwrite_if_exists
copy_file(source_path,destination_path,copy_option::overwrite_if_exists);
这篇关于如何执行的boost ::文件系统COPY_FILE与覆盖的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!