11 #include <sys/types.h>
12 #include <sys/param.h>
15 #include <boost/tokenizer.hpp>
33 char res[MAXPATHLEN + 1];
35 if (!getcwd(res, MAXPATHLEN + 1))
36 throw std::runtime_error(
"working directory name too long");
73 using tokenizer = boost::tokenizer<boost::char_separator<char>>;
74 boost::char_separator<char> seps(
"/",
"", boost::keep_empty_tokens);
75 tokenizer dirs(
value_, seps);
78 for (
const std::string& s: dirs)
85 auto slash =
value_.rfind(
'/');
86 if (slash ==
value_.npos || slash == 0)
89 return {
value_.substr(0, slash - 1)};
94 auto slash =
value_.rfind(
'/');
95 return {
value_.substr(slash + 1)};
101 return 0 == stat (p.
c_str(), &buf);
bool is_absolute() const
Whether starts with /.
path operator/(const path &rhs) const
bool operator==(const path &rhs) const ATTRIBUTE_PURE
path & operator/=(const path &rhs)
const char * c_str() const
path parent_path() const
Return a path which is the parent directory.
path absolute(const path &p)
bool exists(const path &p)
path filename() const
Also known as basename.
Declaration of vcsn::path.
std::list< std::string > path_type
const std::string & string() const
path(const std::string &p)
Init object with path.
value_type value_
Wrapped value.
path_type components() const
static path cwd()
Return the current working directory.
std::ostream & dump(std::ostream &ostr) const
Paths in filesystems, i.e., file names.