Such as the title, how to do it. And what is the difference between the usage of making a absolute path and making a relative path. Who can gave me a Sample code? PS:my environment is centos
            Asked
            
        
        
            Active
            
        
            Viewed 278 times
        
    -2
            
            
        - 
                    3http://stackoverflow.com/questions/10167382/boostfilesystem-get-relative-path – Jason B Jun 16 '15 at 02:22
 - 
                    What are you trying to do? What are your inputs? A relative path is just one that doesn't start with a `/` slash, e.g. `if (std::ifstream in("subdir/file.in"))`. Absolute paths do start with a `/`. What's your actual difficulty? Where's your code? – Tony Delroy Jun 16 '15 at 03:07
 
1 Answers
1
            You can use boost::filesystem::create_directory to create relative path or absolute path. My codes:
#include <boost/filesystem.hpp>
#include <string>
using namespace std;
int main()
{
    //create relative path
    const string reletive_path("./tmp");
    if(! boost::filesystem::exists(reletive_path))
        boost::filesystem::create_directory(reletive_path);
    //create absolute path
    const string abs_path("/tmp");
    if(! boost::filesystem::exists(abs_path))
        boost::filesystem::create_directory(abs_path);
    return 0;
 }
Whether creating a relative or a absolute depend on what param you give. For example, if you give /tmp, it will create a absolute, and ./tmp will create a relative. I hope this can help you.
        cwfighter
        
- 502
 - 1
 - 5
 - 20