Disk ARchive  2.7.15
Full featured and portable backup and archiving tool
filesystem_hard_link_read.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2024 Denis Corbin
4 //
5 // This program is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU General Public License
7 // as published by the Free Software Foundation; either version 2
8 // of the License, or (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // to contact the author, see the AUTHOR file
20 /*********************************************************************/
21 
25 
26 #ifndef FILESYSTEM_HARD_LINK_READ_HPP
27 #define FILESYSTEM_HARD_LINK_READ_HPP
28 
29 #include "../my_config.h"
30 
31 extern "C"
32 {
33 #if HAVE_UNISTD_H
34 #include <unistd.h>
35 #endif
36 
37 #if HAVE_SYS_STAT_H
38 #include <sys/stat.h>
39 #endif
40 } // end extern "C"
41 
42 #include <map>
43 #include "infinint.hpp"
44 #include "fsa_family.hpp"
45 #include "cat_all_entrees.hpp"
46 #include "mem_ui.hpp"
47 
48 #include <set>
49 
50 namespace libdar
51 {
54 
56 
58  {
59  // this class is not to be used directly
60  // it only provides some routine for the inherited classes
61 
62  public:
63  filesystem_hard_link_read(const std::shared_ptr<user_interaction> & dialog,
64  bool x_furtive_read_mode,
65  const fsa_scope & scope) : mem_ui(dialog)
66  { furtive_read_mode = x_furtive_read_mode; sc = scope; ask_before_zeroing_neg_dates = true; };
67 
68  // the copy of the current object would make copy of addresses in
69  // corres_read that could be released twice ... thus, copy constructor and
70  // assignement are forbidden for this class:
71 
74  filesystem_hard_link_read & operator = (const filesystem_hard_link_read & ref) = delete;
75  filesystem_hard_link_read & operator = (filesystem_hard_link_read && ref) = delete;
76 
77  virtual ~filesystem_hard_link_read() = default;
78 
80  const infinint & get_last_etoile_ref() const { return etiquette_counter; };
81 
83  const fsa_scope get_fsa_scope() const { return sc; };
84 
86  void zeroing_negative_dates_without_asking() { ask_before_zeroing_neg_dates = false; };
87 
91  void set_ignored_symlinks_list(const std::set<std::string> & x_ignored_symlinks)
92  { ignored_symlinks = x_ignored_symlinks; };
93 
94  protected:
95 
97  void corres_reset() { corres_read.clear(); etiquette_counter = 0; };
98 
103  const std::string & name,
104  bool see_hard_link,
105  const mask & ea_mask
106  );
107 
108  bool get_ask_before_zeroing_neg_dates() const { return ask_before_zeroing_neg_dates; };
109  private:
110 
111  // private datastructure
112 
113  struct couple
114  {
115  nlink_t count;
116  cat_etoile *obj;
117  cat_mirage holder;
118 
119  couple(cat_etoile *ptr, nlink_t ino_count) : holder("FAKE", ptr) { count = ino_count; obj = ptr; };
120  };
121 
122  struct node
123  {
124  node(ino_t num, dev_t dev) { numnode = num; device = dev; };
125 
126  // this operator is required to use the type node in a std::map
127  bool operator < (const node & ref) const { return numnode < ref.numnode || (numnode == ref.numnode && device < ref.device); };
128  ino_t numnode;
129  dev_t device;
130  };
131 
132  // private variable
133 
134  std::map <node, couple> corres_read;
135  infinint etiquette_counter;
136  bool furtive_read_mode;
137  fsa_scope sc;
138  bool ask_before_zeroing_neg_dates;
139  std::set<std::string> ignored_symlinks;
140 
141  // private methods
142 
143  bool ignore_if_symlink(const std::string & full_path)
144  { return ignored_symlinks.find(full_path) != ignored_symlinks.end(); };
145  };
146 
148 
149 } // end of namespace
150 
151 #endif
include file gathering all entree found in a catalogue
the hard link implementation
Definition: cat_etoile.hpp:48
the hard link implementation, cat_mirage is the named entry owned by a directory it points to a commo...
Definition: cat_mirage.hpp:48
the base class for all entry that have a name
Definition: cat_nomme.hpp:45
the arbitrary large positive integer class
the generic class, parent of all masks
Definition: mask.hpp:62
class mem_ui to keep a copy of a user_interaction object
Definition: mem_ui.hpp:55
mem_ui(const std::shared_ptr< user_interaction > &dialog)
constructor
the class path is here to manipulate paths in the Unix notation: using'/'
Definition: path.hpp:51
filesystem specific attributes available families and fsa_scope definition
std::set< fsa_family > fsa_scope
set of fsa families
Definition: fsa_family.hpp:70
switch module to limitint (32 ou 64 bits integers) or infinint
class mem_ui definition. This class is to be used as parent class to handle user_interaction object m...
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47