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);
const std::string & string() const
path absolute(const path &p)
bool operator==(const path &rhs) const ATTRIBUTE_PURE
static path cwd()
Return the current working directory.
const char * c_str() const
path parent_path() const
Return a path which is the parent directory.
bool exists(const path &p)
Declaration of vcsn::path.
path(const std::string &p)
Init object with path.
std::ostream & dump(std::ostream &ostr) const
Paths in filesystems, i.e., file names.
path operator/(const path &rhs) const
path filename() const
Also known as basename.
path_type components() const
std::list< std::string > path_type
bool is_absolute() const
Whether starts with /.
path & operator/=(const path &rhs)
value_type value_
Wrapped value.