Opened 11 years ago

Last modified 11 years ago

#5702 new Bugs

Filename is returned within quotes instead without

Reported by: moritz@… Owned by: Beman Dawes
Milestone: To Be Determined Component: filesystem
Version: Boost 1.47.0 Severity: Problem
Keywords: Cc:

Description

In the reference (http://www.boost.org/doc/libs/1_47_0/libs/filesystem/v3/doc/reference.html#path-decomposition) it is said that for example the filename returned by filename() will be without the quotes:

std::cout << path("/foo/bar.txt").filename(); // outputs "bar.txt" (without the quotes)

But actually I'm getting an output with the filename enclosed in quotes like:

"bar.txt"

I'm using Windows Vista.

Change History (1)

comment:1 by moritz@…, 11 years ago

If found the origin of the bug: Since filename() returns an object of type "path" and the inserter and the extractor of the path object delimit the string with double-quotes (see http://www.boost.org/doc/libs/1_47_0/libs/filesystem/v3/doc/reference.html#path-inserter-extractor) the filename is returned in quotes.

To avoid this you can use

std::cout << path("/foo/bar.txt").filename().string(); // outputs "bar.txt" without the quotes

Although I don't understand why filename() returns a path object instead of a normal string() it would be the easiest to change only the description in the reference and leave the code as is.

Note: See TracTickets for help on using tickets.