Boost :: filesystem add quotes?

When using boost_filesystem, Boost continues to add quotation marks to file names.

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 by:

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

Conclusion:

./foo
"./foo"
"foo"

This is somewhat unexpected and inconvenient in my case. Is this really intentional, or is it a slightly older version of the Boost (1.46.1) buggy in this regard? Is there any way to avoid adding them?

I looked through the documentation, but, apart from textbooks not showing these quotes in their output example, I was not enlightened.

+5
source share
2 answers

Actually, this is a bug filed for the Boost framework version 1.47.0.

Suggested workaround:

std::cout << path("/foo/bar.txt").filename().string()
+6
source

, . , , , :

boost::replace_all(yourquotedstring, "\"", "");

, , - :

std::cout << path("/foo/bar.txt").filename().string(); 
+4

All Articles