![]() |
Disk ARchive
2.5.2
Full featured and portable backup and archiving tool
|
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 00030 00031 #ifndef GENERIC_TO_GLOBAL_FILE_HPP 00032 #define GENERIC_TO_GLOBAL_FILE_HPP 00033 00034 #include "fichier_global.hpp" 00035 #include "memory_file.hpp" 00036 #include "storage.hpp" 00037 00038 namespace libdar 00039 { 00040 00043 00044 class generic_to_global_file : public fichier_global 00045 { 00046 public: 00047 00053 generic_to_global_file(user_interaction & dialog, generic_file *d, gf_mode mode): fichier_global(dialog, mode) { if(d == nullptr) throw SRC_BUG; if(d->get_mode() != gf_read_write && d->get_mode() != mode) throw SRC_BUG; data = d; }; 00054 00055 // virtual method inherited from generic_file 00056 bool skippable(skippability direction, const infinint & amount) { return data->skippable(direction, amount); } 00057 bool skip(const infinint & pos) { return data->skip(pos); }; 00058 bool skip_to_eof() { return data->skip_to_eof(); }; 00059 bool skip_relative(S_I x) { return data->skip_relative(x); }; 00060 infinint get_position() const { return data->get_position(); }; 00061 00062 00063 // virtual method inherited from fichier_global 00064 void change_ownership(const std::string & user, const std::string & group) {}; 00065 void change_permission(U_I perm) {}; 00066 infinint get_size() const { return data->get_position(); }; //< yes, this is the drawback of this template class convertion, get_size() does not return the real size of the object 00067 void fadvise(advise adv) const {}; 00068 00069 00070 protected: 00071 00072 // virtual method inherited from generic_file 00073 void inherited_read_ahead(const infinint & amount) {}; // no optimization can be done here, we rely on the OS here 00074 void inherited_sync_write() {}; 00075 void inherited_flush_read() {}; 00076 void inherited_terminate() {}; 00077 00078 // inherited from fichier_global 00079 U_I fichier_global_inherited_write(const char *a, U_I size) { data->write(a, size); return size; }; 00080 bool fichier_global_inherited_read(char *a, U_I size, U_I & read, std::string & message) { read = data->read(a, size); message = "THIS IS A BUG IN GENERIC_TO_GLOBAL_FILE, PLEASE REPORT TO THE MAINTAINER!"; return true; }; 00081 00082 private: 00083 generic_file *data; 00084 }; 00085 00087 00088 } // end of namespace 00089 00090 #endif