The compiler doesn’t complain while building,and my program says it worked, and creates the folder, but the file hasn’t moved. What am I doing wrong?
#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;
}
I’m using Windows 7, CodeBlocks 10.05, G++ 4.4.1, and Boost 1.47
if(void)"C:\\fldr1" "rawr.txt" == "C:\\fldr1rawr.txt"also may produce undesired results.You could do something like the following instead: