Disk ARchive
2.4.2
|
00001 /*********************************************************************/ 00002 // dar - disk archive - a backup/restoration program 00003 // Copyright (C) 2002-2052 Denis Corbin 00004 // 00005 // This program is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU General Public License 00007 // as published by the Free Software Foundation; either version 2 00008 // of the License, or (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 // 00019 // to contact the author : http://dar.linux.free.fr/email.html 00020 /*********************************************************************/ 00021 // $Id: path.hpp,v 1.18 2011/01/09 17:25:58 edrusb Rel $ 00022 // 00023 /*********************************************************************/ 00024 00030 00031 #ifndef PATH_HPP 00032 #define PATH_HPP 00033 00034 #include "../my_config.h" 00035 #include <list> 00036 #include <string> 00037 #include "erreurs.hpp" 00038 00039 #define FAKE_ROOT path(string("<ROOT>"), true) 00040 00041 namespace libdar 00042 { 00043 00045 00051 00052 class path 00053 { 00054 public : 00056 00064 path(const std::string & s, bool x_undisclosed = false); 00065 00067 00070 path(const char *s, bool x_undisclosed = false) { *this = path(std::string(s), x_undisclosed); }; 00071 00073 path(const path & ref); 00074 00076 const path & operator = (const path & ref); 00077 00079 bool operator == (const path & ref) const; 00080 00082 00084 std::string basename() const; 00085 00087 00089 void reset_read() { reading = dirs.begin(); }; 00090 00092 00096 bool read_subdir(std::string & r); 00097 00099 bool is_relative() const { return relative; }; 00100 00102 bool is_absolute() const { return !relative; }; 00103 00105 bool is_undisclosed() const { return undisclosed; }; 00106 00108 00114 bool pop(std::string & arg); 00115 00117 00123 bool pop_front(std::string & arg); 00124 00126 00130 path operator + (const path & arg) const { path tmp = *this; tmp += arg; return tmp; }; 00131 00132 00134 00137 path & operator += (const path & arg); 00138 00140 00143 bool is_subdir_of(const path & p, bool case_sensit) const; 00144 00146 00148 std::string display() const; 00149 00153 unsigned int degre() const { return dirs.size() + (relative ? 0 : 1); }; 00154 00156 void explode_undisclosed() const; 00157 00158 private : 00159 std::list<std::string>::iterator reading; 00160 std::list<std::string> dirs; 00161 bool relative; 00162 bool undisclosed; 00163 00164 void reduce(); 00165 }; 00166 00167 00168 } // end of namespace 00169 00170 #endif