header_version.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00028
00029 #ifndef HEADER_VERSION_HPP
00030 #define HEADER_VERSION_HPP
00031
00032 #include "../my_config.h"
00033 #include "infinint.hpp"
00034 #include "generic_file.hpp"
00035 #include "tools.hpp"
00036
00037 namespace libdar
00038 {
00039 const int VERSION_FLAG_SAVED_EA_ROOT = 0x80;
00040 const int VERSION_FLAG_SAVED_EA_USER = 0x40;
00041 const int VERSION_FLAG_SCRAMBLED = 0x20;
00042 const int VERSION_SIZE = 3;
00043 typedef char dar_version[VERSION_SIZE];
00044 extern void version_copy(dar_version & dst, const dar_version & src);
00045 extern bool version_greater(const dar_version & left, const dar_version & right);
00046
00047
00048 struct header_version
00049 {
00050 dar_version edition;
00051 char algo_zip;
00052 std::string cmd_line;
00053 unsigned char flag;
00054
00055 void read(generic_file &f)
00056 {
00057 f.read(edition, sizeof(edition));
00058 f.read(&algo_zip, sizeof(algo_zip));
00059 tools_read_string(f, cmd_line);
00060 if(version_greater(edition, "01"))
00061 f.read((char *)&flag, (size_t)1);
00062 else
00063 flag = 0;
00064 };
00065 void write(generic_file &f)
00066 {
00067 f.write(edition, sizeof(edition));
00068 f.write(&algo_zip, sizeof(algo_zip));
00069 tools_write_string(f, cmd_line);
00070 f.write((char *)&flag, (size_t)1);
00071 };
00072 };
00073
00074 }
00075
00076 #endif