32 #include "../my_config.h"
88 void clear() { num_x = num_d = num_f = num_c = num_b = num_p
89 = num_s = num_l = num_D = num_hard_linked_inodes
90 = num_hard_link_entries = saved = total = 0; };
91 void add(
const entree *ref);
102 std::map <infinint, etoile *> & corres,
139 virtual unsigned char signature()
const = 0;
140 virtual entree *clone()
const = 0;
147 virtual void inherited_dump(
generic_file & f,
bool small)
const;
151 static const U_I ENTREE_CRC_SIZE;
155 extern bool compatible_signature(
unsigned char a,
unsigned char b);
156 extern unsigned char mk_signature(
unsigned char base, saved_status state);
165 unsigned char signature()
const {
return 'z'; };
166 entree *clone()
const {
return new eod(); };
176 nomme(
const std::string & name) { xname = name; };
178 virtual bool operator == (
const nomme & ref)
const {
return xname == ref.xname; };
179 virtual bool operator < (
const nomme & ref)
const {
return xname < ref.xname; };
181 const std::string & get_name()
const {
return xname; };
182 void change_name(
const std::string & x) { xname = x; };
183 bool same_as(
const nomme & ref)
const {
return xname == ref.xname; };
189 #ifdef LIBDAR_SPECIAL_ALLOC
190 USE_SPECIAL_ALLOC(
nomme);
194 void inherited_dump(
generic_file & f,
bool small)
const;
231 const infinint & get_uid()
const {
return uid; };
232 const infinint & get_gid()
const {
return gid; };
233 U_16 get_perm()
const {
return perm; };
234 infinint get_last_access()
const {
return *last_acc; };
235 infinint get_last_modif()
const {
return *last_mod; };
236 void set_last_access(
const infinint & x_time) { *last_acc = x_time; };
237 void set_last_modif(
const infinint & x_time) { *last_mod = x_time; };
238 saved_status get_saved_status()
const {
return xsaved; };
239 void set_saved_status(saved_status x) { xsaved = x; };
240 infinint get_device()
const {
return *fs_dev; };
242 bool same_as(
const inode & ref)
const;
243 bool is_more_recent_than(
const inode & ref,
const infinint & hourshift)
const;
245 virtual bool has_changed_since(
const inode & ref,
const infinint & hourshift,
comparison_fields what_to_check)
const;
249 void compare(
const inode &other,
250 const mask & ea_mask,
252 const infinint & hourshift,
253 bool symlink_date)
const;
267 enum ea_status { ea_none, ea_partial, ea_fake, ea_full, ea_removed };
275 void ea_set_saved_status(ea_status status);
276 ea_status ea_get_saved_status()
const {
return ea_saved; };
279 void ea_attach(ea_attributs *ref);
280 const ea_attributs *get_ea()
const;
281 void ea_detach()
const;
282 infinint ea_get_size()
const;
285 void ea_set_offset(
const infinint & pos) { *ea_offset = pos; };
286 void ea_set_crc(
const crc & val) { crc::set_crc_pointer(ea_crc, &val); };
287 void ea_get_crc(crc & val)
const;
288 bool ea_get_crc_size(infinint & val)
const;
291 infinint get_last_change()
const;
292 void set_last_change(
const infinint & x_time);
293 bool has_last_change()
const {
return last_cha != NULL; };
301 void change_ea_location(generic_file *loc) { storage = loc; };
305 #ifdef LIBDAR_SPECIAL_ALLOC
306 USE_SPECIAL_ALLOC(inode);
310 virtual void sub_compare(
const inode & other)
const {};
315 void inherited_dump(
generic_file & f,
bool small)
const;
352 const etoile & operator = (
const etoile & ref) {
throw SRC_BUG; };
353 ~
etoile() {
delete hosted; };
355 void add_ref(
void *ref);
356 void drop_ref(
void *ref);
357 infinint get_ref_count()
const {
return refs.size(); };
358 inode *get_inode()
const {
return hosted; };
359 infinint get_etiquette()
const {
return etiquette; };
360 void change_etiquette(
const infinint & new_val) { etiquette = new_val; };
363 bool is_counted()
const {
return tags.counted; };
364 bool is_wrote()
const {
return tags.wrote; };
365 bool is_dumped()
const {
return tags.dumped; };
366 void set_counted(
bool val) { tags.counted = val ? 1 : 0; };
367 void set_wrote(
bool val) { tags.wrote = val ? 1 : 0; };
368 void set_dumped(
bool val) { tags.dumped = val ? 1 : 0; };
372 const void *get_first_ref()
const {
if(refs.size() == 0)
throw SRC_BUG;
return refs.front(); };
374 #ifdef LIBDAR_SPECIAL_ALLOC
375 USE_SPECIAL_ALLOC(
etoile);
381 unsigned counted : 1;
386 bool_tags() { counted = wrote = dumped = 0; };
389 std::list<void *> refs;
401 enum mirage_format {fmt_mirage,
403 fmt_file_etiquette };
405 mirage(
const std::string & name,
etoile *ref) :
nomme(name) { star_ref = ref;
if(ref == NULL)
throw SRC_BUG; star_ref->add_ref(
this); };
411 std::map <infinint, etoile *> & corres,
423 std::map <infinint, etoile *> & corres,
429 mirage(
const mirage & ref) :
nomme (ref) { star_ref = ref.star_ref;
if(star_ref == NULL)
throw SRC_BUG; star_ref->add_ref(
this); };
431 ~
mirage() { star_ref->drop_ref(
this); };
433 unsigned char signature()
const {
return 'm'; };
436 inode *get_inode()
const {
if(star_ref == NULL)
throw SRC_BUG;
return star_ref->get_inode(); };
437 infinint get_etiquette()
const {
return star_ref->get_etiquette(); };
438 infinint get_etoile_ref_count()
const {
return star_ref->get_ref_count(); };
439 etoile *get_etoile()
const {
return star_ref; };
441 bool is_inode_counted()
const {
return star_ref->is_counted(); };
442 bool is_inode_wrote()
const {
return star_ref->is_wrote(); };
443 bool is_inode_dumped()
const {
return star_ref->is_dumped(); };
444 void set_inode_counted(
bool val)
const { star_ref->set_counted(val); };
445 void set_inode_wrote(
bool val)
const { star_ref->set_wrote(val); };
446 void set_inode_dumped(
bool val)
const { star_ref->set_dumped(val); };
453 #ifdef LIBDAR_SPECIAL_ALLOC
454 USE_SPECIAL_ALLOC(
mirage);
458 void inherited_dump(
generic_file & f,
bool small)
const;
468 std::map <infinint, etoile *> & corres,
490 static const U_8 FILE_DATA_WITH_HOLE = 0x01;
491 static const U_8 FILE_DATA_IS_DIRTY = 0x02;
497 const std::string & src,
501 bool x_furtive_read_mode);
514 infinint get_size()
const {
return *size; };
515 infinint get_storage_size()
const {
return *storage_size; };
516 void set_storage_size(
const infinint & s) { *storage_size = s; };
517 virtual generic_file *get_data(get_data_mode mode)
const;
519 void set_offset(
const infinint & r);
520 const infinint & get_offset()
const;
521 unsigned char signature()
const {
return mk_signature(
'f', get_saved_status()); };
523 void set_crc(
const crc &c) { crc::set_crc_pointer(check, &c); };
524 bool get_crc(crc & c)
const;
525 bool has_crc()
const {
return check != NULL; };
526 bool get_crc_size(
infinint & val)
const;
527 void drop_crc() {
if(check != NULL) {
delete check; check = NULL; } };
530 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; };
532 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; };
535 bool get_sparse_file_detection_read()
const {
return (file_data_status_read & FILE_DATA_WITH_HOLE) != 0; };
536 bool get_sparse_file_detection_write()
const {
return (file_data_status_write & FILE_DATA_WITH_HOLE) != 0; };
538 entree *clone()
const {
return new file(*
this); };
540 compression get_compression_algo_read()
const {
return algo_read; };
542 compression get_compression_algo_write()
const {
return algo_write; };
545 void change_compression_algo_write(
compression x) { algo_write = x; };
550 bool is_dirty()
const {
return dirty; };
551 void set_dirty(
bool value) { dirty = value; };
553 #ifdef LIBDAR_SPECIAL_ALLOC
554 USE_SPECIAL_ALLOC(
file);
558 void sub_compare(
const inode & other)
const;
559 void inherited_dump(
generic_file & f,
bool small)
const;
562 enum { empty, from_path, from_cat } status;
575 bool furtive_read_mode;
576 char file_data_status_read;
577 char file_data_status_write;
590 const std::string & src,
592 const infinint & fs_device) :
file(xuid, xgid, xperm, last_access, last_modif,
593 last_change, src, che, 0, fs_device,
false) {};
601 escape *ptr) :
file(dialog, f, reading_ver, saved, default_algo, data_loc, ea_loc, ptr) {};
603 unsigned char signature()
const {
return mk_signature(
'o', get_saved_status()); };
616 const std::string & name,
617 const std::string & target,
626 const std::string & get_target()
const;
627 void set_target(std::string x);
631 unsigned char signature()
const {
return mk_signature(
'l', get_saved_status()); };
632 entree *clone()
const {
return new lien(*
this); };
634 #ifdef LIBDAR_SPECIAL_ALLOC
635 USE_SPECIAL_ALLOC(
lien);
638 void sub_compare(
const inode & other)
const;
639 void inherited_dump(
generic_file & f,
bool small)
const;
643 std::string points_to;
654 const std::string & xname,
663 std::map <infinint, etoile *> & corres,
672 void add_children(
nomme *r);
673 bool has_children()
const {
return !fils.empty(); };
674 void reset_read_children()
const;
675 void end_read()
const;
676 bool read_children(
const nomme * &r)
const;
678 void tail_to_read_children();
680 void remove(
const std::string & name);
683 directory * get_parent()
const {
return parent; };
684 bool search_children(
const std::string &name,
nomme *&ref);
685 bool callback_for_children_of(
user_interaction & dialog,
const std::string & sdir,
bool isolated =
false)
const;
689 unsigned char signature()
const {
return mk_signature(
'd', get_saved_status()); };
692 bool get_recursive_has_changed()
const {
return recursive_has_changed; };
694 void recursive_has_changed_update()
const;
701 infinint get_tree_mirage_num()
const;
705 void get_etiquettes_found_in_tree(std::map<infinint, infinint> & already_found)
const;
708 bool is_empty()
const {
return fils.empty(); };
711 void remove_all_mirages_and_reduce_dirs();
715 #ifdef LIBDAR_SPECIAL_ALLOC
720 void inherited_dump(
generic_file & f,
bool small)
const;
723 static const eod fin;
726 std::map<std::string, nomme *> fils;
727 std::list<nomme *> ordered_fils;
728 std::list<nomme *>::iterator it;
729 bool recursive_has_changed;
742 const std::string & name,
753 int get_major()
const {
if(get_saved_status() != s_saved)
throw SRC_BUG;
else return xmajor; };
754 int get_minor()
const {
if(get_saved_status() != s_saved)
throw SRC_BUG;
else return xminor; };
755 void set_major(
int x) { xmajor = x; };
756 void set_minor(
int x) { xminor = x; };
762 #ifdef LIBDAR_SPECIAL_ALLOC
763 USE_SPECIAL_ALLOC(
device);
767 void sub_compare(
const inode & other)
const;
768 void inherited_dump(
generic_file & f,
bool small)
const;
782 const std::string & name,
790 major, minor, fs_device) {};
796 escape *ptr) :
device(dialog, f, reading_ver, saved, ea_loc, ptr) {};
801 unsigned char signature()
const {
return mk_signature(
'c', get_saved_status()); };
804 #ifdef LIBDAR_SPECIAL_ALLOC
817 const std::string & name,
821 last_modif, last_change, name,
822 major, minor, fs_device) {};
828 escape *ptr) :
device(dialog, f, reading_ver, saved, ea_loc, ptr) {};
833 unsigned char signature()
const {
return mk_signature(
'b', get_saved_status()); };
836 #ifdef LIBDAR_SPECIAL_ALLOC
849 const std::string & xname,
850 const infinint & fs_device) :
inode(xuid, xgid, xperm, last_access, last_modif, last_change, xname, fs_device) { set_saved_status(s_saved); };
856 escape *ptr) :
inode(dialog, f, reading_ver, saved, ea_loc, ptr) {};
861 unsigned char signature()
const {
return mk_signature(
'p', get_saved_status()); };
862 entree *clone()
const {
return new tube(*
this); };
864 #ifdef LIBDAR_SPECIAL_ALLOC
865 USE_SPECIAL_ALLOC(
tube);
877 const std::string & xname,
878 const infinint & fs_device) :
inode(xuid, xgid, xperm, last_access, last_modif, last_change, xname, fs_device) { set_saved_status(s_saved); };
884 escape *ptr) :
inode(dialog, f, reading_ver, saved, ea_loc, ptr) {};
889 unsigned char signature()
const {
return mk_signature(
's', get_saved_status()); };
890 entree *clone()
const {
return new prise(*
this); };
892 #ifdef LIBDAR_SPECIAL_ALLOC
893 USE_SPECIAL_ALLOC(
prise);
901 detruit(
const std::string & name,
unsigned char firm,
const infinint & date) :
nomme(name) , del_date(date) { signe = firm; };
903 detruit(
const nomme &ref) :
nomme(ref.get_name()), del_date(0) { signe = ref.signature(); };
905 unsigned char get_signature()
const {
return signe; };
906 void set_signature(
unsigned char x) { signe = x; };
907 unsigned char signature()
const {
return 'x'; };
910 const infinint & get_date()
const {
return del_date; };
911 void set_date(
const infinint & ref) { del_date = ref; };
913 #ifdef LIBDAR_SPECIAL_ALLOC
917 void inherited_dump(
generic_file & f,
bool small)
const;
931 unsigned char signature()
const {
return 'i'; };
933 #ifdef LIBDAR_SPECIAL_ALLOC
938 void inherited_dump(
generic_file & f,
bool small)
const {
throw SRC_BUG; };
951 escape *ptr) :
inode(dialog, f, reading_ver, s_not_saved, ea_loc, ptr) {
throw SRC_BUG; };
953 unsigned char signature()
const {
return 'j'; };
955 #ifdef LIBDAR_SPECIAL_ALLOC
960 void inherited_dump(
generic_file & f,
bool small)
const;
970 const label & data_name);
978 const label & lax_layer1_data_name,
979 bool only_detruit =
false);
987 virtual void reset_read()
const;
988 virtual void end_read()
const;
989 virtual void skip_read_to_parent_dir()
const;
992 virtual bool read(
const entree * & ref)
const;
994 virtual bool read_if_present(std::string *name,
const nomme * & ref)
const;
999 void remove_read_entry(std::string & name);
1001 const directory & get_current_reading_dir()
const {
return *current_read; };
1004 void tail_catalogue_to_current_read();
1007 void reset_sub_read(
const path &sub);
1008 bool sub_read(
const entree * &ref);
1017 virtual bool read_second_time_dir()
const {
return false; };
1028 virtual void pre_add_crc(
const entree *ref, compressor *compr)
const {};
1029 virtual void pre_add_dirty(compressor *compr)
const {};
1030 virtual void pre_add_ea_crc(
const entree *ref, compressor *compr)
const {};
1031 virtual void pre_add_waste_mark(compressor *compr)
const {};
1032 virtual void pre_add_failed_mark(compressor *compr)
const {};
1033 virtual escape *get_escape_layer()
const {
return NULL; };
1035 void add(entree *ref);
1036 void re_add_in(
const std::string &subdirname);
1037 void re_add_in_replace(
const directory &dir);
1038 void add_in_current_read(nomme *ref);
1044 void reset_compare();
1045 bool compare(
const entree * name,
const entree * & extracted);
1062 bool direct_read(
const path & ref,
const nomme * &ret);
1063 infinint update_destroyed_with(catalogue & ref);
1066 void update_absent_with(catalogue & ref, infinint aborting_next_etoile);
1071 void dump(generic_file & f)
const;
1072 void listing(
bool isolated,
1073 const mask &selection,
1074 const mask & subtree,
1075 bool filter_unsaved,
1077 std::string marge)
const;
1078 void tar_listing(
bool isolated,
1079 const mask & selection,
1080 const mask & subtree,
1081 bool filter_unsaved,
1083 std::string beginning)
const;
1084 void xml_listing(
bool isolated,
1085 const mask & selection,
1086 const mask & subtree,
1087 bool filter_unsaved,
1089 std::string beginning)
const;
1091 entree_stats get_stats()
const {
return stats; };
1094 bool is_empty()
const {
if(contenu == NULL)
throw SRC_BUG;
return contenu->is_empty(); };
1096 const directory *get_contenu()
const {
return contenu; };
1098 const label & get_data_name()
const {
return ref_data_name; };
1099 infinint get_root_dir_last_modif()
const {
return contenu->get_last_modif(); };
1104 infinint get_root_mtime()
const {
return contenu->get_last_modif(); };
1109 #ifdef LIBDAR_SPECIAL_ALLOC
1110 USE_SPECIAL_ALLOC(catalogue);
1114 entree_stats & access_stats() {
return stats; };
1115 void set_data_name(
const label & val) { ref_data_name = val; };
1116 void copy_detruits_from(
const catalogue & ref);
1118 const eod * get_r_eod_address()
const {
return & r_eod; };
1130 directory *current_compare;
1131 directory *current_add;
1132 directory *current_read;
1134 signed int sub_count;
1136 label ref_data_name;
1138 void partial_copy_from(
const catalogue &ref);
1141 static const eod r_eod;
1142 static const U_I CAT_CRC_SIZE;