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);
163 unsigned char signature()
const {
return 'z'; };
164 entree *clone()
const {
return new (std::nothrow)
eod(); };
167 #ifdef LIBDAR_SPECIAL_ALLOC
168 USE_SPECIAL_ALLOC(
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);
287 void ea_get_crc(
const crc * & ptr)
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'; };
434 entree *clone()
const {
return new (std::nothrow)
mirage(*
this); };
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 void change_size(
const infinint & s)
const { *size = s; };
516 infinint get_storage_size()
const {
return *storage_size; };
517 void set_storage_size(
const infinint & s) { *storage_size = s; };
518 virtual generic_file *get_data(get_data_mode mode)
const;
520 void set_offset(
const infinint & r);
521 const infinint & get_offset()
const;
522 unsigned char signature()
const {
return mk_signature(
'f', get_saved_status()); };
524 void set_crc(
const crc &c);
525 bool get_crc(
const crc * & c)
const;
526 bool has_crc()
const {
return check != NULL; };
527 bool get_crc_size(
infinint & val)
const;
528 void drop_crc() {
if(check != NULL) {
delete check; check = NULL; } };
531 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; };
533 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; };
536 bool get_sparse_file_detection_read()
const {
return (file_data_status_read & FILE_DATA_WITH_HOLE) != 0; };
537 bool get_sparse_file_detection_write()
const {
return (file_data_status_write & FILE_DATA_WITH_HOLE) != 0; };
539 entree *clone()
const {
return new (std::nothrow)
file(*
this); };
541 compression get_compression_algo_read()
const {
return algo_read; };
543 compression get_compression_algo_write()
const {
return algo_write; };
546 void change_compression_algo_write(
compression x) { algo_write = x; };
551 bool is_dirty()
const {
return dirty; };
552 void set_dirty(
bool value) { dirty = value; };
554 #ifdef LIBDAR_SPECIAL_ALLOC
555 USE_SPECIAL_ALLOC(
file);
559 void sub_compare(
const inode & other)
const;
560 void inherited_dump(
generic_file & f,
bool small)
const;
563 enum { empty, from_path, from_cat } status;
576 bool furtive_read_mode;
577 char file_data_status_read;
578 char file_data_status_write;
591 const std::string & src,
593 const infinint & fs_device) :
file(xuid, xgid, xperm, last_access, last_modif,
594 last_change, src, che, 0, fs_device,
false) {};
602 escape *ptr) :
file(dialog, f, reading_ver, saved, default_algo, data_loc, ea_loc, ptr) {};
604 unsigned char signature()
const {
return mk_signature(
'o', get_saved_status()); };
608 #ifdef LIBDAR_SPECIAL_ALLOC
609 USE_SPECIAL_ALLOC(
door);
621 const std::string & name,
622 const std::string & target,
631 const std::string & get_target()
const;
632 void set_target(std::string x);
636 unsigned char signature()
const {
return mk_signature(
'l', get_saved_status()); };
637 entree *clone()
const {
return new (std::nothrow)
lien(*
this); };
639 #ifdef LIBDAR_SPECIAL_ALLOC
640 USE_SPECIAL_ALLOC(
lien);
643 void sub_compare(
const inode & other)
const;
644 void inherited_dump(
generic_file & f,
bool small)
const;
648 std::string points_to;
659 const std::string & xname,
668 std::map <infinint, etoile *> & corres,
677 void add_children(
nomme *r);
678 bool has_children()
const {
return !ordered_fils.empty(); };
679 void reset_read_children()
const;
680 void end_read()
const;
681 bool read_children(
const nomme * &r)
const;
683 void tail_to_read_children();
685 void remove(
const std::string & name);
688 directory * get_parent()
const {
return parent; };
689 bool search_children(
const std::string &name,
nomme *&ref);
690 bool callback_for_children_of(
user_interaction & dialog,
const std::string & sdir,
bool isolated =
false)
const;
694 unsigned char signature()
const {
return mk_signature(
'd', get_saved_status()); };
697 bool get_recursive_has_changed()
const {
return recursive_has_changed; };
699 void recursive_has_changed_update()
const;
706 infinint get_tree_mirage_num()
const;
710 void get_etiquettes_found_in_tree(std::map<infinint, infinint> & already_found)
const;
713 bool is_empty()
const {
return ordered_fils.empty(); };
716 void remove_all_mirages_and_reduce_dirs();
720 #ifdef LIBDAR_SPECIAL_ALLOC
725 void inherited_dump(
generic_file & f,
bool small)
const;
728 static const eod fin;
731 #ifdef LIBDAR_FAST_DIR
732 std::map<std::string, nomme *> fils;
734 std::list<nomme *> ordered_fils;
735 std::list<nomme *>::iterator it;
736 bool recursive_has_changed;
749 const std::string & name,
760 int get_major()
const {
if(get_saved_status() != s_saved)
throw SRC_BUG;
else return xmajor; };
761 int get_minor()
const {
if(get_saved_status() != s_saved)
throw SRC_BUG;
else return xminor; };
762 void set_major(
int x) { xmajor = x; };
763 void set_minor(
int x) { xminor = x; };
769 #ifdef LIBDAR_SPECIAL_ALLOC
770 USE_SPECIAL_ALLOC(
device);
774 void sub_compare(
const inode & other)
const;
775 void inherited_dump(
generic_file & f,
bool small)
const;
789 const std::string & name,
797 major, minor, fs_device) {};
803 escape *ptr) :
device(dialog, f, reading_ver, saved, ea_loc, ptr) {};
808 unsigned char signature()
const {
return mk_signature(
'c', get_saved_status()); };
809 entree *clone()
const {
return new (std::nothrow)
chardev(*
this); };
811 #ifdef LIBDAR_SPECIAL_ALLOC
824 const std::string & name,
828 last_modif, last_change, name,
829 major, minor, fs_device) {};
835 escape *ptr) :
device(dialog, f, reading_ver, saved, ea_loc, ptr) {};
840 unsigned char signature()
const {
return mk_signature(
'b', get_saved_status()); };
841 entree *clone()
const {
return new (std::nothrow)
blockdev(*
this); };
843 #ifdef LIBDAR_SPECIAL_ALLOC
856 const std::string & xname,
857 const infinint & fs_device) :
inode(xuid, xgid, xperm, last_access, last_modif, last_change, xname, fs_device) { set_saved_status(s_saved); };
863 escape *ptr) :
inode(dialog, f, reading_ver, saved, ea_loc, ptr) {};
868 unsigned char signature()
const {
return mk_signature(
'p', get_saved_status()); };
869 entree *clone()
const {
return new (std::nothrow)
tube(*
this); };
871 #ifdef LIBDAR_SPECIAL_ALLOC
872 USE_SPECIAL_ALLOC(
tube);
884 const std::string & xname,
885 const infinint & fs_device) :
inode(xuid, xgid, xperm, last_access, last_modif, last_change, xname, fs_device) { set_saved_status(s_saved); };
891 escape *ptr) :
inode(dialog, f, reading_ver, saved, ea_loc, ptr) {};
896 unsigned char signature()
const {
return mk_signature(
's', get_saved_status()); };
897 entree *clone()
const {
return new (std::nothrow)
prise(*
this); };
899 #ifdef LIBDAR_SPECIAL_ALLOC
900 USE_SPECIAL_ALLOC(
prise);
908 detruit(
const std::string & name,
unsigned char firm,
const infinint & date) :
nomme(name) , del_date(date) { signe = firm; };
910 detruit(
const nomme &ref) :
nomme(ref.get_name()), del_date(0) { signe = ref.signature(); };
912 unsigned char get_signature()
const {
return signe; };
913 void set_signature(
unsigned char x) { signe = x; };
914 unsigned char signature()
const {
return 'x'; };
915 entree *clone()
const {
return new (std::nothrow)
detruit(*
this); };
917 const infinint & get_date()
const {
return del_date; };
918 void set_date(
const infinint & ref) { del_date = ref; };
920 #ifdef LIBDAR_SPECIAL_ALLOC
924 void inherited_dump(
generic_file & f,
bool small)
const;
938 unsigned char signature()
const {
return 'i'; };
939 entree *clone()
const {
return new (std::nothrow)
ignored(*
this); };
940 #ifdef LIBDAR_SPECIAL_ALLOC
945 void inherited_dump(
generic_file & f,
bool small)
const {
throw SRC_BUG; };
958 escape *ptr) :
inode(dialog, f, reading_ver, s_not_saved, ea_loc, ptr) {
throw SRC_BUG; };
960 unsigned char signature()
const {
return 'j'; };
962 #ifdef LIBDAR_SPECIAL_ALLOC
967 void inherited_dump(
generic_file & f,
bool small)
const;
977 const label & data_name);
985 const label & lax_layer1_data_name,
986 bool only_detruit =
false);
994 virtual void reset_read()
const;
995 virtual void end_read()
const;
996 virtual void skip_read_to_parent_dir()
const;
999 virtual bool read(
const entree * & ref)
const;
1001 virtual bool read_if_present(std::string *name,
const nomme * & ref)
const;
1006 void remove_read_entry(std::string & name);
1008 const directory & get_current_reading_dir()
const {
return *current_read; };
1011 void tail_catalogue_to_current_read();
1014 void reset_sub_read(
const path &sub);
1015 bool sub_read(
const entree * &ref);
1024 virtual bool read_second_time_dir()
const {
return false; };
1035 virtual void pre_add_crc(
const entree *ref, compressor *compr)
const {};
1036 virtual void pre_add_dirty(compressor *compr)
const {};
1037 virtual void pre_add_ea_crc(
const entree *ref, compressor *compr)
const {};
1038 virtual void pre_add_waste_mark(compressor *compr)
const {};
1039 virtual void pre_add_failed_mark(compressor *compr)
const {};
1040 virtual escape *get_escape_layer()
const {
return NULL; };
1042 void add(entree *ref);
1043 void re_add_in(
const std::string &subdirname);
1044 void re_add_in_replace(
const directory &dir);
1045 void add_in_current_read(nomme *ref);
1051 void reset_compare();
1052 bool compare(
const entree * name,
const entree * & extracted);
1069 bool direct_read(
const path & ref,
const nomme * &ret);
1070 infinint update_destroyed_with(catalogue & ref);
1073 void update_absent_with(catalogue & ref, infinint aborting_next_etoile);
1078 void dump(generic_file & f)
const;
1079 void listing(
bool isolated,
1080 const mask &selection,
1081 const mask & subtree,
1082 bool filter_unsaved,
1084 std::string marge)
const;
1085 void tar_listing(
bool isolated,
1086 const mask & selection,
1087 const mask & subtree,
1088 bool filter_unsaved,
1090 std::string beginning)
const;
1091 void xml_listing(
bool isolated,
1092 const mask & selection,
1093 const mask & subtree,
1094 bool filter_unsaved,
1096 std::string beginning)
const;
1098 entree_stats get_stats()
const {
return stats; };
1101 bool is_empty()
const {
if(contenu == NULL)
throw SRC_BUG;
return contenu->is_empty(); };
1103 const directory *get_contenu()
const {
return contenu; };
1105 const label & get_data_name()
const {
return ref_data_name; };
1106 infinint get_root_dir_last_modif()
const {
return contenu->get_last_modif(); };
1111 infinint get_root_mtime()
const {
return contenu->get_last_modif(); };
1118 entree_stats & access_stats() {
return stats; };
1119 void set_data_name(
const label & val) { ref_data_name = val; };
1120 void copy_detruits_from(
const catalogue & ref);
1122 const eod * get_r_eod_address()
const {
return & r_eod; };
1134 directory *current_compare;
1135 directory *current_add;
1136 directory *current_read;
1138 signed int sub_count;
1140 label ref_data_name;
1142 void partial_copy_from(
const catalogue &ref);
1145 static const eod r_eod;
1146 static const U_I CAT_CRC_SIZE;