Disk ARchive  2.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
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 // $Id: path.hpp,v 1.18 2011/01/09 17:25:58 edrusb Rel $
22 //
23 /*********************************************************************/
24 
30 
31 #ifndef PATH_HPP
32 #define PATH_HPP
33 
34 #include "../my_config.h"
35 #include <list>
36 #include <string>
37 #include "erreurs.hpp"
38 
39 #define FAKE_ROOT path(string("<ROOT>"), true)
40 
41 namespace libdar
42 {
43 
45 
51 
52  class path
53  {
54  public :
56 
64  path(const std::string & s, bool x_undisclosed = false);
65 
67 
70  path(const char *s, bool x_undisclosed = false) { *this = path(std::string(s), x_undisclosed); };
71 
73  path(const path & ref);
74 
76  const path & operator = (const path & ref);
77 
79  bool operator == (const path & ref) const;
80 
82 
84  std::string basename() const;
85 
87 
89  void reset_read() { reading = dirs.begin(); };
90 
92 
96  bool read_subdir(std::string & r);
97 
99  bool is_relative() const { return relative; };
100 
102  bool is_absolute() const { return !relative; };
103 
105  bool is_undisclosed() const { return undisclosed; };
106 
108 
114  bool pop(std::string & arg);
115 
117 
123  bool pop_front(std::string & arg);
124 
126 
130  path operator + (const path & arg) const { path tmp = *this; tmp += arg; return tmp; };
131 
132 
134 
137  path & operator += (const path & arg);
138 
140 
143  bool is_subdir_of(const path & p, bool case_sensit) const;
144 
146 
148  std::string display() const;
149 
153  unsigned int degre() const { return dirs.size() + (relative ? 0 : 1); };
154 
156  void explode_undisclosed() const;
157 
158  private :
159  std::list<std::string>::iterator reading;
160  std::list<std::string> dirs;
161  bool relative;
162  bool undisclosed;
163 
164  void reduce();
165  };
166 
167 
168 } // end of namespace
169 
170 #endif