Disk ARchive
2.3.11
|
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 : dar.linux@free.fr 00020 /*********************************************************************/ 00021 // $Id: path.hpp,v 1.9.2.1 2007/06/21 20:47:12 edrusb Rel $ 00022 // 00023 /*********************************************************************/ 00024 00029 00030 #ifndef PATH_HPP 00031 #define PATH_HPP 00032 00033 #include "../my_config.h" 00034 #include <list> 00035 #include <string> 00036 #include "erreurs.hpp" 00037 00038 #define FAKE_ROOT path(string("<ROOT>")) 00039 00040 namespace libdar 00041 { 00042 00044 00047 00048 class path 00049 { 00050 public : 00052 00055 path(const std::string & s); 00056 00058 00061 path(const char *s) { *this = path(std::string(s)); }; 00062 00064 path(const path & ref); 00065 00067 path & operator = (const path & ref); 00068 00070 bool operator == (const path & ref) const; 00071 00073 00075 std::string basename() const; 00076 00078 00080 void reset_read() { reading = dirs.begin(); }; 00081 00083 00087 bool read_subdir(std::string & r); 00088 00090 bool is_relative() const { return relative; }; 00091 00093 00099 bool pop(std::string & arg); 00100 00102 00108 bool pop_front(std::string & arg); 00109 00111 00115 path operator + (const path & arg) const { path tmp = *this; tmp += arg; return tmp; }; 00116 00117 00119 00122 path & operator += (const path & arg); 00123 00125 00128 bool is_subdir_of(const path & p, bool case_sensit) const; 00129 00131 00133 std::string display() const; 00134 00138 unsigned int degre() const { return dirs.size() + (relative ? 0 : 1); }; 00139 00140 private : 00141 std::list<std::string>::iterator reading; 00142 std::list<std::string> dirs; 00143 bool relative; 00144 00145 void reduce(); 00146 }; 00147 00148 00149 } // end of namespace 00150 00151 #endif