Disk ARchive  2.4.10
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
semaphore.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2052 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21 
25 
26 #ifndef SEMAPHORE_HPP
27 #define SEMAPHORE_HPP
28 
29 #include "../my_config.h"
30 
31 #include "mem_ui.hpp"
32 #include "mask.hpp"
33 #include "catalogue.hpp"
34 
35 namespace libdar
36 {
37 
40 
42 
63 
64 
65  class semaphore : public mem_ui
66  {
67  public:
68 
70 
77  semaphore(user_interaction & dialog,
78  const std::string & backup_hook_file_execute,
79  const mask & backup_hook_file_mask);
80 
82  semaphore(const semaphore & ref) : mem_ui(ref.get_ui()) { copy_from(ref); };
83 
85  semaphore & operator = (const semaphore & ref) { detruit(); copy_from(ref); return *this; };
86 
88  ~semaphore() { detruit(); };
89 
91 
100  void raise(const std::string & path,
101  const entree *object,
102  bool data_to_save);
103 
105  void lower();
106 
107 #ifdef LIBDAR_SPECIAL_ALLOC
108  USE_SPECIAL_ALLOC(semaphore);
109 #endif
110  private:
111  infinint count; //< is the number of subdirectories currently saved in the last directory that matched the mask
112  std::string chem; //< path of the file that has to be call in the "end" context when count will drop to zero
113  std::string filename; //< filename of that same file
114  infinint uid; //< UID of that same file
115  infinint gid; //< GID of that same file
116  std::string execute; //< command to execute
117  const mask *match; //< for which file to run the execute command
118 
119  std::string build_string(const std::string & context);
120  void copy_from(const semaphore & ref);
121  void detruit();
122  };
123 
125 
126 } // end of namespace
127 
128 #endif