Disk ARchive
2.4.10
|
class semaphore More...
#include <semaphore.hpp>
Inherits libdar::mem_ui.
Public Member Functions | |
semaphore (user_interaction &dialog, const std::string &backup_hook_file_execute, const mask &backup_hook_file_mask) | |
constructor | |
semaphore (const semaphore &ref) | |
copy constructor | |
semaphore & | operator= (const semaphore &ref) |
assignment operator | |
~semaphore () | |
destructor | |
void | raise (const std::string &path, const entree *object, bool data_to_save) |
to prepare a file for backup | |
void | lower () |
to tell that the backup is completed for the last "raised" entry. | |
![]() | |
mem_ui (user_interaction &dialog) | |
constructor | |
mem_ui (const mem_ui &ref) | |
the copy constructor | |
virtual | ~mem_ui () |
destructor | |
const mem_ui & | operator= (const mem_ui &ref) |
assignement operator | |
user_interaction & | get_ui () const |
get access to the user_interaction cloned object | |
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 65 of file semaphore.hpp.
libdar::semaphore::semaphore | ( | user_interaction & | dialog, |
const std::string & | backup_hook_file_execute, | ||
const mask & | backup_hook_file_mask | ||
) |
constructor
[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 |
void libdar::semaphore::raise | ( | const std::string & | path, |
const 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
[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) |