|
Boost Users : |
Subject: [Boost-users] [Filesystem] There must be a better way to do path decomposition
From: Ramon F Herrera (ramon_at_[hidden])
Date: 2011-08-03 12:16:51
This code at least works:
string directory_path(argv[1]);
path p(directory_path);
ostringstream component;
string lastComponent;
for (path::iterator it = p.begin(); it != p.end(); it++) {
component.str(""); // Hack, to be replaced by better way
component << *it; // to grab `*it' in a string
lastComponent = component.str();
}
lastComponent = lastComponent.substr(1, lastComponent.size()-2);
According to the documentation examples, the item pointed to by `*it' is
of the following type:
path::iterator::value_type is path::string_type, and iteration treats
path as a container of filenames.
I tried to capture `*it' in a string and in a string_type but the
compiler does not like the '=' operator.
TIA,
-RFH
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