Disk ARchive  2.4.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines
semaphore.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 
00025 
00026 #ifndef SEMAPHORE_HPP
00027 #define SEMAPHORE_HPP
00028 
00029 #include "../my_config.h"
00030 
00031 #include "mem_ui.hpp"
00032 #include "mask.hpp"
00033 #include "catalogue.hpp"
00034 
00035 namespace libdar
00036 {
00037 
00040 
00042 
00063 
00064 
00065     class semaphore : public mem_ui
00066     {
00067     public:
00068 
00070 
00077         semaphore(user_interaction & dialog,
00078                   const std::string & backup_hook_file_execute,
00079                   const mask & backup_hook_file_mask);
00080 
00082         semaphore(const semaphore & ref) : mem_ui(ref.get_ui()) { copy_from(ref); };
00083 
00085         semaphore & operator = (const semaphore & ref) { detruit(); copy_from(ref); return *this; };
00086 
00088         ~semaphore() { detruit(); };
00089 
00091 
00100         void raise(const std::string & path,
00101                    const entree *object,
00102                    bool data_to_save);
00103 
00105         void lower();
00106 
00107 #ifdef LIBDAR_SPECIAL_ALLOC
00108         USE_SPECIAL_ALLOC(semaphore);
00109 #endif
00110     private:
00111         infinint count;       //< is the number of subdirectories currently saved in the last directory that matched the mask
00112         std::string chem;     //< path of the file that has to be call in the "end" context when count will drop to zero
00113         std::string filename; //< filename of that same file
00114         infinint uid;         //< UID of that same file
00115         infinint gid;         //< GID of that same file
00116         std::string execute;  //< command to execute
00117         const mask *match;    //< for which file to run the execute command
00118 
00119         std::string build_string(const std::string & context);
00120         void copy_from(const semaphore & ref);
00121         void detruit();
00122     };
00123 
00125 
00126 } // end of namespace
00127 
00128 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines