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;
142 #ifdef LIBDAR_SPECIAL_ALLOC
143 USE_SPECIAL_ALLOC(
entree);
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(); };
169 #ifdef LIBDAR_SPECIAL_ALLOC
170 USE_SPECIAL_ALLOC(
eod);
178 nomme(
const std::string & name) { xname = name; };
180 virtual bool operator == (
const nomme & ref)
const {
return xname == ref.xname; };
181 virtual bool operator < (
const nomme & ref)
const {
return xname < ref.xname; };
183 const std::string & get_name()
const {
return xname; };
184 void change_name(
const std::string & x) { xname = x; };
185 bool same_as(
const nomme & ref)
const {
return xname == ref.xname; };
191 #ifdef LIBDAR_SPECIAL_ALLOC
192 USE_SPECIAL_ALLOC(
nomme);
196 void inherited_dump(
generic_file & f,
bool small)
const;
233 const infinint & get_uid()
const {
return uid; };
234 const infinint & get_gid()
const {
return gid; };
235 U_16 get_perm()
const {
return perm; };
236 infinint get_last_access()
const {
return *last_acc; };
237 infinint get_last_modif()
const {
return *last_mod; };
238 void set_last_access(
const infinint & x_time) { *last_acc = x_time; };
239 void set_last_modif(
const infinint & x_time) { *last_mod = x_time; };
240 saved_status get_saved_status()
const {
return xsaved; };
241 void set_saved_status(saved_status x) { xsaved = x; };
242 infinint get_device()
const {
return *fs_dev; };
244 bool same_as(
const inode & ref)
const;
245 bool is_more_recent_than(
const inode & ref,
const infinint & hourshift)
const;
247 virtual bool has_changed_since(
const inode & ref,
const infinint & hourshift,
comparison_fields what_to_check)
const;
251 void compare(
const inode &other,
252 const mask & ea_mask,
254 const infinint & hourshift,
255 bool symlink_date)
const;
269 enum ea_status { ea_none, ea_partial, ea_fake, ea_full, ea_removed };
277 void ea_set_saved_status(ea_status status);
278 ea_status ea_get_saved_status()
const {
return ea_saved; };
281 void ea_attach(ea_attributs *ref);
282 const ea_attributs *get_ea()
const;
283 void ea_detach()
const;
284 infinint ea_get_size()
const;
287 void ea_set_offset(
const infinint & pos) { *ea_offset = pos; };
288 void ea_set_crc(
const crc & val);
289 void ea_get_crc(
const crc * & ptr)
const;
290 bool ea_get_crc_size(infinint & val)
const;
293 infinint get_last_change()
const;
294 void set_last_change(
const infinint & x_time);
295 bool has_last_change()
const {
return last_cha != NULL; };
303 void change_ea_location(generic_file *loc) { storage = loc; };
307 #ifdef LIBDAR_SPECIAL_ALLOC
308 USE_SPECIAL_ALLOC(inode);
312 virtual void sub_compare(
const inode & other)
const {};
317 void inherited_dump(
generic_file & f,
bool small)
const;
354 const etoile & operator = (
const etoile & ref) {
throw SRC_BUG; };
355 ~
etoile() {
delete hosted; };
357 void add_ref(
void *ref);
358 void drop_ref(
void *ref);
359 infinint get_ref_count()
const {
return refs.size(); };
360 inode *get_inode()
const {
return hosted; };
361 infinint get_etiquette()
const {
return etiquette; };
362 void change_etiquette(
const infinint & new_val) { etiquette = new_val; };
365 bool is_counted()
const {
return tags.counted; };
366 bool is_wrote()
const {
return tags.wrote; };
367 bool is_dumped()
const {
return tags.dumped; };
368 void set_counted(
bool val) { tags.counted = val ? 1 : 0; };
369 void set_wrote(
bool val) { tags.wrote = val ? 1 : 0; };
370 void set_dumped(
bool val) { tags.dumped = val ? 1 : 0; };
374 const void *get_first_ref()
const {
if(refs.size() == 0)
throw SRC_BUG;
return refs.front(); };
376 #ifdef LIBDAR_SPECIAL_ALLOC
377 USE_SPECIAL_ALLOC(
etoile);
383 unsigned counted : 1;
388 bool_tags() { counted = wrote = dumped = 0; };
391 std::list<void *> refs;
403 enum mirage_format {fmt_mirage,
405 fmt_file_etiquette };
407 mirage(
const std::string & name,
etoile *ref) :
nomme(name) { star_ref = ref;
if(ref == NULL)
throw SRC_BUG; star_ref->add_ref(
this); };
413 std::map <infinint, etoile *> & corres,
425 std::map <infinint, etoile *> & corres,
431 mirage(
const mirage & ref) :
nomme (ref) { star_ref = ref.star_ref;
if(star_ref == NULL)
throw SRC_BUG; star_ref->add_ref(
this); };
433 ~
mirage() { star_ref->drop_ref(
this); };
435 unsigned char signature()
const {
return 'm'; };
438 inode *get_inode()
const {
if(star_ref == NULL)
throw SRC_BUG;
return star_ref->get_inode(); };
439 infinint get_etiquette()
const {
return star_ref->get_etiquette(); };
440 infinint get_etoile_ref_count()
const {
return star_ref->get_ref_count(); };
441 etoile *get_etoile()
const {
return star_ref; };
443 bool is_inode_counted()
const {
return star_ref->is_counted(); };
444 bool is_inode_wrote()
const {
return star_ref->is_wrote(); };
445 bool is_inode_dumped()
const {
return star_ref->is_dumped(); };
446 void set_inode_counted(
bool val)
const { star_ref->set_counted(val); };
447 void set_inode_wrote(
bool val)
const { star_ref->set_wrote(val); };
448 void set_inode_dumped(
bool val)
const { star_ref->set_dumped(val); };
455 #ifdef LIBDAR_SPECIAL_ALLOC
456 USE_SPECIAL_ALLOC(
mirage);
460 void inherited_dump(
generic_file & f,
bool small)
const;
470 std::map <infinint, etoile *> & corres,
492 static const U_8 FILE_DATA_WITH_HOLE = 0x01;
493 static const U_8 FILE_DATA_IS_DIRTY = 0x02;
499 const std::string & src,
503 bool x_furtive_read_mode);
516 infinint get_size()
const {
return *size; };
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 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 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;
707 infinint get_tree_mirage_num()
const;
711 void get_etiquettes_found_in_tree(std::map<infinint, infinint> & already_found)
const;
714 bool is_empty()
const {
return ordered_fils.empty(); };
717 void remove_all_mirages_and_reduce_dirs();
721 #ifdef LIBDAR_SPECIAL_ALLOC
726 void inherited_dump(
generic_file & f,
bool small)
const;
729 static const eod fin;
732 #ifdef LIBDAR_FAST_DIR
733 std::map<std::string, nomme *> fils;
735 std::list<nomme *> ordered_fils;
736 std::list<nomme *>::iterator it;
737 bool recursive_has_changed;
750 const std::string & name,
761 int get_major()
const {
if(get_saved_status() != s_saved)
throw SRC_BUG;
else return xmajor; };
762 int get_minor()
const {
if(get_saved_status() != s_saved)
throw SRC_BUG;
else return xminor; };
763 void set_major(
int x) { xmajor = x; };
764 void set_minor(
int x) { xminor = x; };
770 #ifdef LIBDAR_SPECIAL_ALLOC
771 USE_SPECIAL_ALLOC(
device);
775 void sub_compare(
const inode & other)
const;
776 void inherited_dump(
generic_file & f,
bool small)
const;
790 const std::string & name,
798 major, minor, fs_device) {};
804 escape *ptr) :
device(dialog, f, reading_ver, saved, ea_loc, ptr) {};
809 unsigned char signature()
const {
return mk_signature(
'c', get_saved_status()); };
812 #ifdef LIBDAR_SPECIAL_ALLOC
825 const std::string & name,
829 last_modif, last_change, name,
830 major, minor, fs_device) {};
836 escape *ptr) :
device(dialog, f, reading_ver, saved, ea_loc, ptr) {};
841 unsigned char signature()
const {
return mk_signature(
'b', get_saved_status()); };
844 #ifdef LIBDAR_SPECIAL_ALLOC
857 const std::string & xname,
858 const infinint & fs_device) :
inode(xuid, xgid, xperm, last_access, last_modif, last_change, xname, fs_device) { set_saved_status(s_saved); };
864 escape *ptr) :
inode(dialog, f, reading_ver, saved, ea_loc, ptr) {};
869 unsigned char signature()
const {
return mk_signature(
'p', get_saved_status()); };
870 entree *clone()
const {
return new tube(*
this); };
872 #ifdef LIBDAR_SPECIAL_ALLOC
873 USE_SPECIAL_ALLOC(
tube);
885 const std::string & xname,
886 const infinint & fs_device) :
inode(xuid, xgid, xperm, last_access, last_modif, last_change, xname, fs_device) { set_saved_status(s_saved); };
892 escape *ptr) :
inode(dialog, f, reading_ver, saved, ea_loc, ptr) {};
897 unsigned char signature()
const {
return mk_signature(
's', get_saved_status()); };
898 entree *clone()
const {
return new prise(*
this); };
900 #ifdef LIBDAR_SPECIAL_ALLOC
901 USE_SPECIAL_ALLOC(
prise);
909 detruit(
const std::string & name,
unsigned char firm,
const infinint & date) :
nomme(name) , del_date(date) { signe = firm; };
911 detruit(
const nomme &ref) :
nomme(ref.get_name()), del_date(0) { signe = ref.signature(); };
913 unsigned char get_signature()
const {
return signe; };
914 void set_signature(
unsigned char x) { signe = x; };
915 unsigned char signature()
const {
return 'x'; };
918 const infinint & get_date()
const {
return del_date; };
919 void set_date(
const infinint & ref) { del_date = ref; };
921 #ifdef LIBDAR_SPECIAL_ALLOC
925 void inherited_dump(
generic_file & f,
bool small)
const;
939 unsigned char signature()
const {
return 'i'; };
941 #ifdef LIBDAR_SPECIAL_ALLOC
946 void inherited_dump(
generic_file & f,
bool small)
const {
throw SRC_BUG; };
959 escape *ptr) :
inode(dialog, f, reading_ver, s_not_saved, ea_loc, ptr) {
throw SRC_BUG; };
961 unsigned char signature()
const {
return 'j'; };
963 #ifdef LIBDAR_SPECIAL_ALLOC
968 void inherited_dump(
generic_file & f,
bool small)
const;
978 const label & data_name);
986 const label & lax_layer1_data_name,
987 bool only_detruit =
false);
995 virtual void reset_read()
const;
996 virtual void end_read()
const;
997 virtual void skip_read_to_parent_dir()
const;
1000 virtual bool read(
const entree * & ref)
const;
1002 virtual bool read_if_present(std::string *name,
const nomme * & ref)
const;
1007 void remove_read_entry(std::string & name);
1009 const directory & get_current_reading_dir()
const {
return *current_read; };
1012 void tail_catalogue_to_current_read();
1015 void reset_sub_read(
const path &sub);
1016 bool sub_read(
const entree * &ref);
1025 virtual bool read_second_time_dir()
const {
return false; };
1036 virtual void pre_add_crc(
const entree *ref, compressor *compr)
const {};
1037 virtual void pre_add_dirty(compressor *compr)
const {};
1038 virtual void pre_add_ea_crc(
const entree *ref, compressor *compr)
const {};
1039 virtual void pre_add_waste_mark(compressor *compr)
const {};
1040 virtual void pre_add_failed_mark(compressor *compr)
const {};
1041 virtual escape *get_escape_layer()
const {
return NULL; };
1043 void add(entree *ref);
1044 void re_add_in(
const std::string &subdirname);
1045 void re_add_in_replace(
const directory &dir);
1046 void add_in_current_read(nomme *ref);
1052 void reset_compare();
1053 bool compare(
const entree * name,
const entree * & extracted);
1070 bool direct_read(
const path & ref,
const nomme * &ret);
1071 infinint update_destroyed_with(catalogue & ref);
1074 void update_absent_with(catalogue & ref, infinint aborting_next_etoile);
1079 void dump(generic_file & f)
const;
1080 void listing(
bool isolated,
1081 const mask &selection,
1082 const mask & subtree,
1083 bool filter_unsaved,
1085 std::string marge)
const;
1086 void tar_listing(
bool isolated,
1087 const mask & selection,
1088 const mask & subtree,
1089 bool filter_unsaved,
1091 std::string beginning)
const;
1092 void xml_listing(
bool isolated,
1093 const mask & selection,
1094 const mask & subtree,
1095 bool filter_unsaved,
1097 std::string beginning)
const;
1099 entree_stats get_stats()
const {
return stats; };
1102 bool is_empty()
const {
if(contenu == NULL)
throw SRC_BUG;
return contenu->is_empty(); };
1104 const directory *get_contenu()
const {
return contenu; };
1106 const label & get_data_name()
const {
return ref_data_name; };
1107 infinint get_root_dir_last_modif()
const {
return contenu->get_last_modif(); };
1112 infinint get_root_mtime()
const {
return contenu->get_last_modif(); };
1119 entree_stats & access_stats() {
return stats; };
1120 void set_data_name(
const label & val) { ref_data_name = val; };
1121 void copy_detruits_from(
const catalogue & ref);
1123 const eod * get_r_eod_address()
const {
return & r_eod; };
1135 directory *current_compare;
1136 directory *current_add;
1137 directory *current_read;
1139 signed int sub_count;
1141 label ref_data_name;
1143 void partial_copy_from(
const catalogue &ref);
1146 static const eod r_eod;
1147 static const U_I CAT_CRC_SIZE;