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: mask_list.hpp,v 1.1.2.3 2009/07/25 20:13:35 edrusb Rel $ 00022 // 00023 /*********************************************************************/ 00024 00030 00031 #ifndef MASK_LIST_HPP 00032 #define MASK_LIST_HPP 00033 00034 #include "../my_config.h" 00035 00036 #include "mask.hpp" 00037 00038 namespace libdar 00039 { 00040 00043 00045 00049 00050 class mask_list : public mask 00051 { 00052 public: 00053 00055 00063 mask_list(const std::string & filename_list_st, bool case_sensit, const path & prefix, bool include); 00064 00066 bool is_covered(const std::string & expression) const; 00068 mask *clone() const { return new mask_list(*this); }; 00069 00071 U_I size() const { return contenu.size(); }; 00072 00073 private: 00074 00075 // we need to change to lexicographical order relation ship for the '/' character be the most lower of all. This way 00076 // the first entry listed from a set a file sharing the same first characters will be the one corresponding 00077 // to the directory with this common prefix. 00078 00079 class my_char 00080 { 00081 public: 00082 my_char() { val = 0; }; 00083 my_char(const char x) : val(x) {}; 00084 bool operator < (const my_char & x) const 00085 { 00086 if(val == '/') 00087 if(x.val == '/') 00088 return false; 00089 else 00090 return true; 00091 else 00092 if(x.val == '/') 00093 return false; 00094 else 00095 return val < x.val; 00096 }; 00097 00098 operator char() const 00099 { 00100 return val; 00101 }; 00102 00103 private: 00104 char val; 00105 }; 00106 00107 std::vector <std::basic_string<my_char> > contenu; 00108 U_I taille; 00109 bool case_s; 00110 bool including; // mask is used for including files (not for excluding files) 00111 00112 std::list<std::basic_string<my_char> > convert_list_string_char(const std::list<std::string> & src) const; 00113 std::basic_string<my_char> convert_string_char(const std::string & src) const; 00114 std::string convert_string_my_char(const std::basic_string<my_char> & src) const; 00115 }; 00116 00118 00119 } // end of namespace 00120 00121 #endif