![]() |
Disk ARchive
2.5.2
Full featured and portable backup and archiving tool
|
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 00027 00028 #ifndef PATH_HPP 00029 #define PATH_HPP 00030 00031 #include "../my_config.h" 00032 #include <list> 00033 #include <string> 00034 #include "erreurs.hpp" 00035 #include "on_pool.hpp" 00036 00037 #define FAKE_ROOT path(string("<ROOT>"), true) 00038 00039 namespace libdar 00040 { 00041 00043 00049 00050 class path : public on_pool 00051 { 00052 public : 00054 00062 path(const std::string & s, bool x_undisclosed = false); 00063 00065 00068 path(const char *s, bool x_undisclosed = false) { *this = path(std::string(s), x_undisclosed); }; 00069 00071 path(const path & ref); 00072 00074 const path & operator = (const path & ref); 00075 00077 bool operator == (const path & ref) const; 00078 bool operator != (const path & ref) const { return !(*this == ref); }; 00079 00081 00083 std::string basename() const; 00084 00086 00088 void reset_read() { reading = dirs.begin(); }; 00089 00091 00095 bool read_subdir(std::string & r); 00096 00098 bool is_relative() const { return relative; }; 00099 00101 bool is_absolute() const { return !relative; }; 00102 00104 bool is_undisclosed() const { return undisclosed; }; 00105 00107 00113 bool pop(std::string & arg); 00114 00116 00122 bool pop_front(std::string & arg); 00123 00125 00129 path operator + (const path & arg) const { path tmp = *this; tmp += arg; return tmp; }; 00130 00131 00133 00136 path & operator += (const path & arg); 00137 00139 00142 bool is_subdir_of(const path & p, bool case_sensit) const; 00143 00145 00147 std::string display() const; 00148 00152 unsigned int degre() const { return dirs.size() + (relative ? 0 : 1); }; 00153 00155 void explode_undisclosed() const; 00156 00157 private : 00158 std::list<std::string>::iterator reading; 00159 std::list<std::string> dirs; 00160 bool relative; 00161 bool undisclosed; 00162 00163 void reduce(); 00164 }; 00165 00166 00167 } // end of namespace 00168 00169 #endif