| Disk ARchive 2.5.10 Full featured and portable backup and archiving tool

- Main Page
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

path.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2052 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21
27
28 #ifndef PATH_HPP
29 #define PATH_HPP
30
31 #include "../my_config.h"
32 #include <list>
33 #include <string>
34 #include "erreurs.hpp"
35 #include "on_pool.hpp"
36
37 #define FAKE_ROOT path(string("<ROOT>"), true)
38
39 namespace libdar
40 {
41
43
49
50 class path : public on_pool
51 {
52 public :
54
62 path(const std::string & s, bool x_undisclosed = false);
63
65
68 path(const char *s, bool x_undisclosed = false) { *this = path(std::string(s), x_undisclosed); };
69
71 path(const path & ref);
72
74 const path & operator = (const path & ref);
75
77 bool operator == (const path & ref) const;
78 bool operator != (const path & ref) const { return !(*this == ref); };
79
81
83 std::string basename() const;
84
86
88 void reset_read() { reading = dirs.begin(); };
89
91
95 bool read_subdir(std::string & r);
96
98 bool is_relative() const { return relative; };
99
101 bool is_absolute() const { return !relative; };
102
104 bool is_undisclosed() const { return undisclosed; };
105
107
113 bool pop(std::string & arg);
114
116
122 bool pop_front(std::string & arg);
123
125
129 path operator + (const path & arg) const { path tmp = *this; tmp += arg; return tmp; };
130
131
133
136 path & operator += (const path & arg);
137
139
142 bool is_subdir_of(const path & p, bool case_sensit) const;
143
145
147 std::string display() const;
148
152 unsigned int degre() const { return dirs.size() + (relative ? 0 : 1); };
153
155 void explode_undisclosed() const;
156
157 private :
158 std::list<std::string>::iterator reading;
159 std::list<std::string> dirs;
160 bool relative;
161 bool undisclosed;
162
163 void reduce();
164 };
165
166
167 } // end of namespace
168
169 #endif
libdar::on_pool
Definition: on_pool.hpp:52
libdar::path::operator+
path operator+(const path &arg) const
add a path to the current path. The added path must be a relative path
Definition: path.hpp:129
libdar::path::is_absolute
bool is_absolute() const
whether the path is absolute or relative
Definition: path.hpp:101
libdar::path::is_undisclosed
bool is_undisclosed() const
whether the path has an undisclosed part at the beginning
Definition: path.hpp:104
libdar::path::pop
bool pop(std::string &arg)
remove and gives in argument the basename of the path
libdar::path::basename
std::string basename() const
get the basename of a path
libdar::path::reset_read
void reset_read()
reset the read_subdir operation
Definition: path.hpp:88
libdar::path::is_relative
bool is_relative() const
whether the path is relative or absolute (= start with a /)
Definition: path.hpp:98
libdar::path::path
path(const std::string &s, bool x_undisclosed=false)
constructor from a string
libdar::path::read_subdir
bool read_subdir(std::string &r)
sequentially read the elements that compose the path
libdar::path::explode_undisclosed
void explode_undisclosed() const
if the current object is an undisclosed path, tries to convert it back to normal path ...
libdar::path::is_subdir_of
bool is_subdir_of(const path &p, bool case_sensit) const
test whether the current object is a subdir of the method's argument
libdar::path::pop_front
bool pop_front(std::string &arg)
remove and gives in argument the outer most member of the path
libdar::path::operator==
bool operator==(const path &ref) const
comparison operator
erreurs.hpp
contains all the excetion class thrown by libdar
libdar::path::path
path(const char *s, bool x_undisclosed=false)
constructor from a char *
Definition: path.hpp:68
on_pool.hpp
this is the base class of object that can be allocated on a memory pool
libdar::path::display
std::string display() const
convert back a path to a string
libdar::path::operator+=
path & operator+=(const path &arg)
add a path to the current path. The added path must be a relative path
libdar::path::degre
unsigned int degre() const
returns the number of member in the path
Definition: path.hpp:152
libdar::path::operator=
const path & operator=(const path &ref)
assignment operator
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
libdar::path
the class path is here to manipulate paths in the Unix notation: using'/'
Definition: path.hpp:50