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 : dar.linux@free.fr 00020 /*********************************************************************/ 00021 // $Id$ 00022 // 00023 /*********************************************************************/ 00024 00025 #ifndef EA_HPP 00026 #define EA_HPP 00027 00028 #pragma interface 00029 00030 #include <vector> 00031 #include <string> 00032 #include "generic_file.hpp" 00033 #include "infinint.hpp" 00034 00035 enum ea_mode { ea_insert, ea_del }; // for use later 00036 // actually the whole EA list is stored/restored, but 00037 // it could be possible to check which EA have changed to save only thoses 00038 // and also record EA that have been removed. 00039 // the problem is the localisation of EA in the archive, 00040 // comparison implies retrieving each EA list, which could implies 00041 // reading the whole archive for EA lists. 00042 // other thing to consider, is the catalogue extraction, it must also contain 00043 // all EA lists. to be able to compare. 00044 // solution : store the EA lists after the data and before the catalogue. 00045 // to be seen. 00046 // 00047 enum ea_domain { ea_root, ea_user }; 00048 00049 struct ea_entry 00050 { 00051 ea_mode mode; 00052 enum ea_domain domain; 00053 string key, value; 00054 00055 ea_entry() { mode = ea_insert; domain = ea_user; key = value = ""; }; 00056 ea_entry(generic_file & f); 00057 00058 void dump(generic_file & f) const; 00059 }; 00060 00061 class ea_attributs 00062 { 00063 public: 00064 ea_attributs() { alire = attr.begin(); }; 00065 ea_attributs(generic_file & f); 00066 ea_attributs(const ea_attributs & ref); 00067 00068 void dump(generic_file & f) const; 00069 void add(const ea_entry &x) { attr.push_back(x); }; 00070 void reset_read() const; 00071 bool read(ea_entry & x) const; 00072 infinint size() const { return attr.size(); }; 00073 void clear() { attr.clear(); alire = attr.begin(); }; 00074 bool find(ea_domain dom, const string &key, ea_mode & found_mode, string & found_value) const; 00075 bool diff(const ea_attributs & other, bool check_ea_root, bool check_ea_user) const; 00076 00077 void check() const {}; // actually empty, but additional checks could be added 00078 00079 private: 00080 vector<ea_entry> attr; 00081 vector<ea_entry>::iterator alire; 00082 }; 00083 00084 #endif