|
Disk ARchive
2.4.12
|
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 00025 00026 #ifndef FICHIER_HPP 00027 #define FICHIER_HPP 00028 00029 00030 #include "../my_config.h" 00031 00032 extern "C" 00033 { 00034 #if HAVE_UNISTD_H 00035 #include <unistd.h> 00036 #endif 00037 } // end extern "C" 00038 00039 #include "integers.hpp" 00040 #include "thread_cancellation.hpp" 00041 #include "label.hpp" 00042 #include "crc.hpp" 00043 #include "user_interaction.hpp" 00044 #include "mem_ui.hpp" 00045 00046 #include <string> 00047 00048 namespace libdar 00049 { 00050 00053 00054 class fichier : public generic_file, public thread_cancellation 00055 { 00056 public : 00057 // constructors 00058 fichier(user_interaction & dialog, S_I fd); 00059 fichier(user_interaction & dialog, const char *name, gf_mode m, U_I mode, bool furtive_mode); 00060 fichier(user_interaction & dialog, const std::string & chemin, gf_mode m, U_I mode, bool furtive_mode); 00061 fichier(const std::string & chemin, bool furtive_mode = false); // builds a read-only object 00062 fichier(const fichier & ref) : generic_file(ref) { copy_from(ref); }; 00063 00064 // assignment operator 00065 const fichier & operator = (const fichier & ref) { detruit(); copy_from(ref); return *this; }; 00066 00067 // destructor 00068 ~fichier() { detruit(); }; 00069 00070 00072 virtual void change_ownership(const std::string & user, const std::string & group); 00073 00075 virtual void change_permission(U_I perm); 00076 00078 infinint get_size() const; 00079 00080 // inherited from generic_file 00081 bool skip(const infinint & pos); 00082 bool skip_to_eof(); 00083 bool skip_relative(S_I x); 00084 infinint get_position(); 00085 00086 #ifdef LIBDAR_SPECIAL_ALLOC 00087 USE_SPECIAL_ALLOC(fichier); 00088 #endif 00089 protected : 00090 U_I inherited_read(char *a, U_I size); 00091 void inherited_write(const char *a, U_I size); 00092 void inherited_sync_write() {}; 00093 void inherited_terminate() {}; 00094 00095 private : 00096 S_I filedesc; 00097 user_interaction *x_dialog; 00098 00099 void open(const char *name, gf_mode m, U_I perm, bool furtive_mode); 00100 void copy_from(const fichier & ref); 00101 void detruit() { close(filedesc); filedesc = -1; if(x_dialog != NULL) { delete x_dialog; x_dialog = NULL; } }; 00102 void init_dialog(user_interaction &dialog); 00103 }; 00104 00106 00107 } // end of namespace 00108 00109 #endif
1.7.6.1