Disk ARchive  2.4.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
path.hpp
Go to the documentation of this file.
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 "special_alloc.hpp"
00036 
00037 #define FAKE_ROOT path(string("<ROOT>"), true)
00038 
00039 namespace libdar
00040 {
00041 
00043 
00049 
00050     class path
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 
00080 
00082         std::string basename() const;
00083 
00085 
00087         void reset_read() { reading = dirs.begin(); };
00088 
00090 
00094         bool read_subdir(std::string & r);
00095 
00097         bool is_relative() const { return relative; };
00098 
00100         bool is_absolute() const { return !relative; };
00101 
00103         bool is_undisclosed() const { return undisclosed; };
00104 
00106 
00112         bool pop(std::string & arg);
00113 
00115 
00121         bool pop_front(std::string & arg);
00122 
00124 
00128         path operator + (const path & arg) const { path tmp = *this; tmp += arg; return tmp; };
00129 
00130 
00132 
00135         path & operator += (const path & arg);
00136 
00138 
00141         bool is_subdir_of(const path & p, bool case_sensit) const;
00142 
00144 
00146         std::string display() const;
00147 
00151         unsigned int degre() const { return dirs.size() + (relative ? 0 : 1); };
00152 
00154         void explode_undisclosed() const;
00155 
00156 #ifdef LIBDAR_SPECIAL_ALLOC
00157         USE_SPECIAL_ALLOC(path);
00158 #endif
00159     private :
00160         std::list<std::string>::iterator reading;
00161         std::list<std::string> dirs;
00162         bool relative;
00163         bool undisclosed;
00164 
00165         void reduce();
00166     };
00167 
00168 
00169 } // end of namespace
00170 
00171 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines