Disk ARchive 2.7.14
Full featured and portable backup and archiving tool
Loading...
Searching...
No Matches
filesystem_restore.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_RESTORE_HPP
27#define FILESYSTEM_RESTORE_HPP
28
29#include "../my_config.h"
30
31extern "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 <deque>
43#include "crit_action.hpp"
44#include "fsa_family.hpp"
45#include "cat_all_entrees.hpp"
48
49#include <set>
50
51namespace libdar
52{
55
57
59 {
60 public:
62 filesystem_restore(const std::shared_ptr<user_interaction> & dialog,
63 const path & root,
65 bool x_info_details,
66 const mask & x_ea_mask,
67 comparison_fields what_to_check,
68 bool x_warn_remove_no_match,
69 bool empty,
70 const crit_action *x_overwrite,
72 const fsa_scope & scope);
73
76
79
82
85
87 ~filesystem_restore() { restore_stack_dir_ownership(); detruire(); };
88
91
92 using action_done_for_data = enum
93 {
94 done_data_restored, //< data has been restored to filesystem
95 done_no_change_no_data, //< no change in filesystem because no data present in archive
96 done_no_change_policy, //< no change in filesystem because of overwiting policy decision
97 done_data_removed //< data (= whole inode) removed from filesystem
98 };
99
101
110 void write(const cat_entree *x,
112 bool & ea_restored,
113 bool & data_created,
114 bool & hard_link,
115 bool & fsa_restored);
116
117
119
123 void ignore_overwrite_restrictions_for_next_write() { ignore_over_restricts = true; };
124
125
126 private:
127 class stack_dir_t : public cat_directory
128 {
129 public:
130 stack_dir_t(const cat_directory & ref, bool restore) : cat_directory(ref) { restore_date = restore; };
131
132 bool get_restore_date() const { return restore_date; };
133 void set_restore_date(bool val) { restore_date = val; };
134
135 private:
136 bool restore_date;
137 };
138
139 path *fs_root;
140 bool info_details;
141 mask *ea_mask;
142 bool warn_overwrite;
143 comparison_fields what_to_check;
144 bool warn_remove_no_match;
145 std::deque<stack_dir_t> stack_dir;
146 path *current_dir;
147 bool empty;
148 bool ignore_over_restricts;
149 const crit_action *overwrite;
150 bool only_overwrite;
151
152 void detruire();
153 void restore_stack_dir_ownership();
154 user_interaction & get_ui() const { return filesystem_hard_link_read::get_ui(); };
155 std::shared_ptr<user_interaction> get_pointer() const { return filesystem_hard_link_read::get_pointer(); };
156
157 // subroutines of write()
158
160 void action_over_remove(const cat_inode *in_place,
162 const std::string & spot,
163 over_action_data action);
165 void action_over_data(const cat_inode *in_place,
166 const cat_nomme *to_be_added,
167 const std::string & spot,
168 over_action_data action,
171 bool action_over_ea(const cat_inode *in_place,
172 const cat_nomme *to_be_added,
173 const std::string & spot,
174 over_action_ea action);
176 bool action_over_fsa(const cat_inode *in_place,
177 const cat_nomme *to_be_added,
178 const std::string & spot,
179 over_action_ea action);
180
181 };
182
184
185} // end of namespace
186
187#endif
include file gathering all entree found in a catalogue
the deleted file entry
the cat_directory inode class
the root class from all other inherite for any entry in the catalogue
the root class for all cat_inode
Definition cat_inode.hpp:53
the base class for all entry that have a name
Definition cat_nomme.hpp:45
receive the flow of inode from the restoration filtering routing and promotes these to real filesyste...
void ignore_overwrite_restrictions_for_next_write()
ask for no warning or user interaction for the next write operation
void reset_write()
reset the writing process for the current object
void action_over_data(const cat_inode *in_place, const cat_nomme *to_be_added, const std::string &spot, over_action_data action, action_done_for_data &data_done)
perform action for data due to the overwriting policy when the "to be added" entry is not a cat_detru...
bool action_over_ea(const cat_inode *in_place, const cat_nomme *to_be_added, const std::string &spot, over_action_ea action)
perform action for EA due to overwriting policy
filesystem_restore(const std::shared_ptr< user_interaction > &dialog, const path &root, bool x_warn_overwrite, bool x_info_details, const mask &x_ea_mask, comparison_fields what_to_check, bool x_warn_remove_no_match, bool empty, const crit_action *x_overwrite, bool x_only_overwrite, const fsa_scope &scope)
constructor
void action_over_remove(const cat_inode *in_place, const cat_detruit *to_be_added, const std::string &spot, over_action_data action)
perform action due to the overwriting policy when the "to be added" entry is a detruit object
filesystem_restore(filesystem_restore &&ref)=delete
move constructor is forbidden
filesystem_restore & operator=(const filesystem_restore &ref)=delete
assignment operator is forbidden
void write(const cat_entree *x, action_done_for_data &data_restored, bool &ea_restored, bool &data_created, bool &hard_link, bool &fsa_restored)
restore a libdar object to a filesystem entry both data and EA
bool action_over_fsa(const cat_inode *in_place, const cat_nomme *to_be_added, const std::string &spot, over_action_ea action)
perform action for FSA due to overwriting policy
filesystem_restore(const filesystem_restore &ref)=delete
copy constructor is forbidden
the generic class, parent of all masks
std::shared_ptr< user_interaction > get_pointer() const
get access to the shared_ptr pointing to the user_interaction
user_interaction & get_ui() const
get access to the user_interaction object
the class path is here to manipulate paths in the Unix notation: using'/'
comparison_fields
how to consider file change during comparison and incremental backup
over_action_ea
the possible action for overwriting EA
std::set< fsa_family > fsa_scope
set of fsa families
over_action_data
the possible actions for overwriting data
include macro defined by the configure script and some specific additional ones
libdar namespace encapsulate all libdar symbols
contains classes that let the user define the policy for overwriting files
filesystem specific attributes available families and fsa_scope definition