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;
246 virtual bool has_changed_since(
const inode & ref,
const infinint & hourshift,
comparison_fields what_to_check)
const;
250 void compare(
const inode &other,
251 const mask & ea_mask,
253 const infinint & hourshift,
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; };
280 void ea_attach(ea_attributs *ref);
281 const ea_attributs *get_ea()
const;
282 void ea_detach()
const;
283 infinint ea_get_size()
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;
292 infinint get_last_change()
const;
293 void set_last_change(
const infinint & x_time);
294 bool has_last_change()
const {
return last_cha != NULL; };
302 void change_ea_location(generic_file *loc) { storage = loc; };
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;
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()); };
810 entree *clone()
const {
return new (std::nothrow)
chardev(*
this); };
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()); };
842 entree *clone()
const {
return new (std::nothrow)
blockdev(*
this); };
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 (std::nothrow)
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 (std::nothrow)
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'; };
916 entree *clone()
const {
return new (std::nothrow)
detruit(*
this); };
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'; };
940 entree *clone()
const {
return new (std::nothrow)
ignored(*
this); };
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;
the symbolic link inode class
etoile(inode *host, const infinint &etiquette_number)
build a object
are defined here basic integer types that tend to be portable
mem_ui(user_interaction &dialog)
constructor
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
void reset_all()
reset all pointers to the root (a bit better than reset_add() + reset_read() + reset_compare() + rese...
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
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...
void swap_stuff(catalogue &ref)
the directory inode class
void post_constructor(generic_file &f)
called by entree::read and mirage::post_constructor, let inherited classes builds object's data after...
comparison_fields
flag used to only consider certain fields when comparing/restoring inodes
void post_constructor(generic_file &f)
called by entree::read and mirage::post_constructor, let inherited classes builds object's data after...
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
void dump(generic_file &f, bool small) const
write down the object information to a generic_file
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
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'/'