Boost logo

Boost Users :

Subject: [Boost-users] boost::filesystem create directory fail
From: albert (albert_200200_at_[hidden])
Date: 2013-03-05 20:25:52


I use the code below to create directories, but it fails. What is the
correct way to do it? Thanks in advance.
  try
     {
         string logdirname("./notexistdir/logdir/");
         boost::filesystem::path logdir(logdirname.c_str());
         boost::filesystem::file_status s =
boost::filesystem::status(logdir);
         if( !boost::filesystem::is_directory(s) )
         {
             cout<< "not a directory, mkdir" <<endl;
             if(boost::filesystem::create_directory(logdir))
             {
                 cout<<"directory create ok" <<endl;
             }
             else
             {
                 cout<<"directory create fail" <<endl;
             }
         }
         else
         {
             cout<<"is a directory" <<endl;
         }
     }
     catch(exception& ex)
     {
         cout<< "exception caught[" << ex.what() <<"]" <<endl;
     }



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net