3 This file is part of libmspfs
4 Copyright © 2006-2008 Mikko Rasa, Mikkosoft Productions
5 Distributed under the LGPL
27 Stores a filesystem path. Paths are always stored in a normalized form; there
28 are never any "." or ".." components in the middle of the path, and relative
29 paths always begin with a single "." component or a sequence ".." components.
40 std::string::size_type start,end;
42 Iterator(const Path &);
44 Iterator &operator++();
45 Iterator &operator--();
46 std::string operator*() const;
47 bool operator==(const Iterator &i) const { return (start==i.start && end==i.end); }
48 bool operator!=(const Iterator &i) const { return !(*this==i); }
56 Path(const std::string &);
59 const std::string &str() const { return path; }
61 /// Returns the number of components in the path.
62 unsigned size() const;
64 bool empty() const { return path.empty(); }
66 /// Determines whether the path starts from the root directory
67 bool is_absolute() const;
69 /// Extracts a range of components from the path.
70 Path subpath(unsigned start, unsigned count = static_cast<unsigned>(-1)) const;
72 /// Concatenates this path with another one, with usual filesystem semantics
73 Path operator/(const Path &p) const;
74 Path &operator/=(const Path &);
77 Extracts a single component from the path. Negative indices count from the
80 std::string operator[](int) const;
82 bool operator==(const Path &) const;
83 Iterator begin() const;
86 void init(const std::string &);
87 void add_component(const std::string &);
90 inline std::ostream &operator<<(std::ostream &o, const Path &p) { o<<p.str(); return o; }