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