[英]Trouble understanding boost copy_file “File exists” error message
I am investigating an issue in my program where the following error message appears: 我正在调查程序中出现以下错误消息的问题:
boost::fs: boost::filesystem::copy_file: File exists: "path/to/file1", "path/to/file2" path1="path/to/file1" path2="path/to/file2"
I guess the issue is that some file already exists and that overwriting it is impossible, but I am not sure which file exactly. 我猜问题是某些文件已经存在,并且无法覆盖它,但是我不确定到底是哪个文件。
Is it file1
that can't be copied to path/to/file2
or the opposite? 是无法复制到
path/to/file2
file1
还是相反的文件? Or something else entirely? 还是完全其他?
The boost documentation Here says the following: 增强文档在这里说以下内容:
void copy_file(const path& from, const path& to);
void copy_file(const path& from, const path& to,
system::error_code& ec);
void copy_file(const path& from, const path& to,
copy_option option);
void copy_file(const path& from, const path& to,
copy_option option, system::error_code& ec);
Also, you can check if a file exists using: 另外,您可以使用以下方法检查文件是否存在:
if ( !boost::filesystem::exists( "myfile.txt" ) )
{
std::cout << "Can't find my file!" << std::endl;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.