【发布时间】:2015-07-14 11:03:27
【问题描述】:
如果文件未打开,如何使用 boost 检查文件是否已打开,然后删除该文件,否则什么也不做
boost::filesystem::wpath file("c://test.txt");
if(boost::filesystem::exists(file))
{
if(here i want a check that file is already open or not, if open then run else)
{
boost::filesystem::remove(file);
}
else
{
}
}
【问题讨论】:
-
您将如何处理在检查和尝试删除文件之间打开文件的情况?
-
如果它打开了,我不想删除它。
-
这就是为什么我放评论,我想实现一些代码,如果文件被打开而不是删除它。
-
@ArslanAhmed IInspectable 的观点是:如果文件在您检查时未打开怎么办(所以您要删除它),但它是 i> 在您尝试删除它时打开?
-
@MikeKinghan 感谢您指出这一点
标签: c++ boost boost-filesystem