编译器在构建时没有抱怨,而且我的程序说它工作并创建文件夹,但文件没有移动。我究竟做错了什么?Boost rename()函数不起作用
#include <iostream>
#include <boost/filesystem.hpp>
using namespace std;
using namespace boost::filesystem;
char c = 'c';
bool move(){
if ((bool) rename("C:\\fldr1" "rawr.txt", "C:\\fldr2" "rared.txt") == (true)){
return true;
}
else{
return false;
}
}
int main(int argc, char argv[])
{
if (argv[1] = (c))
{
if (is_directory("C:\\fldr2")){
if (move){
cout << "Done 1!" << endl;
}
}
else{
cout << "Dir doesn't exist!" << endl;
if ((bool)create_directory("C:\\fldr2") == (true)){
if (move){
cout << "Done 2!" << endl;
}
}
}
}
return 0;
}
我使用Windows 7,代码块10.05,G ++ 4.4.1,和Boost 1.47
你居然铸造'void'返回功能,以'bool'“返回值”,并检查他们?这是否编译? –
@larsmans它编译,但函数没有正确调用或什么 – RunningDroid
你明白,你不会得到一个有意义的价值,你呢? –