Disk ARchive
2.4.12
|
a set of tool routine More...
Files | |
file | deci.hpp |
manages the decimal representation of infinint | |
file | tools.hpp |
a set of general purpose routines | |
Functions | |
std::ostream & | libdar::operator<< (std::ostream &ref, const infinint &arg) |
specific << operator to use infinint in std::ostream More... | |
void | libdar::tools_init () |
libdar internal use only: it is launched from get_version() and initializes tools internal variables | |
void | libdar::tools_end () |
libdar internal use only: it is launched from close_and_clean() and releases tools internal variables | |
char * | libdar::tools_str2charptr (const std::string &x) |
convert a string to a char * More... | |
void | libdar::tools_write_string (generic_file &f, const std::string &s) |
write a string to a file with a '\0' at then end More... | |
void | libdar::tools_read_string (generic_file &f, std::string &s) |
read a string from a file expecting it to terminate by '\0' More... | |
void | libdar::tools_write_string_all (generic_file &f, const std::string &s) |
write a string to a file, '\0' has no special meaning nor is added at the end More... | |
void | libdar::tools_read_string_size (generic_file &f, std::string &s, infinint taille) |
read a string if given size from a file '\0' has no special meaning More... | |
infinint | libdar::tools_get_filesize (const path &p) |
retrieve the size in byte of a file More... | |
infinint | libdar::tools_get_extended_size (std::string s, U_I base) |
convert the given string to infinint taking care of multiplication suffixes like k, M, T, etc. More... | |
void | libdar::tools_extract_basename (const char *command_name, std::string &basename) |
extracts the basename of a file (removing path part) More... | |
std::string::iterator | libdar::tools_find_last_char_of (std::string &s, unsigned char v) |
give a pointer to the last character of the given value in the given string More... | |
std::string::iterator | libdar::tools_find_first_char_of (std::string &s, unsigned char v) |
give a pointer to the last character of the given value in the given string More... | |
void | libdar::tools_split_path_basename (const char *all, path *&chemin, std::string &base) |
split a given full path in path part and basename part More... | |
void | libdar::tools_split_path_basename (const std::string &all, std::string &chemin, std::string &base) |
split a given full path in path part and basename part More... | |
void | libdar::tools_open_pipes (user_interaction &dialog, const std::string &input, const std::string &output, tuyau *&in, tuyau *&out) |
open a pair of tuyau objects encapsulating two named pipes. More... | |
void | libdar::tools_blocking_read (int fd, bool mode) |
set blocking/not blocking mode for reading on a file descriptor More... | |
std::string | libdar::tools_name_of_uid (const infinint &uid) |
convert uid to name in regards to the current system's configuration More... | |
std::string | libdar::tools_name_of_gid (const infinint &gid) |
convert gid to name in regards of the current system's configuration More... | |
std::string | libdar::tools_uword2str (U_16 x) |
convert unsigned word to string More... | |
std::string | libdar::tools_int2str (S_I x) |
convert integer to string More... | |
U_I | libdar::tools_str2int (const std::string &x) |
convert an integer written in decimal notation to the corresponding value More... | |
S_I | libdar::tools_str2signed_int (const std::string &x) |
convert a signed integer written in decimal notation to the corresponding value More... | |
bool | libdar::tools_my_atoi (const char *a, U_I &val) |
ascii to integer conversion More... | |
std::string | libdar::tools_addspacebefore (std::string s, U_I expected_size) |
prepend spaces before the given string More... | |
std::string | libdar::tools_display_date (infinint date) |
convert a date in second to its human readable representation More... | |
infinint | libdar::tools_convert_date (const std::string &repres) |
convert a human readable date representation in number of second since the system reference date More... | |
void | libdar::tools_system (user_interaction &dialog, const std::vector< std::string > &argvector) |
wrapper to the "system" system call. More... | |
void | libdar::tools_system_with_pipe (user_interaction &dialog, const std::string &dar_cmd, const std::vector< std::string > &argvpipe) |
wrapper to the "system" system call using anonymous pipe to tranmit arguments to the child process More... | |
void | libdar::tools_write_vector (generic_file &f, const std::vector< std::string > &x) |
write a list of string to file More... | |
void | libdar::tools_read_vector (generic_file &f, std::vector< std::string > &x) |
read a list of string from a file More... | |
std::string | libdar::tools_concat_vector (const std::string &separator, const std::vector< std::string > &x) |
concatenate a vectors of strings in a single string More... | |
std::vector< std::string > | libdar::operator+ (std::vector< std::string > a, std::vector< std::string > b) |
concatenate two vectors More... | |
bool | libdar::tools_is_member (const std::string &val, const std::vector< std::string > &liste) |
test the presence of a value in a list More... | |
void | libdar::tools_display_features (user_interaction &dialog, bool ea, bool largefile, bool nodump, bool special_alloc, U_I bits, bool thread_safe, bool libz, bool libbz2, bool liblzo2, bool libcrypto, bool furtive_read) |
display the compilation time features of libdar More... | |
void | libdar::tools_display_features (user_interaction &dialog) |
display the compilation time features of libdar More... | |
bool | libdar::tools_is_equal_with_hourshift (const infinint &hourshift, const infinint &date1, const infinint &date2) |
test if two dates are equal taking care of a integer hour of difference More... | |
template<class T > | |
std::vector< T > | libdar::operator+= (std::vector< T > &a, const std::vector< T > &b) |
template function to add two vectors | |
const char * | libdar::tools_get_from_env (const char **env, const char *clef) |
isolate the value of a given variable from the environment vector More... | |
void | libdar::tools_check_basename (user_interaction &dialog, const path &loc, std::string &base, const std::string &extension) |
does sanity checks on a slice name, check presence and detect whether the given basename is not rather a filename More... | |
std::string | libdar::tools_getcwd () |
get current working directory | |
std::string | libdar::tools_readlink (const char *root) |
returns the file pointed to by a symbolic link (or transparent if the file is not a symlink). More... | |
bool | libdar::tools_look_for (const char *argument, S_I argc, char *const argv[]) |
test the presence of an argument More... | |
void | libdar::tools_noexcept_make_date (const std::string &chem, const infinint &last_acc, const infinint &last_mod) |
set dates of a given file, no exception thrown More... | |
void | libdar::tools_make_date (const std::string &chemin, infinint access, infinint modif) |
set dates of a given file, may throw exception More... | |
bool | libdar::tools_is_case_insensitive_equal (const std::string &a, const std::string &b) |
compare two string in case insensitive manner More... | |
void | libdar::tools_to_upper (char *nts) |
convert a string to upper case More... | |
void | libdar::tools_to_upper (std::string &r) |
convert a string to upper case More... | |
void | libdar::tools_remove_last_char_if_equal_to (char c, std::string &s) |
remove last character of a string is it equal to a given value More... | |
void | libdar::tools_read_range (const std::string &s, S_I &min, U_I &max) |
from a string with a range notation (min-max) extract the range values More... | |
std::string | libdar::tools_printf (const char *format,...) |
make printf-like formating to a std::string More... | |
std::string | libdar::tools_vprintf (const char *format, va_list ap) |
make printf-like formating to a std::string More... | |
bool | libdar::tools_do_some_files_match_mask_regex (user_interaction &ui, const std::string &c_chemin, const std::string &file_mask) |
test the presence of files corresponding to a given mask in a directory (regex mask) More... | |
void | libdar::tools_unlink_file_mask_regex (user_interaction &dialog, const std::string &c_chemin, const std::string &file_mask, bool info_details) |
remove files from a given directory More... | |
void | libdar::tools_avoid_slice_overwriting_regex (user_interaction &dialog, const path &chemin, const std::string &x_file_mask, bool info_details, bool allow_overwriting, bool warn_overwriting, bool dry_run) |
prevents slice overwriting: check the presence of slice and if necessary ask the user if they can be removed More... | |
void | libdar::tools_add_elastic_buffer (generic_file &f, U_32 max_size) |
append an elastic buffer of given size to the file More... | |
bool | libdar::tools_are_on_same_filesystem (const std::string &file1, const std::string &file2) |
tells whether two files are on the same mounted filesystem More... | |
path | libdar::tools_relative2absolute_path (const path &src, const path &cwd) |
transform a relative path to an absolute one given the current directory value More... | |
void | libdar::tools_block_all_signals (sigset_t &old_mask) |
block all signals (based on POSIX sigprocmask) More... | |
void | libdar::tools_set_back_blocked_signals (sigset_t old_mask) |
unblock signals according to given mask More... | |
U_I | libdar::tools_count_in_string (const std::string &s, const char a) |
counts the number of a given char in a given string More... | |
infinint | libdar::tools_get_mtime (const std::string &s) |
returns the last modification date of the given file More... | |
infinint | libdar::tools_get_size (const std::string &s) |
returns the size of the given plain file More... | |
infinint | libdar::tools_get_ctime (const std::string &s) |
returns the last change date of the given file More... | |
std::vector< std::string > | libdar::tools_split_in_words (generic_file &f) |
read a file and split its contents in words More... | |
bool | libdar::tools_find_next_char_out_of_parenthesis (const std::string &data, const char what, U_32 start, U_32 &found) |
look next char in string out of parenthesis More... | |
std::string | libdar::tools_substitute (const std::string &hook, const std::map< char, std::string > &corres) |
produce the string resulting from the substition of % macro defined in the map More... | |
std::string | libdar::tools_hook_substitute (const std::string &hook, const std::string &path, const std::string &basename, const std::string &num, const std::string &padded_num, const std::string &ext, const std::string &context) |
produces the string resulting from the substitution of %... macro More... | |
void | libdar::tools_hook_execute (user_interaction &ui, const std::string &cmd_line) |
execute and retries at user will a given command line More... | |
void | libdar::tools_hook_substitute_and_execute (user_interaction &ui, const std::string &hook, const std::string &path, const std::string &basename, const std::string &num, const std::string &padded_num, const std::string &ext, const std::string &context) |
subsititue and execute command line More... | |
std::string | libdar::tools_build_regex_for_exclude_mask (const std::string &prefix, const std::string &relative_part) |
builds a regex from root directory and user provided regex to be applied to the relative path More... | |
std::string | libdar::tools_output2xml (const std::string &src) |
convert string for xml output More... | |
U_I | libdar::tools_octal2int (const std::string &perm) |
convert octal string to integer More... | |
std::string | libdar::tools_int2octal (const U_I &perm) |
convert a number to a string corresponding to its octal representation More... | |
void | libdar::tools_set_permission (S_I fd, U_I perm) |
change the permission of the file which descriptor is given More... | |
U_I | libdar::tools_get_permission (S_I fd) |
obtain the permission of the file which descriptor is given More... | |
void | libdar::tools_set_ownership (S_I fd, const std::string &slice_user, const std::string &slice_group) |
change ownership of the file which descriptor is given More... | |
void | libdar::tools_memxor (void *dest, const void *src, U_I n) |
Produces in "dest" the XORed value of "dest" and "src". More... | |
tlv_list | libdar::tools_string2tlv_list (user_interaction &dialog, const U_16 &type, const std::vector< std::string > &data) |
Produces a list of TLV from a constant type and a list of string. More... | |
void | libdar::tools_read_from_pipe (user_interaction &dialog, S_I fd, tlv_list &result) |
Extract from anonymous pipe a tlv_list. More... | |
U_I | libdar::tools_pseudo_random (U_I max) |
Produces a pseudo random number x, where 0 <= x < max. More... | |
template<class N , class B > | |
std::vector< B > | libdar::tools_number_base_decomposition_in_big_endian (N number, const B &base) |
Template for the decomposition of any number in any base (decimal, octal, hexa, etc.) More... | |
std::string | libdar::tools_unsigned_char_to_hexa (unsigned char x) |
convert a unsigned char into its hexa decima representation More... | |
std::string | libdar::tools_string_to_hexa (const std::string &input) |
convert a string into its hexadecima representation More... | |
infinint | libdar::tools_file_size_to_crc_size (const infinint &size) |
Defines the CRC size to use for a given filesize. More... | |
std::string | libdar::tools_get_euid () |
return a string containing the Effective UID | |
std::string | libdar::tools_get_egid () |
return a string containing the Effective UID | |
std::string | libdar::tools_get_hostname () |
return a string containing the hostname of the current host | |
std::string | libdar::tools_get_date_utc () |
return a string containing the current time (UTC) | |
std::string | libdar::tools_get_compression_ratio (const infinint &storage_size, const infinint &file_size) |
return the string about compression ratio | |
a set of tool routine
these routines are available from libdar for historical reason, but are not part of the API. They are shared and used by dar, dar_slave, dar_xform, and dar_manager command. You should avoid using them in external program as they may be removed or changed without backward compatibility support.
std::vector<std::string> libdar::operator+ | ( | std::vector< std::string > | a, |
std::vector< std::string > | b | ||
) |
concatenate two vectors
[in] | a | the first vector |
[in] | b | the second vector |
std::ostream& libdar::operator<< | ( | std::ostream & | ref, |
const infinint & | arg | ||
) |
specific << operator to use infinint in std::ostream
including "deci.hpp" let this operator available so you can display infinint with the << std::ostream operator as you can do for standard types.
void libdar::tools_add_elastic_buffer | ( | generic_file & | f, |
U_32 | max_size | ||
) |
append an elastic buffer of given size to the file
[in,out] | f | file to append elastic buffer to |
[in] | max_size | size of the elastic buffer to add |
std::string libdar::tools_addspacebefore | ( | std::string | s, |
U_I | expected_size | ||
) |
prepend spaces before the given string
[in] | s | the string to append spaces to |
[in] | expected_size | the minimum size of the resulting string |
bool libdar::tools_are_on_same_filesystem | ( | const std::string & | file1, |
const std::string & | file2 | ||
) |
tells whether two files are on the same mounted filesystem
[in] | file1 | first file |
[in] | file2 | second file |
void libdar::tools_avoid_slice_overwriting_regex | ( | user_interaction & | dialog, |
const path & | chemin, | ||
const std::string & | x_file_mask, | ||
bool | info_details, | ||
bool | allow_overwriting, | ||
bool | warn_overwriting, | ||
bool | dry_run | ||
) |
prevents slice overwriting: check the presence of slice and if necessary ask the user if they can be removed
[in,out] | dialog | for user interaction |
[in] | chemin | where slice is about to be created |
[in] | x_file_mask | mask corresponding to slices that will be generated (regex) |
[in] | info_details | whether user must be displayed details of the operation |
[in] | allow_overwriting | whether overwriting is allowed by the user |
[in] | warn_overwriting | whether a warning must be issued before overwriting (if allowed) |
[in] | dry_run | do a dry-run exection (no filesystem modification is performed) |
void libdar::tools_block_all_signals | ( | sigset_t & | old_mask | ) |
block all signals (based on POSIX sigprocmask)
[out] | old_mask | is set to the old mask value (for later unmasking signals) |
Erange | is thrown if system call failed for some reason |
void libdar::tools_blocking_read | ( | int | fd, |
bool | mode | ||
) |
set blocking/not blocking mode for reading on a file descriptor
[in] | fd | file descriptor to read on |
[in] | mode | set to true for a blocking read and to false for non blocking read |
std::string libdar::tools_build_regex_for_exclude_mask | ( | const std::string & | prefix, |
const std::string & | relative_part | ||
) |
builds a regex from root directory and user provided regex to be applied to the relative path
[in] | prefix | is the root portion of the path |
[in] | relative_part | is the user provided regex to be applied to the relative path |
void libdar::tools_check_basename | ( | user_interaction & | dialog, |
const path & | loc, | ||
std::string & | base, | ||
const std::string & | extension | ||
) |
does sanity checks on a slice name, check presence and detect whether the given basename is not rather a filename
[in,out] | dialog | for user interaction |
[in] | loc | the path where resides the slice |
[in,out] | base | the basename of the slice |
[in] | extension | the extension of dar's slices |
std::string libdar::tools_concat_vector | ( | const std::string & | separator, |
const std::vector< std::string > & | x | ||
) |
concatenate a vectors of strings in a single string
[in] | separator | string to insert between two elements |
[in] | x | the list string |
infinint libdar::tools_convert_date | ( | const std::string & | repres | ) |
convert a human readable date representation in number of second since the system reference date
[in] | repres | the date's human representation |
U_I libdar::tools_count_in_string | ( | const std::string & | s, |
const char | a | ||
) |
counts the number of a given char in a given string
[in] | s | string to look inside of |
[in] | a | char to look for |
std::string libdar::tools_display_date | ( | infinint | date | ) |
convert a date in second to its human readable representation
[in] | date | the date in second |
void libdar::tools_display_features | ( | user_interaction & | dialog, |
bool | ea, | ||
bool | largefile, | ||
bool | nodump, | ||
bool | special_alloc, | ||
U_I | bits, | ||
bool | thread_safe, | ||
bool | libz, | ||
bool | libbz2, | ||
bool | liblzo2, | ||
bool | libcrypto, | ||
bool | furtive_read | ||
) |
display the compilation time features of libdar
[in,out] | dialog | for user interaction |
[in] | ea | whether Extended Attribute support is available |
[in] | largefile | whether large file support is available |
[in] | nodump | whether nodump flag support is available |
[in] | special_alloc | whether special allocation is activated |
[in] | bits | infinint version used |
[in] | thread_safe | whether thread safe support is available |
[in] | libz | whether libz compression is available |
[in] | libbz2 | whether libbz2 compression is available |
[in] | liblzo2 | whether lzo compression is available |
[in] | libcrypto | whether strong encryption is available |
[in] | furtive_read | whether furtive read access is available |
void libdar::tools_display_features | ( | user_interaction & | dialog | ) |
display the compilation time features of libdar
[in,out] | dialog | for user interaction |
bool libdar::tools_do_some_files_match_mask_regex | ( | user_interaction & | ui, |
const std::string & | c_chemin, | ||
const std::string & | file_mask | ||
) |
test the presence of files corresponding to a given mask in a directory (regex mask)
[in,out] | ui | for user interaction |
[in] | c_chemin | directory where file have to be looked for |
[in] | file_mask | regex expression which designates the files to look for |
void libdar::tools_extract_basename | ( | const char * | command_name, |
std::string & | basename | ||
) |
extracts the basename of a file (removing path part)
[in] | command_name | is the full path of the file |
[out] | basename | the basename of the file |
Ememory | can be thrown if memory allocation failed |
infinint libdar::tools_file_size_to_crc_size | ( | const infinint & | size | ) |
Defines the CRC size to use for a given filesize.
[in] | size | is the size of the file to protect by CRC |
std::string::iterator libdar::tools_find_first_char_of | ( | std::string & | s, |
unsigned char | v | ||
) |
give a pointer to the last character of the given value in the given string
[in] | s | is the given string |
[in] | v | is the given char value |
std::string::iterator libdar::tools_find_last_char_of | ( | std::string & | s, |
unsigned char | v | ||
) |
give a pointer to the last character of the given value in the given string
[in] | s | is the given string |
[in] | v | is the given char value |
bool libdar::tools_find_next_char_out_of_parenthesis | ( | const std::string & | data, |
const char | what, | ||
U_32 | start, | ||
U_32 & | found | ||
) |
look next char in string out of parenthesis
[in] | data | is the string to look into |
[in] | what | is the char to look for |
[in] | start | is the index in string to start from, assuming at given position we are out of parenthesis |
[out] | found | the position of the next char equal to what |
infinint libdar::tools_get_ctime | ( | const std::string & | s | ) |
returns the last change date of the given file
[in] | s | path of the file to get the last ctime |
infinint libdar::tools_get_extended_size | ( | std::string | s, |
U_I | base | ||
) |
convert the given string to infinint taking care of multiplication suffixes like k, M, T, etc.
[in] | s | is the string to read |
[in] | base | is the multiplication factor (base = 1000 for SI, base = 1024 for computer science use) |
infinint libdar::tools_get_filesize | ( | const path & | p | ) |
retrieve the size in byte of a file
[in] | p | is the path to the file which size is to get |
const char* libdar::tools_get_from_env | ( | const char ** | env, |
const char * | clef | ||
) |
isolate the value of a given variable from the environment vector
[in] | env | the environment vector as retreived from the third argument of the main() function |
[in] | clef | the key or variable name too look for |
infinint libdar::tools_get_mtime | ( | const std::string & | s | ) |
returns the last modification date of the given file
[in] | s | path of the file to get the last mtime |
U_I libdar::tools_get_permission | ( | S_I | fd | ) |
obtain the permission of the file which descriptor is given
[in] | fd | file's descriptor |
infinint libdar::tools_get_size | ( | const std::string & | s | ) |
returns the size of the given plain file
[in] | s | path of the file to get the size |
void libdar::tools_hook_execute | ( | user_interaction & | ui, |
const std::string & | cmd_line | ||
) |
execute and retries at user will a given command line
[in] | ui | which way to ask the user whether to continue upon command line error |
[in] | cmd_line | the command line to execute |
std::string libdar::tools_hook_substitute | ( | const std::string & | hook, |
const std::string & | path, | ||
const std::string & | basename, | ||
const std::string & | num, | ||
const std::string & | padded_num, | ||
const std::string & | ext, | ||
const std::string & | context | ||
) |
produces the string resulting from the substitution of %... macro
[in] | hook | the string in which to substitute |
[in] | path | is by what p will be replaced |
[in] | basename | is by what b will be replaced |
[in] | num | is by what n will be replaced |
[in] | padded_num | is by what N will be replaced |
[in] | ext | is by what e will be replaced |
[in] | context | is by what c will be replaced |
void libdar::tools_hook_substitute_and_execute | ( | user_interaction & | ui, |
const std::string & | hook, | ||
const std::string & | path, | ||
const std::string & | basename, | ||
const std::string & | num, | ||
const std::string & | padded_num, | ||
const std::string & | ext, | ||
const std::string & | context | ||
) |
subsititue and execute command line
[in,out] | ui | this is the way to contact the user |
[in] | hook | the string in which to substitute |
[in] | path | is by what p will be replaced |
[in] | basename | is by what b will be replaced |
[in] | num | is by what n will be replaced |
[in] | padded_num | is by what N will be replaced |
[in] | ext | is by what e will be replaced |
[in] | context | is by what c will be replaced |
std::string libdar::tools_int2octal | ( | const U_I & | perm | ) |
convert a number to a string corresponding to its octal representation
perm | is the octal number |
std::string libdar::tools_int2str | ( | S_I | x | ) |
convert integer to string
[in] | x | the integer to convert |
bool libdar::tools_is_case_insensitive_equal | ( | const std::string & | a, |
const std::string & | b | ||
) |
compare two string in case insensitive manner
[in] | a | first string to compare |
[in] | b | second string to compare |
bool libdar::tools_is_equal_with_hourshift | ( | const infinint & | hourshift, |
const infinint & | date1, | ||
const infinint & | date2 | ||
) |
test if two dates are equal taking care of a integer hour of difference
[in] | hourshift | is the number of integer hour more or less two date can be considered equal |
[in] | date1 | first date to compare |
[in] | date2 | second date to compare to |
bool libdar::tools_is_member | ( | const std::string & | val, |
const std::vector< std::string > & | liste | ||
) |
test the presence of a value in a list
[in] | val | is the value to look for |
[in] | liste | is the list to look in |
bool libdar::tools_look_for | ( | const char * | argument, |
S_I | argc, | ||
char *const | argv[] | ||
) |
test the presence of an argument
[in] | argument | is the command line argument to look for |
[in] | argc | is the number of argument on the command line |
[in] | argv | is the list of argument on the command line |
void libdar::tools_make_date | ( | const std::string & | chemin, |
infinint | access, | ||
infinint | modif | ||
) |
set dates of a given file, may throw exception
[in] | chemin | the path to the file to set |
[in] | access | last access date to use |
[in] | modif | last modification date to use |
void libdar::tools_memxor | ( | void * | dest, |
const void * | src, | ||
U_I | n | ||
) |
Produces in "dest" the XORed value of "dest" and "src".
[in,out] | dest | is the area where to write down the result |
[in] | src | points to vector or array of values to convert |
[in] | n | is the number of byte to convert from src to dest |
bool libdar::tools_my_atoi | ( | const char * | a, |
U_I & | val | ||
) |
ascii to integer conversion
[in] | a | is the ascii string to convert |
[out] | val | is the resulting value |
std::string libdar::tools_name_of_gid | ( | const infinint & | gid | ) |
convert gid to name in regards of the current system's configuration
[in] | gid | the Group ID number |
std::string libdar::tools_name_of_uid | ( | const infinint & | uid | ) |
convert uid to name in regards to the current system's configuration
[in] | uid | the User ID number |
void libdar::tools_noexcept_make_date | ( | const std::string & | chem, |
const infinint & | last_acc, | ||
const infinint & | last_mod | ||
) |
set dates of a given file, no exception thrown
[in] | chem | the path to the file to set |
[in] | last_acc | last access date to use |
[in] | last_mod | last modification date to use |
std::vector<B> libdar::tools_number_base_decomposition_in_big_endian | ( | N | number, |
const B & | base | ||
) |
Template for the decomposition of any number in any base (decimal, octal, hexa, etc.)
[in] | number | is the number to decompose |
[in] | base | is the base to decompose the number into |
U_I libdar::tools_octal2int | ( | const std::string & | perm | ) |
convert octal string to integer
perm | is a string representing a number in octal (string must have a leading zero) |
void libdar::tools_open_pipes | ( | user_interaction & | dialog, |
const std::string & | input, | ||
const std::string & | output, | ||
tuyau *& | in, | ||
tuyau *& | out | ||
) |
open a pair of tuyau objects encapsulating two named pipes.
[in,out] | dialog | for user interaction |
[in] | input | path to the input named pipe |
[in] | output | path to the output named pipe |
[out] | in | resulting tuyau object for input |
[out] | out | resulting tuyau object for output |
std::string libdar::tools_output2xml | ( | const std::string & | src | ) |
convert string for xml output
std::string libdar::tools_printf | ( | const char * | format, |
... | |||
) |
make printf-like formating to a std::string
[in] | format | the format string |
[in] | ... | list of argument to use against the format string |
U_I libdar::tools_pseudo_random | ( | U_I | max | ) |
Produces a pseudo random number x, where 0 <= x < max.
[in] | max | defines the range of the random number to return |
void libdar::tools_read_from_pipe | ( | user_interaction & | dialog, |
S_I | fd, | ||
tlv_list & | result | ||
) |
Extract from anonymous pipe a tlv_list.
[in,out] | dialog | for user interaction |
[in] | fd | the filedescriptor for the anonymous pipe's read extremity |
[out] | result | the resulting tlv_list |
void libdar::tools_read_range | ( | const std::string & | s, |
S_I & | min, | ||
U_I & | max | ||
) |
from a string with a range notation (min-max) extract the range values
[in] | s | the string to parse |
[out] | min | the minimum value of the range |
[out] | max | the maximum value of the range |
Erange | is thrown is the string to parse is incorrect |
void libdar::tools_read_string | ( | generic_file & | f, |
std::string & | s | ||
) |
read a string from a file expecting it to terminate by '\0'
f | the file to read from |
s | the string to put the data to (except the ending '\0') |
void libdar::tools_read_string_size | ( | generic_file & | f, |
std::string & | s, | ||
infinint | taille | ||
) |
read a string if given size from a file '\0' has no special meaning
[in] | f | is the file to read from |
[in] | s | is the string to put read data in |
[in] | taille | is the size in byte to read |
void libdar::tools_read_vector | ( | generic_file & | f, |
std::vector< std::string > & | x | ||
) |
read a list of string from a file
[in] | f | the file to read from |
[out] | x | the list to fill from file |
std::string libdar::tools_readlink | ( | const char * | root | ) |
returns the file pointed to by a symbolic link (or transparent if the file is not a symlink).
root | the path to the file to read |
path libdar::tools_relative2absolute_path | ( | const path & | src, |
const path & | cwd | ||
) |
transform a relative path to an absolute one given the current directory value
[in] | src | the relative path to transform |
[in] | cwd | the value to take for the current directory |
void libdar::tools_remove_last_char_if_equal_to | ( | char | c, |
std::string & | s | ||
) |
remove last character of a string is it equal to a given value
[in] | c | the given value to compare the last char with |
[in,out] | s | the string to modify |
void libdar::tools_set_back_blocked_signals | ( | sigset_t | old_mask | ) |
unblock signals according to given mask
[in] | old_mask | value to set to blocked signal mask |
Erange | is thrown if system call failed for some reason |
void libdar::tools_set_ownership | ( | S_I | fd, |
const std::string & | slice_user, | ||
const std::string & | slice_group | ||
) |
change ownership of the file which descriptor is given
[in] | fd | file's descriptor |
[in] | slice_user | the user to set the file to. For empty string, no attempts to change the user ownership is done |
[in] | slice_group | the group to set the file to. For empty string, no attempts to change the group ownership is done |
void libdar::tools_set_permission | ( | S_I | fd, |
U_I | perm | ||
) |
change the permission of the file which descriptor is given
[in] | fd | file's descriptor |
[in] | perm | file permission to set the file to |
std::vector<std::string> libdar::tools_split_in_words | ( | generic_file & | f | ) |
read a file and split its contents in words
[in,out] | f | is the file to read |
void libdar::tools_split_path_basename | ( | const char * | all, |
path *& | chemin, | ||
std::string & | base | ||
) |
split a given full path in path part and basename part
[in] | all | is the path to split |
[out] | chemin | is the resulting path part, it points to a newly allocated path object |
[out] | base | is the resulting basename |
void libdar::tools_split_path_basename | ( | const std::string & | all, |
std::string & | chemin, | ||
std::string & | base | ||
) |
split a given full path in path part and basename part
[in] | all | is the path to split |
[out] | chemin | is the resulting path part, it points to a newly allocated path object |
[out] | base | is the resulting basename |
char* libdar::tools_str2charptr | ( | const std::string & | x | ) |
convert a string to a char *
[in] | x | is the string to convert |
Ememory | is thrown if the memory allocation failed, this call never return NULL |
U_I libdar::tools_str2int | ( | const std::string & | x | ) |
convert an integer written in decimal notation to the corresponding value
[in] | x | the decimal representation of the integer |
S_I libdar::tools_str2signed_int | ( | const std::string & | x | ) |
convert a signed integer written in decimal notation to the corresponding value
[in] | x | the decimal representation of the integer |
tlv_list libdar::tools_string2tlv_list | ( | user_interaction & | dialog, |
const U_16 & | type, | ||
const std::vector< std::string > & | data | ||
) |
Produces a list of TLV from a constant type and a list of string.
[in,out] | dialog | for user interaction |
[in] | type | is the type each TLV will have |
[in] | data | is the list of string to convert into a list of TLV |
std::string libdar::tools_string_to_hexa | ( | const std::string & | input | ) |
convert a string into its hexadecima representation
[in] | input | input string to convert |
std::string libdar::tools_substitute | ( | const std::string & | hook, |
const std::map< char, std::string > & | corres | ||
) |
produce the string resulting from the substition of % macro defined in the map
[in] | hook | is the user's expression in which to proceed to substitution |
[in] | corres | is a map telling which char following a % sign to replace by which string |
void libdar::tools_system | ( | user_interaction & | dialog, |
const std::vector< std::string > & | argvector | ||
) |
wrapper to the "system" system call.
[in,out] | dialog | for user interaction |
[in] | argvector | the equivalent to the argv[] vector |
void libdar::tools_system_with_pipe | ( | user_interaction & | dialog, |
const std::string & | dar_cmd, | ||
const std::vector< std::string > & | argvpipe | ||
) |
wrapper to the "system" system call using anonymous pipe to tranmit arguments to the child process
[in,out] | dialog | for user interaction |
[in] | dar_cmd | the path to the executable to run |
[in] | argvpipe | the list of arguments to pass through anonymous pipe |
void libdar::tools_to_upper | ( | char * | nts | ) |
convert a string to upper case
[in,out] | nts | a NULL terminated string to convert |
void libdar::tools_to_upper | ( | std::string & | r | ) |
convert a string to upper case
[in,out] | r | to convert |
void libdar::tools_unlink_file_mask_regex | ( | user_interaction & | dialog, |
const std::string & | c_chemin, | ||
const std::string & | file_mask, | ||
bool | info_details | ||
) |
remove files from a given directory
[in,out] | dialog | for user interaction |
[in] | c_chemin | directory where files have to be removed |
[in] | file_mask | regex expression which designates the files to remove |
[in] | info_details | whether user must be displayed details of the operation |
std::string libdar::tools_unsigned_char_to_hexa | ( | unsigned char | x | ) |
convert a unsigned char into its hexa decima representation
[in] | x | is the byte to convert |
std::string libdar::tools_uword2str | ( | U_16 | x | ) |
convert unsigned word to string
[in] | x | the unsigned word to convert |
std::string libdar::tools_vprintf | ( | const char * | format, |
va_list | ap | ||
) |
make printf-like formating to a std::string
[in] | format | the format string |
[in] | ap | list of argument to use against the format string |
void libdar::tools_write_string | ( | generic_file & | f, |
const std::string & | s | ||
) |
write a string to a file with a '\0' at then end
[in] | f | the file to write to |
[in] | s | the string to write to file |
void libdar::tools_write_string_all | ( | generic_file & | f, |
const std::string & | s | ||
) |
write a string to a file, '\0' has no special meaning nor is added at the end
[in] | f | the file to write to |
[in] | s | the string to write to file |
void libdar::tools_write_vector | ( | generic_file & | f, |
const std::vector< std::string > & | x | ||
) |
write a list of string to file
[in] | f | the file to write to |
[in] | x | the list of string to write |