Disk ARchive  2.5.14-bis
Full featured and portable backup and archiving tool
tools.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 
31 
35 
36 
37 #ifndef TOOLS_HPP
38 #define TOOLS_HPP
39 
40 #include "../my_config.h"
41 
42 extern "C"
43 {
44 #if STDC_HEADERS
45 #include <stdarg.h>
46 #endif
47 #if HAVE_SIGNAL_H
48 #include <signal.h>
49 #endif
50 #if HAVE_GPGME_H
51 #include <gpgme.h>
52 #endif
53 }
54 
55 #include <string>
56 #include <vector>
57 #include <map>
58 #include "path.hpp"
59 #include "infinint.hpp"
60 #include "generic_file.hpp"
61 #include "tuyau.hpp"
62 #include "integers.hpp"
63 #include "tlv_list.hpp"
64 #include "memory_pool.hpp"
65 #include "datetime.hpp"
66 
67 #define TOOLS_SI_SUFFIX 1000
68 #define TOOLS_BIN_SUFFIX 1024
69 
70 namespace libdar
71 {
72 
75 
76 
78  extern void tools_init();
80  extern void tools_end();
81 
83 
88  extern char *tools_str2charptr(const std::string &x);
89 
91 
94  extern void tools_write_string(generic_file & f, const std::string & s);
95 
97 
100  extern void tools_read_string(generic_file & f, std::string & s);
101 
103 
106  extern void tools_write_string_all(generic_file & f, const std::string & s);
107 
109 
113  extern void tools_read_string_size(generic_file & f, std::string & s, infinint taille);
114 
116 
119  extern infinint tools_get_filesize(const path &p);
120 
122 
126  extern infinint tools_get_extended_size(std::string s, U_I base);
127 
133  extern std::string tools_display_integer_in_metric_system(infinint number, const std::string & unit, bool binary);
134 
136 
140  extern void tools_extract_basename(const char *command_name, std::string & basename);
141 
142 
144 
150  extern std::string::iterator tools_find_last_char_of(std::string &s, unsigned char v);
151 
153 
159  extern std::string::iterator tools_find_first_char_of(std::string &s, unsigned char v);
160 
162 
168  extern void tools_split_path_basename(const char *all, path * &chemin, std::string & base, memory_pool *pool = nullptr);
169 
171 
177  extern void tools_split_path_basename(const std::string &all, std::string & chemin, std::string & base, memory_pool *pool = nullptr);
178 
180 
188  extern void tools_open_pipes(user_interaction & dialog,
189  const std::string &input,
190  const std::string & output,
191  tuyau *&in,
192  tuyau *&out,
193  memory_pool *pool = nullptr);
194 
196 
199  extern void tools_blocking_read(int fd, bool mode);
200 
202 
205  extern std::string tools_name_of_uid(const infinint & uid);
206 
208 
211  extern std::string tools_name_of_gid(const infinint & gid);
212 
214 
217  extern std::string tools_uword2str(U_16 x);
218 
220 
223  extern std::string tools_int2str(S_I x);
224  extern std::string tools_uint2str(U_I x);
225 
227 
230  extern U_I tools_str2int(const std::string & x);
231 
233 
236  extern S_I tools_str2signed_int(const std::string & x);
237 
239 
245  extern bool tools_my_atoi(const char *a, U_I & val);
246 
248 
252  extern std::string tools_addspacebefore(std::string s, U_I expected_size);
253 
255 
258  extern std::string tools_display_date(const datetime & date);
259 
261 
265  extern infinint tools_convert_date(const std::string & repres);
266 
268 
271  extern void tools_system(user_interaction & dialog, const std::vector<std::string> & argvector);
272 
274 
281  extern void tools_system_with_pipe(user_interaction & dialog,
282  const std::string & dar_cmd,
283  const std::vector<std::string> & argvpipe,
284  memory_pool *pool = nullptr);
285 
287 
290  extern void tools_write_vector(generic_file & f, const std::vector<std::string> & x);
291 
293 
296  extern void tools_read_vector(generic_file & f, std::vector<std::string> & x);
297 
299 
303  extern std::string tools_concat_vector(const std::string & separator,
304  const std::vector<std::string> & x);
305 
307 
311  std::vector<std::string> operator + (std::vector<std::string> a, std::vector<std::string> b);
312 
313 
315 
319  extern void tools_display_features(user_interaction & dialog);
320 
321 
323 
328  extern bool tools_is_equal_with_hourshift(const infinint & hourshift, const datetime & date1, const datetime & date2);
329 
331 
332  template <class T> std::vector<T> operator +=(std::vector<T> & a, const std::vector<T> & b)
333  {
334  a = a + b;
335  return a;
336  }
337 
338 
340 
345  extern const char *tools_get_from_env(const char **env, const char *clef);
346 
348 
355  extern void tools_check_basename(user_interaction & dialog,
356  const path & loc,
357  std::string & base,
358  const std::string & extension,
359  memory_pool *pool = nullptr);
360 
362 
363  extern std::string tools_getcwd();
364 
366 
370  extern std::string tools_readlink(const char *root);
371 
373 
379  extern bool tools_look_for(const char *argument, S_I argc, char *const argv[]);
380 
381 
383 
389  extern void tools_noexcept_make_date(const std::string & chem, bool symlink, const datetime & last_acc, const datetime & last_mod, const datetime & birth);
390 
392 
399  extern void tools_make_date(const std::string & chemin, bool symlink, const datetime & access, const datetime & modif, const datetime & birth);
400 
402 
406  extern bool tools_is_case_insensitive_equal(const std::string & a, const std::string & b);
407 
414  extern void tools_to_upper(const std::string & r, std::string & uppered);
415 
416 #if HAVE_WCTYPE_H
417  extern void tools_to_wupper(std::wstring & r);
424 #endif
425 
427 
430  extern void tools_remove_last_char_if_equal_to(char c, std::string & s);
431 
433 
441  extern void tools_read_range(const std::string & s, S_I & min, U_I & max);
442 
443 
445 
455  extern std::string tools_printf(const char *format, ...);
456 
458 
467  extern std::string tools_vprintf(const char *format, va_list ap);
468 
470 
475  extern bool tools_do_some_files_match_mask_regex(user_interaction & ui, const std::string & c_chemin, const std::string & file_mask);
476 
477 
479 
485  extern void tools_unlink_file_mask_regex(user_interaction & dialog, const std::string & c_chemin, const std::string & file_mask, bool info_details);
486 
487 
489 
500  const path & chemin,
501  const std::string & basename,
502  const std::string & extension,
503  bool info_details,
504  bool allow_overwriting,
505  bool warn_overwriting,
506  bool dry_run);
507 
509 
528  extern void tools_add_elastic_buffer(generic_file & f,
529  U_32 max_size,
530  U_32 modulo,
531  U_32 offset);
532 
533 
541  extern bool tools_are_on_same_filesystem(const std::string & file1, const std::string & file2);
542 
543 
545 
549  extern path tools_relative2absolute_path(const path & src, const path & cwd);
550 
552 
555  extern void tools_block_all_signals(sigset_t &old_mask);
556 
558 
561  extern void tools_set_back_blocked_signals(sigset_t old_mask);
562 
564 
568  extern U_I tools_count_in_string(const std::string & s, const char a);
569 
571 
577  extern datetime tools_get_mtime(user_interaction & dialog,
578  const std::string & s,
579  bool auto_zeroing,
580  bool silent);
581 
583 
586  extern infinint tools_get_size(const std::string & s);
587 
589 
592  extern datetime tools_get_ctime(const std::string & s);
593 
595 
599  extern std::vector<std::string> tools_split_in_words(generic_file & f);
600 
601 
603 
607  extern std::vector<std::string> tools_split_in_words(const std::string & arg);
608 
609 
611 
620  extern bool tools_find_next_char_out_of_parenthesis(const std::string & data, const char what, U_32 start, U_32 & found);
621 
622 
624 
628  extern std::string tools_substitute(const std::string & hook,
629  const std::map<char, std::string> & corres);
630 
631 
633 
643  extern std::string tools_hook_substitute(const std::string & hook,
644  const std::string & path,
645  const std::string & basename,
646  const std::string & num,
647  const std::string & padded_num,
648  const std::string & ext,
649  const std::string & context);
650 
651 
653 
656  extern void tools_hook_execute(user_interaction & ui,
657  const std::string & cmd_line);
658 
659 
661 
671  const std::string & hook,
672  const std::string & path,
673  const std::string & basename,
674  const std::string & num,
675  const std::string & padded_num,
676  const std::string & ext,
677  const std::string & context);
678 
680 
681 
685  extern std::string tools_build_regex_for_exclude_mask(const std::string & prefix,
686  const std::string & relative_part);
687 
689 
692  extern std::string tools_output2xml(const std::string & src);
693 
695 
698  extern U_I tools_octal2int(const std::string & perm);
699 
700 
702 
705  extern std::string tools_int2octal(const U_I & perm);
706 
708 
709  extern std::string tools_get_permission_string(char type, U_32 perm, bool hard);
710 
712 
715  extern void tools_set_permission(S_I fd, U_I perm);
716 
718 
722  extern U_I tools_get_permission(S_I fd);
723 
725 
727 
730  extern uid_t tools_ownership2uid(const std::string & user);
731 
733 
736  extern uid_t tools_ownership2gid(const std::string & group);
737 
739 
744  extern void tools_set_ownership(S_I filedesc, const std::string & slice_user, const std::string & slice_group);
745 
747 
752  extern void tools_memxor(void *dest, const void *src, U_I n);
753 
755 
760  extern tlv_list tools_string2tlv_list(user_interaction & dialog, const U_16 & type, const std::vector<std::string> & data);
761 
762 
763 
765 
769  extern void tools_read_from_pipe(user_interaction & dialog, S_I fd, tlv_list & result);
770 
771 
772 
774 
777  extern U_I tools_pseudo_random(U_I max);
778 
779 
781 
788 
789  template <class N, class B> std::vector<B> tools_number_base_decomposition_in_big_endian(N number, const B & base)
790  {
791  std::vector<B> ret;
792 
793  if(base <= 0)
794  throw Erange("tools_number_decoupe_in_big_endian", "base must be strictly positive");
795 
796  while(number != 0)
797  {
798  ret.push_back(number % base);
799  number /= base;
800  }
801 
802  return ret;
803  }
804 
806 
809  std::string tools_unsigned_char_to_hexa(unsigned char x);
810 
812 
815 
816  std::string tools_string_to_hexa(const std::string & input);
817 
819 
822  extern infinint tools_file_size_to_crc_size(const infinint & size);
823 
825  extern std::string tools_get_euid();
826 
828  extern std::string tools_get_egid();
829 
831  extern std::string tools_get_hostname();
832 
834  extern std::string tools_get_date_utc();
835 
837  extern std::string tools_get_compression_ratio(const infinint & storage_size, const infinint & file_size, bool compressed);
838 
840  extern std::string tools_strerror_r(int errnum);
841 
842 #ifdef GPGME_SUPPORT
843  extern std::string tools_gpgme_strerror_r(gpgme_error_t err);
845 #endif
846 
847 #if HAVE_WCHAR_H
848  extern std::wstring tools_string_to_wstring(const std::string & val);
850 
852  extern std::string tools_wstring_to_string(const std::wstring & val);
853 #endif
854 
856  extern void tools_merge_to_vector(std::vector<std::string> & a, const std::vector<std::string> & b);
857 
859  extern std::vector<std::string> tools_substract_from_vector(const std::vector<std::string> & a, const std::vector<std::string> & b);
860 
871  struct dirent *tools_allocate_struct_dirent(const std::string & path_name, U_64 & max_name_length, memory_pool *pool = nullptr);
872 
873 
877  extern void tools_release_struct_dirent(struct dirent *ptr);
878 
880  extern void tools_secu_string_show(user_interaction & dialog, const std::string & msg, const secu_string & key);
881 
882  template <class T> T tools_max(T a, T b) { return a > b ? a : b; }
883  template <class T> T tools_min(T a, T b) { return a > b ? b : a; }
884 
886  extern std::string tools_escape_chars_in_string(const std::string & val, const char *to_escape);
887 
889 
891  extern bool tools_infinint2U_64(infinint val, U_64 & res);
892 
893 
895 
902  template <class T> void tools_check_negative_date(T & val,
903  user_interaction & ui,
904  const char *inode_path,
905  const char *nature,
906  bool ask_before,
907  bool silent)
908  {
909  if(val < 0)
910  {
911  if(!silent)
912  {
913  std::string msg = tools_printf(gettext("Found negative date (%s) for inode %s ."),
914  nature,
915  inode_path);
916  if(ask_before)
917  ui.pause(tools_printf(gettext("%S Can we read it as if it was zero (1st January 1970 at 00:00:00 UTC)?"),
918  &msg));
919  else // just warn
920  ui.warning(msg + gettext("Considering date as if it was zero (Jan 1970)"));
921  }
922 
923  val = 0;
924  }
925  }
926 
927 }
928 
929 #endif
void tools_noexcept_make_date(const std::string &chem, bool symlink, const datetime &last_acc, const datetime &last_mod, const datetime &birth)
set dates of a given file, no exception thrown
std::string tools_get_egid()
return a string containing the Effective UID
void warning(const std::string &message)
method used to display a warning or a message to the user.
void tools_open_pipes(user_interaction &dialog, const std::string &input, const std::string &output, tuyau *&in, tuyau *&out, memory_pool *pool=nullptr)
open a pair of tuyau objects encapsulating two named pipes.
void 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
void tools_split_path_basename(const char *all, path *&chemin, std::string &base, memory_pool *pool=nullptr)
split a given full path in path part and basename part
void tools_write_string_all(generic_file &f, const std::string &s)
write a string to a file, &#39;\0&#39; has no special meaning nor is added at the end
bool tools_look_for(const char *argument, S_I argc, char *const argv[])
test the presence of an argument
void tools_to_upper(const std::string &r, std::string &uppered)
convert a string to upper case
are defined here basic integer types that tend to be portable
class memory_pool allocates and recycles blocks of memory for better performances it is expected to b...
void tools_read_from_pipe(user_interaction &dialog, S_I fd, tlv_list &result)
Extract from anonymous pipe a tlv_list.
S_I tools_str2signed_int(const std::string &x)
convert a signed integer written in decimal notation to the corresponding value
std::string 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 ...
void tools_init()
libdar internal use only: it is launched from get_version() and initializes tools internal variables ...
std::string tools_escape_chars_in_string(const std::string &val, const char *to_escape)
escape with a anti-slash character a set of chars found in the given string
datetime tools_get_mtime(user_interaction &dialog, const std::string &s, bool auto_zeroing, bool silent)
returns the last modification date of the given file
const char * tools_get_from_env(const char **env, const char *clef)
isolate the value of a given variable from the environment vector
std::vector< B > 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.)
Definition: tools.hpp:789
void tools_extract_basename(const char *command_name, std::string &basename)
extracts the basename of a file (removing path part)
void tools_read_string_size(generic_file &f, std::string &s, infinint taille)
read a string if given size from a file &#39;\0&#39; has no special meaning
bool 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
void tools_write_string(generic_file &f, const std::string &s)
write a string to a file with a &#39;\0&#39; at then end
void tools_read_vector(generic_file &f, std::vector< std::string > &x)
read a list of string from a file
class generic_file is defined here as well as class fichierthe generic_file interface is widely used ...
void tools_set_back_blocked_signals(sigset_t old_mask)
unblock signals according to given mask
std::vector< std::string > tools_substract_from_vector(const std::vector< std::string > &a, const std::vector< std::string > &b)
remove from &#39;a&#39; elements found in &#39;b&#39; and return the resulting vector
void tools_set_permission(S_I fd, U_I perm)
change the permission of the file which descriptor is given
infinint tools_convert_date(const std::string &repres)
convert a human readable date representation in number of second since the system reference date ...
std::string tools_name_of_uid(const infinint &uid)
convert uid to name in regards to the current system&#39;s configuration
std::string tools_uword2str(U_16 x)
convert unsigned word to string
void 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
std::vector< T > operator+=(std::vector< T > &a, const std::vector< T > &b)
template function to add two vectors
Definition: tools.hpp:332
void tools_end()
libdar internal use only: it is launched from close_and_clean() and releases tools internal variables...
std::string tools_name_of_gid(const infinint &gid)
convert gid to name in regards of the current system&#39;s configuration
This is a pure virtual class that is used by libdar when interaction with the user is required...
void tools_display_features(user_interaction &dialog)
display the compilation time features of libdar
bool tools_is_case_insensitive_equal(const std::string &a, const std::string &b)
compare two string in case insensitive manner
void 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
infinint tools_file_size_to_crc_size(const infinint &size)
Defines the CRC size to use for a given filesize.
std::string tools_printf(const char *format,...)
make printf-like formating to a std::string
struct dirent * tools_allocate_struct_dirent(const std::string &path_name, U_64 &max_name_length, memory_pool *pool=nullptr)
uid_t tools_ownership2gid(const std::string &group)
convert string group name or gid to numeric gid value
datetime tools_get_ctime(const std::string &s)
returns the last change date of the given file
virtual void pause(const std::string &message)
method used to ask a boolean question to the user.
void tools_add_elastic_buffer(generic_file &f, U_32 max_size, U_32 modulo, U_32 offset)
append an elastic buffer of given size to the file
std::string tools_string_to_hexa(const std::string &input)
convert a string into its hexadecima representation
void tools_blocking_read(int fd, bool mode)
set blocking/not blocking mode for reading on a file descriptor
std::string::iterator 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
infinint 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.
U_I tools_octal2int(const std::string &perm)
convert octal string to integer
bool 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) ...
here is the definition of the path classthe path class handle path and provide several operation on t...
void tools_read_string(generic_file &f, std::string &s)
read a string from a file expecting it to terminate by &#39;\0&#39;
tlv_list 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.
std::string tools_get_euid()
return a string containing the Effective UID
void tools_release_struct_dirent(struct dirent *ptr)
std::string 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
std::string tools_getcwd()
get current working directory
bool tools_infinint2U_64(infinint val, U_64 &res)
convert an infinint to U_64 (aka "uint64_t" or yet "unsigned long long")
bool tools_is_equal_with_hourshift(const infinint &hourshift, const datetime &date1, const datetime &date2)
test if two dates are equal taking care of a integer hour of difference
std::string tools_addspacebefore(std::string s, U_I expected_size)
prepend spaces before the given string
std::string tools_display_date(const datetime &date)
convert a date in second to its human readable representation
defines the implementation of pipe under the generic_file interface.mainly used between zapette and s...
std::string tools_int2str(S_I x)
convert integer to string
void tools_write_vector(generic_file &f, const std::vector< std::string > &x)
write a list of string to file
path tools_relative2absolute_path(const path &src, const path &cwd)
transform a relative path to an absolute one given the current directory value
infinint tools_get_size(const std::string &s)
returns the size of the given plain file
std::string tools_get_permission_string(char type, U_32 perm, bool hard)
convert a permission number into its string representation (rwxrwxrwx)
std::string tools_strerror_r(int errnum)
wrapper routine to strerror_r
std::vector< std::string > tools_split_in_words(generic_file &f)
read a file and split its contents into words
switch module to limitint (32 ou 64 bits integers) or infinint
std::string::iterator 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
std::string tools_get_hostname()
return a string containing the hostname of the current host
std::string tools_unsigned_char_to_hexa(unsigned char x)
convert a unsigned char into its hexa decima representation
void tools_make_date(const std::string &chemin, bool symlink, const datetime &access, const datetime &modif, const datetime &birth)
set dates of a given file, may throw exception
std::string tools_get_date_utc()
return a string containing the current time (UTC)
std::string tools_output2xml(const std::string &src)
convert string for xml output
exception used to signal range error
Definition: erreurs.hpp:179
std::string tools_int2octal(const U_I &perm)
convert a number to a string corresponding to its octal representation
class secu_string
Definition: secu_string.hpp:57
void tools_memxor(void *dest, const void *src, U_I n)
Produces in "dest" the XORed value of "dest" and "src".
U_I tools_str2int(const std::string &x)
convert an integer written in decimal notation to the corresponding value
this file contains the definition of class datetime that stores unix times in a portable way ...
this is the interface class from which all other data transfer classes inherit
void tools_check_basename(user_interaction &dialog, const path &loc, std::string &base, const std::string &extension, memory_pool *pool=nullptr)
does sanity checks on a slice name, check presence and detect whether the given basename is not rathe...
std::string tools_readlink(const char *root)
returns the file pointed to by a symbolic link (or transparent if the file is not a symlink)...
void 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
infinint tools_get_filesize(const path &p)
retrieve the size in byte of a file
void tools_system_with_pipe(user_interaction &dialog, const std::string &dar_cmd, const std::vector< std::string > &argvpipe, memory_pool *pool=nullptr)
wrapper to the "system" system call using anonymous pipe to tranmit arguments to the child process ...
std::string tools_concat_vector(const std::string &separator, const std::vector< std::string > &x)
concatenate a vectors of strings in a single string
U_I tools_pseudo_random(U_I max)
Produces a pseudo random number x, where 0 <= x < max.
uid_t tools_ownership2uid(const std::string &user)
change ownership of the file which descriptor is given
std::string tools_vprintf(const char *format, va_list ap)
make printf-like formating to a std::string
std::string tools_get_compression_ratio(const infinint &storage_size, const infinint &file_size, bool compressed)
return the string about compression ratio
List of Generic Type Length Value data structures.
std::string 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
void tools_secu_string_show(user_interaction &dialog, const std::string &msg, const secu_string &key)
display the content of a secu_string, this function is only for trouble shooting! ...
char * tools_str2charptr(const std::string &x)
convert a string to a char *
void tools_check_negative_date(T &val, user_interaction &ui, const char *inode_path, const char *nature, bool ask_before, bool silent)
check the value is not negative, and if asked set it to zero
Definition: tools.hpp:902
void tools_system(user_interaction &dialog, const std::vector< std::string > &argvector)
wrapper to the "system" system call.
the arbitrary large positive integer class
bool tools_my_atoi(const char *a, U_I &val)
ascii to integer conversion
U_I tools_count_in_string(const std::string &s, const char a)
counts the number of a given char in a given string
void tools_avoid_slice_overwriting_regex(user_interaction &dialog, const path &chemin, const std::string &basename, const std::string &extension, 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 ...
void tools_set_ownership(S_I filedesc, const std::string &slice_user, const std::string &slice_group)
change ownership of the file which descriptor is given
std::string tools_display_integer_in_metric_system(infinint number, const std::string &unit, bool binary)
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
void tools_block_all_signals(sigset_t &old_mask)
block all signals (based on POSIX sigprocmask)
void tools_merge_to_vector(std::vector< std::string > &a, const std::vector< std::string > &b)
add in &#39;a&#39;, element of &#39;b&#39; not already found in &#39;a&#39;
U_I tools_get_permission(S_I fd)
obtain the permission of the file which descriptor is given
the class path is here to manipulate paths in the Unix notation: using&#39;/&#39;
Definition: path.hpp:50
bool tools_are_on_same_filesystem(const std::string &file1, const std::string &file2)
void tools_hook_execute(user_interaction &ui, const std::string &cmd_line)
execute and retries at user will a given command line