Disk ARchive  2.6.8
Full featured and portable backup and archiving tool
data_dir.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2020 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 : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21 
25 
26 
27 #ifndef DATA_DIR_HPP
28 #define DATA_DIR_HPP
29 
30 #include "../my_config.h"
31 
32 #include <string>
33 #include <deque>
34 #include <vector>
35 #include "infinint.hpp"
36 #include "generic_file.hpp"
37 #include "user_interaction.hpp"
38 #include "path.hpp"
39 #include "cat_directory.hpp"
40 #include "cat_inode.hpp"
41 #include "cat_detruit.hpp"
42 #include "data_tree.hpp"
43 
44 namespace libdar
45 {
46 
49 
51 
52  class data_dir : public data_tree
53  {
54  public:
55  data_dir(const std::string &name);
56  data_dir(generic_file &f, unsigned char db_version); //< does not read signature
57  data_dir(const data_tree & ref);
58  data_dir(const data_dir & ref);
59  data_dir(data_dir && ref) = default;
60  data_dir & operator = (const data_dir & ref) { rejetons.clear(); return *this; };
61  data_dir & operator = (data_dir && ref) noexcept = default;
62  ~data_dir();
63 
64  virtual void dump(generic_file & f) const override; //< write signature followed by data constructor will read
65 
66  void add(const cat_inode *entry, const archive_num & archive);
67  void add(const cat_detruit *entry, const archive_num & archive);
68  const data_tree *read_child(const std::string & name) const;
69  void read_all_children(std::vector<std::string> & fils) const;
70  void finalize_except_self(const archive_num & archive,
71  const datetime & deleted_date,
72  const archive_num & ignore_archives_greater_or_equal);
73 
74  // inherited methods
75  virtual bool check_order(user_interaction & dialog, const path & current_path, bool & initial_warn) const override;
76  virtual void finalize(const archive_num & archive, const datetime & deleted_date, const archive_num & ignore_archives_greater_or_equal) override;
77  virtual bool remove_all_from(const archive_num & archive_to_remove, const archive_num & last_archive) override;
78 
81  void *tag,
82  archive_num num,
83  std::string marge = "") const;
84  virtual void apply_permutation(archive_num src, archive_num dst) override;
85  virtual void skip_out(archive_num num) override;
86  virtual void compute_most_recent_stats(std::deque<infinint> & data,
87  std::deque<infinint> & ea,
88  std::deque<infinint> & total_data,
89  std::deque<infinint> & total_ea) const override;
90 
91  virtual char obj_signature() const override { return signature(); };
92  static char signature() { return 'd'; };
93 
94  virtual bool fix_corruption() override; // inherited from data_tree
95 
97 
101  bool data_tree_find(path chemin, const data_tree *& ptr) const;
102 
105 
106 
108 
112  static data_dir *data_tree_read(generic_file & f, unsigned char db_version);
113 
114  private:
115  std::deque<data_tree *> rejetons; //< subdir and subfiles of the current dir
116 
117  void add_child(data_tree *fils); //< "this" is now responsible of "fils" disalocation
118  void remove_child(const std::string & name);
119  data_tree *find_or_addition(const std::string & name, bool is_dir, const archive_num & archive);
120 
122  static data_tree *read_next_in_list_from_file(generic_file & f, unsigned char db_version);
123  };
124 
125 
126 
127 
129 
130 } // end of namespace
131 
132 #endif
libdar::data_dir
the data_dir class inherits from data_tree and holds the directory tree's parent relationship
Definition: data_dir.hpp:52
libdar::user_interaction
This is a pure virtual class that is used by libdar when interaction with the user is required.
Definition: user_interaction.hpp:46
user_interaction.hpp
defines the interaction interface between libdar and users.
infinint.hpp
switch module to limitint (32 ou 64 bits integers) or infinint
cat_inode.hpp
base object for all inode types, managed EA and FSA, dates, permissions, ownership,...
libdar::cat_detruit
the deleted file entry
Definition: cat_detruit.hpp:48
libdar::data_dir::show
void show(database_listing_show_files_callback callback, void *tag, archive_num num, std::string marge="") const
list the most recent files owned by that archive (or by any archive if num == 0)
libdar::cat_inode
the root class for all cat_inode
Definition: cat_inode.hpp:52
cat_detruit.hpp
used to record information in a catalogue about a deleted file (differential backup context)
libdar::data_dir::data_tree_find
bool data_tree_find(path chemin, const data_tree *&ptr) const
lookup routine to find a pointer to the dat_tree object corresponding to the given path
generic_file.hpp
class generic_file is defined here as well as class fichier
libdar::data_dir::data_tree_read
static data_dir * data_tree_read(generic_file &f, unsigned char db_version)
read a signature and then run the data_dir constructor but aborts if not a data_dir
libdar::path
the class path is here to manipulate paths in the Unix notation: using'/'
Definition: path.hpp:50
libdar::data_dir::finalize
virtual void finalize(const archive_num &archive, const datetime &deleted_date, const archive_num &ignore_archives_greater_or_equal) override
add deleted entry if no object of the current archive exist and the entry of the previous archive is ...
libdar::datetime
stores time information
Definition: datetime.hpp:58
cat_directory.hpp
class used to organize objects in tree in catalogue as like directories in a filesystem
libdar::generic_file
this is the interface class from which all other data transfer classes inherit
Definition: generic_file.hpp:76
libdar::data_tree
the data_tree class stores presence of a given file in a set of archives
Definition: data_tree.hpp:53
data_tree.hpp
base classes used to store entree information in dar_manager databases
libdar::archive
the archive class realizes the most general operations on archives
Definition: archive.hpp:64
libdar::cat_directory
the cat_directory inode class
Definition: cat_directory.hpp:51
libdar::archive_num
class archive_num stores the position of an archive inside a dar_manager database
Definition: archive_num.hpp:46
libdar::data_dir::read_next_in_list_from_file
static data_tree * read_next_in_list_from_file(generic_file &f, unsigned char db_version)
read signature and depening on it run data_tree or data_dir constructor
libdar::data_dir::check_order
virtual bool check_order(user_interaction &dialog, const path &current_path, bool &initial_warn) const override
check date order between archives withing the database ; throw Erange if problem found with date orde...
libdar::data_dir::data_tree_update_with
void data_tree_update_with(const cat_directory *dir, archive_num archive)
add a directory to the dat_dir
libdar::data_dir::remove_all_from
virtual bool remove_all_from(const archive_num &archive_to_remove, const archive_num &last_archive) override
return true if the corresponding file is no more located in any archive (thus, the object is no more ...
path.hpp
here is the definition of the path class
libdar::database_listing_show_files_callback
void(*)(void *context, const std::string &filename, bool available_data, bool available_ea) database_listing_show_files_callback
called by the database::get_files() routine
Definition: database_listing_callback.hpp:51
libdar::compile_time::ea
bool ea() noexcept
returns whether EA support has been activated at compilation time
libdar::data_dir::skip_out
virtual void skip_out(archive_num num) override
decrement archive numbers above num
libdar
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:46