Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

boost::filesystem adding quotation marks?

When using boost_filesystem, Boost keeps adding quotation marks to the filenames.

foo.cpp:

#include <iostream>
#include <boost/filesystem.hpp>

int main( int argc, char * argv[] )
{
    std::cout << argv[0] << std::endl;
    boost::filesystem::path p( argv[0] );
    std::cout << p << std::endl;
    std::cout << p.filename() << std::endl;
    return 0;
}

Compiled:

g++ foo.cpp -o foo -lboost_filesystem -lboost_system

Output:

./foo
"./foo"
"foo"

This is somewhat unexpected, and inconvenient in my case. Is this really intentional, or is my somewhat older version of Boost (1.46.1) buggy in this respect? Is there some way I could avoid them being added?

I perused the documentation, but aside from the tutorials not showing those quotation marks in their example output, I was not enlightened.

like image 515
DevSolar Avatar asked Mar 15 '13 07:03

DevSolar


1 Answers

This is actually a bug filed on the Boost framework on version 1.47.0.

The proposed workaround is:

std::cout << path("/foo/bar.txt").filename().string()
like image 92
fredrik Avatar answered Sep 26 '22 03:09

fredrik