Disk ARchive 2.4.2
|
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 // $Id: archive_version.hpp,v 1.3 2011/01/09 17:25:58 edrusb Rel $ 00022 // 00023 /*********************************************************************/ 00024 00028 00029 #ifndef ARCHIVE_VERSION_HPP 00030 #define ARCHIVE_VERSION_HPP 00031 00032 #include "../my_config.h" 00033 00034 #include <string> 00035 00036 #include "integers.hpp" 00037 #include "infinint.hpp" 00038 #include "generic_file.hpp" 00039 00040 namespace libdar 00041 { 00042 00045 00047 class archive_version 00048 { 00049 public: 00051 00057 archive_version(U_16 x = 0, unsigned char fix = 0); 00058 00059 bool operator < (const archive_version & ref) const { return value() < ref.value(); }; 00060 bool operator >= (const archive_version & ref) const { return value() >= ref.value(); }; 00061 bool operator == (const archive_version & ref) const { return value() == ref.value(); }; 00062 bool operator != (const archive_version & ref) const { return value() != ref.value(); }; 00063 bool operator > (const archive_version & ref) const { return value() > ref.value(); }; 00064 bool operator <= (const archive_version & ref) const { return value() <= ref.value(); }; 00065 00066 void dump(generic_file & f) const; 00067 void read(generic_file & f); 00068 std::string display() const; 00069 00070 bool is_droot() const { return droot; }; 00071 // the string read from file (read()) is "dro", which is the start of a catalogue 00072 // this may be the case with new versions where a header_version is placed where ought to be the catalogue 00073 // in this situation, we can know that this an old archive and must re-read the archive in the old way 00074 00075 private: 00076 U_16 version; 00077 unsigned char fix; 00078 bool droot; 00079 00080 U_I value() const { return (U_I)(version)*256 + fix; }; 00081 static unsigned char to_digit(unsigned char val); 00082 static unsigned char to_char(unsigned char val); 00083 }; 00084 00085 extern const archive_version empty_archive_version(); 00086 00088 00089 } // end of namespace 00090 00091 #endif