|
Boost Users : |
Subject: [Boost-users] [filesystem] remove_filename( ) - is this an error?
From: Robert Jones (robertgbjones_at_[hidden])
Date: 2010-04-26 09:53:04
Hi Guys
This bit of code...
#include <iostream>
#include <boost/filesystem.hpp>
int main( )
{
const char * bits[] = { "first", "second", "third", "fourth", 0 };
boost::filesystem::path path;
for ( const char * * bit = bits; * bit; ++ bit )
{
path /= * bit;
}
while ( path.has_parent_path( ) )
{
std::cout << path << std::endl;
path.remove_filename( );
}
}
produces
first/second/third/fourth
first/second/third/
first/second/third
first/second/
first/second
first/
which surprised me, as the documentation says
basic_path& remove_filename();
*Effects:* If has_parent_path() then remove the last *filename* from the
stored path. If that leaves the stored path with one or more trailing *slash
* elements not representing *root-directory*, remove them.
Seems to me that remove_filename() does NOT remove trailing slashes as
stated.
- Rob.
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