| Disk ARchive 2.6.11 Full featured and portable backup and archiving tool

Public Member Functions | Private Member Functions | Private Attributes | List of all members
libdar::semaphore Class Reference
Private

class semaphore More...

`#include <semaphore.hpp>`

Inherits libdar::mem_ui.

## Public Member Functions
| semaphore (const std::shared_ptr< user_interaction > &dialog, const std::string &backup_hook_file_execute, const mask &backup_hook_file_mask)
| constructor More...
| semaphore (const semaphore &ref)
| copy constructor
| semaphore (semaphore &&ref) noexcept
| move constructor
semaphore & | operator= (const semaphore &ref)
| assignment operator
semaphore & | operator= (semaphore &&ref) noexcept
| move operator
| ~semaphore ()
| destructor
void | raise (const std::string &path, const cat_entree *object, bool data_to_save)
| to prepare a file for backup More...
void | lower ()
| to tell that the backup is completed for the last "raised" entry.
Public Member Functions inherited from libdar::mem_ui
| mem_ui (const std::shared_ptr< user_interaction > &dialog)
| constructor More...
| mem_ui (const mem_ui &ref)=default
| the copy constructor More...
| mem_ui (mem_ui &&ref) noexcept=default
| the move constructor
mem_ui & | operator= (const mem_ui &ref)=default
| assignement operator More...
mem_ui & | operator= (mem_ui &&ref) noexcept=default
| move operator
virtual | ~mem_ui () noexcept(false)
| destructor More...

## Private Member Functions
void | nullifyptr () noexcept
std::string | build_string (const std::string &context)
void | copy_from (const semaphore &ref)
void | move_from (semaphore &&ref) noexcept
void | detruit ()

## Private Attributes
infinint | count
| is the number of subdirectories currently saved in the last directory that matched the mask
std::string | chem
| path of the file that has to be call in the "end" context when count will drop to zero
std::string | filename
| filename of that same file
infinint | uid
| UID of that same file.
infinint | gid
| GID of that same file.
unsigned char | sig
| object type
std::string | execute
| command to execute
const mask * | match
| for which file to run the execute command

## Additional Inherited Members
Protected Member Functions inherited from libdar::mem_ui
user_interaction & | get_ui () const
| get access to the user_interaction object More...
std::shared_ptr< user_interaction > | get_pointer () const
| get access to the shared_ptr pointing to the user_interaction

## Detailed Description

class semaphore

Its action is to invoke the execute hook for each file that match the given mask Each file to backup has to be "raised()", which, if it matches the mask, leads to the execution of the execute hook with the proper substitution for that file in the "start" context. Then the backup can take place. When the backup is finished, the lower() method has to be called to trigger the execution of the hook with the proper substitution but in the "end" context. but, things are a bit complicated due to the handle of directories: If a directory is "raised()" and matches the mask, next calls to raise() do not trigger any hook execution even if the file match the mask, while saving into the directory that matched first. Instead, each new call to raise() increments an internal counter when a new directory is met, which is decremented when an "eod" is given to raised(). So it is important to feed raise() with any entry may it has to be saved or not. while lower() has only to be called when a file has been saved. This is only when this internal counters reaches zero, that the lower() call will trigger the execution for this first matched directory, of the hook in the "end" context.

So the expected use is to give each file to be saved (including eod) to the raise() method, before eventually saving the file, and call the lower() method only for files that had to be saved once the backup is completed, may it be normally or due to an exception being thrown.

Definition at line 63 of file semaphore.hpp.

## Constructor & Destructor Documentation

## ◆ semaphore()

libdar::semaphore::semaphore | ( | const std::shared_ptr< user_interaction > & | dialog,
|  | const std::string & | backup_hook_file_execute,
|  | const mask & | backup_hook_file_mask
| ) |  |

constructor

Parameters

  [in] | dialog | for user interaction
  [in] | backup_hook_file_execute | is the string to execute, it can contains macros to be substitued, f by filename, p by path, u by uid, g by gid, and c by the context, which is either "start" or "end".
  [in] | backup_hook_file_mask | defines the path+filename of entry that need to have the hook executed before and after their backup

## Member Function Documentation

## ◆ raise()

void libdar::semaphore::raise | ( | const std::string & | path,
|  | const cat_entree * | object,
|  | bool | data_to_save
| ) |  |

to prepare a file for backup

all file has to be given to this call, even the eod objects

Parameters

  [in] | path | is the full path to the object
  [in] | object | is the object about to be saved
  [in] | data_to_save | tells whether this entry will have to be saved or just recursed into (directory for example)

Note
  , if data_to_save is true, the lower() method is expected to be used before a next call to raise. For a directory this is only the call to lower() of the matching EOD that will trigger the hook execution in the "end" context. If instead data_to_save if false, no lower() call has to be done.

The documentation for this class was generated from the following file:

- semaphore.hpp