29 #include "../my_config.h" 86 void clear() { num_x = num_d = num_f = num_c = num_b = num_p
87 = num_s = num_l = num_D = num_hard_linked_inodes
88 = num_hard_link_entries = saved = total = 0; };
89 void add(
const entree *ref);
100 std::map <infinint, etoile *> & corres,
137 virtual unsigned char signature()
const = 0;
138 virtual entree *clone()
const = 0;
140 #ifdef LIBDAR_SPECIAL_ALLOC 141 USE_SPECIAL_ALLOC(
entree);
145 virtual void inherited_dump(
generic_file & f,
bool small)
const;
149 static const U_I ENTREE_CRC_SIZE;
153 extern bool compatible_signature(
unsigned char a,
unsigned char b);
154 extern unsigned char mk_signature(
unsigned char base, saved_status state);
155 extern unsigned char get_base_signature(
unsigned char a);
164 unsigned char signature()
const {
return 'z'; };
165 entree *clone()
const {
return new (std::nothrow)
eod(); };
168 #ifdef LIBDAR_SPECIAL_ALLOC 169 USE_SPECIAL_ALLOC(
eod);
177 nomme(
const std::string & name) { xname = name; };
179 virtual bool operator == (
const nomme & ref)
const {
return xname == ref.xname; };
180 virtual bool operator < (
const nomme & ref)
const {
return xname < ref.xname; };
182 const std::string & get_name()
const {
return xname; };
183 void change_name(
const std::string & x) { xname = x; };
184 bool same_as(
const nomme & ref)
const {
return xname == ref.xname; };
190 #ifdef LIBDAR_SPECIAL_ALLOC 191 USE_SPECIAL_ALLOC(
nomme);
195 void inherited_dump(
generic_file & f,
bool small)
const;
232 const infinint & get_uid()
const {
return uid; };
233 const infinint & get_gid()
const {
return gid; };
234 U_16 get_perm()
const {
return perm; };
235 infinint get_last_access()
const {
return *last_acc; };
236 infinint get_last_modif()
const {
return *last_mod; };
237 void set_last_access(
const infinint & x_time) { *last_acc = x_time; };
238 void set_last_modif(
const infinint & x_time) { *last_mod = x_time; };
239 saved_status get_saved_status()
const {
return xsaved; };
240 void set_saved_status(saved_status x) { xsaved = x; };
241 infinint get_device()
const {
return *fs_dev; };
243 bool same_as(
const inode & ref)
const;
244 bool is_more_recent_than(
const inode & ref,
const infinint & hourshift)
const;
250 void compare(
const inode &other,
251 const mask & ea_mask,
254 bool symlink_date)
const;
268 enum ea_status { ea_none, ea_partial, ea_fake, ea_full, ea_removed };
276 void ea_set_saved_status(ea_status status);
277 ea_status ea_get_saved_status()
const {
return ea_saved; };
282 void ea_detach()
const;
286 void ea_set_offset(
const infinint & pos) { *ea_offset = pos; };
287 void ea_set_crc(
const crc & val);
288 void ea_get_crc(
const crc * & ptr)
const;
289 bool ea_get_crc_size(
infinint & val)
const;
293 void set_last_change(
const infinint & x_time);
294 bool has_last_change()
const {
return last_cha != NULL; };
306 #ifdef LIBDAR_SPECIAL_ALLOC 307 USE_SPECIAL_ALLOC(
inode);
311 virtual void sub_compare(
const inode & other)
const {};
316 void inherited_dump(
generic_file & f,
bool small)
const;
353 const etoile & operator = (
const etoile & ref) {
throw SRC_BUG; };
354 ~
etoile() {
delete hosted; };
356 void add_ref(
void *ref);
357 void drop_ref(
void *ref);
358 infinint get_ref_count()
const {
return refs.size(); };
359 inode *get_inode()
const {
return hosted; };
360 infinint get_etiquette()
const {
return etiquette; };
361 void change_etiquette(
const infinint & new_val) { etiquette = new_val; };
364 bool is_counted()
const {
return tags.counted; };
365 bool is_wrote()
const {
return tags.wrote; };
366 bool is_dumped()
const {
return tags.dumped; };
367 void set_counted(
bool val) { tags.counted = val ? 1 : 0; };
368 void set_wrote(
bool val) { tags.wrote = val ? 1 : 0; };
369 void set_dumped(
bool val) { tags.dumped = val ? 1 : 0; };
373 const void *get_first_ref()
const {
if(refs.size() == 0)
throw SRC_BUG;
return refs.front(); };
375 #ifdef LIBDAR_SPECIAL_ALLOC 376 USE_SPECIAL_ALLOC(
etoile);
382 unsigned counted : 1;
387 bool_tags() { counted = wrote = dumped = 0; };
390 std::list<void *> refs;
402 enum mirage_format {fmt_mirage,
404 fmt_file_etiquette };
406 mirage(
const std::string & name,
etoile *ref) :
nomme(name) { star_ref = ref;
if(ref == NULL)
throw SRC_BUG; star_ref->add_ref(
this); };
412 std::map <infinint, etoile *> & corres,
424 std::map <infinint, etoile *> & corres,
430 mirage(
const mirage & ref) :
nomme (ref) { star_ref = ref.star_ref;
if(star_ref == NULL)
throw SRC_BUG; star_ref->add_ref(
this); };
432 ~
mirage() { star_ref->drop_ref(
this); };
434 unsigned char signature()
const {
return 'm'; };
435 entree *clone()
const {
return new (std::nothrow)
mirage(*
this); };
437 inode *get_inode()
const {
if(star_ref == NULL)
throw SRC_BUG;
return star_ref->get_inode(); };
438 infinint get_etiquette()
const {
return star_ref->get_etiquette(); };
439 infinint get_etoile_ref_count()
const {
return star_ref->get_ref_count(); };
440 etoile *get_etoile()
const {
return star_ref; };
442 bool is_inode_counted()
const {
return star_ref->is_counted(); };
443 bool is_inode_wrote()
const {
return star_ref->is_wrote(); };
444 bool is_inode_dumped()
const {
return star_ref->is_dumped(); };
445 void set_inode_counted(
bool val)
const { star_ref->set_counted(val); };
446 void set_inode_wrote(
bool val)
const { star_ref->set_wrote(val); };
447 void set_inode_dumped(
bool val)
const { star_ref->set_dumped(val); };
454 #ifdef LIBDAR_SPECIAL_ALLOC 455 USE_SPECIAL_ALLOC(
mirage);
459 void inherited_dump(
generic_file & f,
bool small)
const;
469 std::map <infinint, etoile *> & corres,
491 static const U_8 FILE_DATA_WITH_HOLE = 0x01;
492 static const U_8 FILE_DATA_IS_DIRTY = 0x02;
498 const std::string & src,
502 bool x_furtive_read_mode);
515 infinint get_size()
const {
return *size; };
516 void change_size(
const infinint & s)
const { *size = s; };
517 infinint get_storage_size()
const {
return *storage_size; };
518 void set_storage_size(
const infinint & s) { *storage_size = s; };
519 virtual generic_file *get_data(get_data_mode mode)
const;
521 void set_offset(
const infinint & r);
522 const infinint & get_offset()
const;
523 unsigned char signature()
const {
return mk_signature(
'f', get_saved_status()); };
525 void set_crc(
const crc &c);
526 bool get_crc(
const crc * & c)
const;
527 bool has_crc()
const {
return check != NULL; };
528 bool get_crc_size(
infinint & val)
const;
529 void drop_crc() {
if(check != NULL) {
delete check; check = NULL; } };
532 void set_sparse_file_detection_read(
bool val) {
if(status == from_cat)
throw SRC_BUG;
if(val) file_data_status_read |= FILE_DATA_WITH_HOLE;
else file_data_status_read &= ~FILE_DATA_WITH_HOLE; };
534 void set_sparse_file_detection_write(
bool val) {
if(val) file_data_status_write |= FILE_DATA_WITH_HOLE;
else file_data_status_write &= ~FILE_DATA_WITH_HOLE; };
537 bool get_sparse_file_detection_read()
const {
return (file_data_status_read & FILE_DATA_WITH_HOLE) != 0; };
538 bool get_sparse_file_detection_write()
const {
return (file_data_status_write & FILE_DATA_WITH_HOLE) != 0; };
540 entree *clone()
const {
return new (std::nothrow)
file(*
this); };
542 compression get_compression_algo_read()
const {
return algo_read; };
544 compression get_compression_algo_write()
const {
return algo_write; };
547 void change_compression_algo_write(
compression x) { algo_write = x; };
552 bool is_dirty()
const {
return dirty; };
553 void set_dirty(
bool value) { dirty = value; };
555 #ifdef LIBDAR_SPECIAL_ALLOC 556 USE_SPECIAL_ALLOC(
file);
560 void sub_compare(
const inode & other)
const;
561 void inherited_dump(
generic_file & f,
bool small)
const;
564 enum { empty, from_path, from_cat } status;
577 bool furtive_read_mode;
578 char file_data_status_read;
579 char file_data_status_write;
592 const std::string & src,
594 const infinint & fs_device) :
file(xuid, xgid, xperm, last_access, last_modif,
595 last_change, src, che, 0, fs_device,
false) {};
603 escape *ptr) :
file(dialog, f, reading_ver, saved, default_algo, data_loc, ea_loc, ptr) {};
605 unsigned char signature()
const {
return mk_signature(
'o', get_saved_status()); };
609 #ifdef LIBDAR_SPECIAL_ALLOC 610 USE_SPECIAL_ALLOC(
door);
622 const std::string & name,
623 const std::string & target,
632 const std::string & get_target()
const;
633 void set_target(std::string x);
637 unsigned char signature()
const {
return mk_signature(
'l', get_saved_status()); };
638 entree *clone()
const {
return new (std::nothrow)
lien(*
this); };
640 #ifdef LIBDAR_SPECIAL_ALLOC 641 USE_SPECIAL_ALLOC(
lien);
644 void sub_compare(
const inode & other)
const;
645 void inherited_dump(
generic_file & f,
bool small)
const;
649 std::string points_to;
660 const std::string & xname,
669 std::map <infinint, etoile *> & corres,
678 void add_children(
nomme *r);
679 bool has_children()
const {
return !ordered_fils.empty(); };
680 void reset_read_children()
const;
681 void end_read()
const;
682 bool read_children(
const nomme * &r)
const;
684 void tail_to_read_children();
686 void remove(
const std::string & name);
689 directory * get_parent()
const {
return parent; };
690 bool search_children(
const std::string &name,
nomme *&ref);
691 bool callback_for_children_of(
user_interaction & dialog,
const std::string & sdir,
bool isolated =
false)
const;
695 unsigned char signature()
const {
return mk_signature(
'd', get_saved_status()); };
698 bool get_recursive_has_changed()
const {
return recursive_has_changed; };
700 void recursive_has_changed_update()
const;
709 infinint get_tree_mirage_num()
const;
714 void get_etiquettes_found_in_tree(std::map<infinint, infinint> & already_found)
const;
717 bool is_empty()
const {
return ordered_fils.empty(); };
720 void remove_all_mirages_and_reduce_dirs();
723 void recursive_set_mirage_inode_wrote(
bool val);
727 #ifdef LIBDAR_SPECIAL_ALLOC 732 void inherited_dump(
generic_file & f,
bool small)
const;
735 static const eod fin;
738 #ifdef LIBDAR_FAST_DIR 739 std::map<std::string, nomme *> fils;
741 std::list<nomme *> ordered_fils;
742 std::list<nomme *>::iterator it;
743 bool recursive_has_changed;
756 const std::string & name,
767 int get_major()
const {
if(get_saved_status() != s_saved)
throw SRC_BUG;
else return xmajor; };
768 int get_minor()
const {
if(get_saved_status() != s_saved)
throw SRC_BUG;
else return xminor; };
769 void set_major(
int x) { xmajor = x; };
770 void set_minor(
int x) { xminor = x; };
776 #ifdef LIBDAR_SPECIAL_ALLOC 777 USE_SPECIAL_ALLOC(
device);
781 void sub_compare(
const inode & other)
const;
782 void inherited_dump(
generic_file & f,
bool small)
const;
796 const std::string & name,
804 major, minor, fs_device) {};
810 escape *ptr) :
device(dialog, f, reading_ver, saved, ea_loc, ptr) {};
815 unsigned char signature()
const {
return mk_signature(
'c', get_saved_status()); };
816 entree *clone()
const {
return new (std::nothrow)
chardev(*
this); };
818 #ifdef LIBDAR_SPECIAL_ALLOC 831 const std::string & name,
835 last_modif, last_change, name,
836 major, minor, fs_device) {};
842 escape *ptr) :
device(dialog, f, reading_ver, saved, ea_loc, ptr) {};
847 unsigned char signature()
const {
return mk_signature(
'b', get_saved_status()); };
848 entree *clone()
const {
return new (std::nothrow)
blockdev(*
this); };
850 #ifdef LIBDAR_SPECIAL_ALLOC 863 const std::string & xname,
864 const infinint & fs_device) :
inode(xuid, xgid, xperm, last_access, last_modif, last_change, xname, fs_device) { set_saved_status(s_saved); };
870 escape *ptr) :
inode(dialog, f, reading_ver, saved, ea_loc, ptr) {};
875 unsigned char signature()
const {
return mk_signature(
'p', get_saved_status()); };
876 entree *clone()
const {
return new (std::nothrow)
tube(*
this); };
878 #ifdef LIBDAR_SPECIAL_ALLOC 879 USE_SPECIAL_ALLOC(
tube);
891 const std::string & xname,
892 const infinint & fs_device) :
inode(xuid, xgid, xperm, last_access, last_modif, last_change, xname, fs_device) { set_saved_status(s_saved); };
898 escape *ptr) :
inode(dialog, f, reading_ver, saved, ea_loc, ptr) {};
903 unsigned char signature()
const {
return mk_signature(
's', get_saved_status()); };
904 entree *clone()
const {
return new (std::nothrow)
prise(*
this); };
906 #ifdef LIBDAR_SPECIAL_ALLOC 907 USE_SPECIAL_ALLOC(
prise);
915 detruit(
const std::string & name,
unsigned char firm,
const infinint & date) :
nomme(name) , del_date(date) { signe = firm; };
917 detruit(
const nomme &ref) :
nomme(ref.get_name()), del_date(0) { signe = ref.signature(); };
919 unsigned char get_signature()
const {
return signe; };
920 void set_signature(
unsigned char x) { signe = x; };
921 unsigned char signature()
const {
return 'x'; };
922 entree *clone()
const {
return new (std::nothrow)
detruit(*
this); };
924 const infinint & get_date()
const {
return del_date; };
925 void set_date(
const infinint & ref) { del_date = ref; };
927 #ifdef LIBDAR_SPECIAL_ALLOC 931 void inherited_dump(
generic_file & f,
bool small)
const;
945 unsigned char signature()
const {
return 'i'; };
946 entree *clone()
const {
return new (std::nothrow)
ignored(*
this); };
947 #ifdef LIBDAR_SPECIAL_ALLOC 952 void inherited_dump(
generic_file & f,
bool small)
const {
throw SRC_BUG; };
965 escape *ptr) :
inode(dialog, f, reading_ver, s_not_saved, ea_loc, ptr) {
throw SRC_BUG; };
967 unsigned char signature()
const {
return 'j'; };
969 #ifdef LIBDAR_SPECIAL_ALLOC 974 void inherited_dump(
generic_file & f,
bool small)
const;
984 const label & data_name);
992 const label & lax_layer1_data_name,
993 bool only_detruit =
false);
1001 virtual void reset_read()
const;
1002 virtual void end_read()
const;
1003 virtual void skip_read_to_parent_dir()
const;
1006 virtual bool read(
const entree * & ref)
const;
1008 virtual bool read_if_present(std::string *name,
const nomme * & ref)
const;
1013 void remove_read_entry(std::string & name);
1015 const directory & get_current_reading_dir()
const {
return *current_read; };
1018 void tail_catalogue_to_current_read();
1021 void reset_sub_read(
const path &sub);
1022 bool sub_read(
const entree * &ref);
1031 virtual bool read_second_time_dir()
const {
return false; };
1043 virtual void pre_add_dirty(
compressor *compr)
const {};
1044 virtual void pre_add_ea_crc(
const entree *ref,
compressor *compr)
const {};
1045 virtual void pre_add_waste_mark(
compressor *compr)
const {};
1046 virtual void pre_add_failed_mark(
compressor *compr)
const {};
1047 virtual escape *get_escape_layer()
const {
return NULL; };
1050 void re_add_in(
const std::string &subdirname);
1051 void re_add_in_replace(
const directory &dir);
1052 void add_in_current_read(
nomme *ref);
1058 void reset_compare();
1059 bool compare(
const entree * name,
const entree * & extracted);
1076 bool direct_read(
const path & ref,
const nomme * &ret);
1086 void listing(
bool isolated,
1087 const mask &selection,
1088 const mask & subtree,
1089 bool filter_unsaved,
1091 std::string marge)
const;
1092 void tar_listing(
bool isolated,
1093 const mask & selection,
1094 const mask & subtree,
1095 bool filter_unsaved,
1097 std::string beginning)
const;
1098 void xml_listing(
bool isolated,
1099 const mask & selection,
1100 const mask & subtree,
1101 bool filter_unsaved,
1103 std::string beginning)
const;
1108 bool is_empty()
const {
if(contenu == NULL)
throw SRC_BUG;
return contenu->is_empty(); };
1110 const directory *get_contenu()
const {
return contenu; };
1112 const label & get_data_name()
const {
return ref_data_name; };
1113 infinint get_root_dir_last_modif()
const {
return contenu->get_last_modif(); };
1121 infinint get_root_mtime()
const {
return contenu->get_last_modif(); };
1129 void set_data_name(
const label & val) { ref_data_name = val; };
1130 void copy_detruits_from(
const catalogue & ref);
1132 const eod * get_r_eod_address()
const {
return & r_eod; };
1148 signed int sub_count;
1150 label ref_data_name;
1152 void partial_copy_from(
const catalogue &ref);
1155 static const eod r_eod;
1156 static const U_I CAT_CRC_SIZE;
the symbolic link inode class
the generic class, parent of all masks
are defined here basic integer types that tend to be portable
the catalogue class which gather all objects contained in a give archive
holds the statistics contents of a catalogue
virtual void post_constructor(generic_file &f)
called by entree::read and mirage::post_constructor, let inherited classes builds object's data after...
the Unix socket inode class
class generic_file is defined here as well as class fichierthe generic_file interface is widely used ...
define the datastructure "label" used to identify slice membership to an archive
virtual void pre_add(const entree *ref, compressor *compr) const
catalogue extension routines for escape sequence
bool is_empty() const
whether this directory is empty or not
void recursive_set_mirage_inode_wrote(bool val)
recursive setting of mirage inode_wrote flag
bool ea()
returns whether EA support has been activated at compilation time
This is a pure virtual class that is used by libdar when interaction with the user is required...
the present file to ignore (not to be recorded as deleted later)
the root class from all other inherite for any entry in the catalogue
the base class for all entry that have a name
the hard link implementation, mirage is the named entry owned by a directory it points to a common "e...
re-definition of new and delete class operatorthis is a set of macro that makes the new and delete op...
the directory inode class
comparison_fields
flag used to only consider certain fields when comparing/restoring inodes
the End of Directory entry class
the hard link implementation (etoile means star in French, seen a star as a point from which are thro...
defines the interaction between libdar and the user.Three classes are defined
here is the definition of the path classthe path class handle path and provide several operation on t...
the root class for all inode
the class for Door IPC (mainly for Solaris)
void launch_recursive_has_changed_update() const
recursive evaluation of directories that have changed (make the directory::get_recurisve_has_changed(...
class escape definition, used for sequential reading of archivesThe class escape is used to insert es...
arbitrary large storage structure
the special device root class
switch module to limitint (32 ou 64 bits integers) or infinint
here lies a collection of mask classes
compression class for gzip and bzip2 algorithms
compression
the different compression algorithm available
this is the interface class from which all other data transfer classes inherit
class mem_ui to keep a copy of a user_interaction object
bool is_empty() const
whether the catalogue is empty or not
compression engine implementation
bool is_first_mirage() const
whether we are the mirage that triggered this hard link creation
the arbitrary large positive integer class
class archive_version manages the version of the archive format
contains a set of routines to manage EA values associated to a file
escape * get_escape_layer() const
escape generic_file relative methods
the class ea_attributs manages the set of EA that can be associated to an inode
the ignored directory class, to be promoted later as empty directory if needed
libdar namespace encapsulate all libdar symbols
void specific_dump(generic_file &f, bool small) const
this call gives an access to inherited_dump
the class path is here to manipulate paths in the Unix notation: using'/'