Disk ARchive
2.4.5
|
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$ 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 #include "special_alloc.hpp" 00039 00040 #define FAKE_ROOT path(string("<ROOT>"), true) 00041 00042 namespace libdar 00043 { 00044 00046 00052 00053 class path 00054 { 00055 public : 00057 00065 path(const std::string & s, bool x_undisclosed = false); 00066 00068 00071 path(const char *s, bool x_undisclosed = false) { *this = path(std::string(s), x_undisclosed); }; 00072 00074 path(const path & ref); 00075 00077 const path & operator = (const path & ref); 00078 00080 bool operator == (const path & ref) const; 00081 00083 00085 std::string basename() const; 00086 00088 00090 void reset_read() { reading = dirs.begin(); }; 00091 00093 00097 bool read_subdir(std::string & r); 00098 00100 bool is_relative() const { return relative; }; 00101 00103 bool is_absolute() const { return !relative; }; 00104 00106 bool is_undisclosed() const { return undisclosed; }; 00107 00109 00115 bool pop(std::string & arg); 00116 00118 00124 bool pop_front(std::string & arg); 00125 00127 00131 path operator + (const path & arg) const { path tmp = *this; tmp += arg; return tmp; }; 00132 00133 00135 00138 path & operator += (const path & arg); 00139 00141 00144 bool is_subdir_of(const path & p, bool case_sensit) const; 00145 00147 00149 std::string display() const; 00150 00154 unsigned int degre() const { return dirs.size() + (relative ? 0 : 1); }; 00155 00157 void explode_undisclosed() const; 00158 00159 #ifdef LIBDAR_SPECIAL_ALLOC 00160 USE_SPECIAL_ALLOC(path); 00161 #endif 00162 private : 00163 std::list<std::string>::iterator reading; 00164 std::list<std::string> dirs; 00165 bool relative; 00166 bool undisclosed; 00167 00168 void reduce(); 00169 }; 00170 00171 00172 } // end of namespace 00173 00174 #endif