| Disk ARchive 2.7.18 Full featured and portable backup and archiving tool

Loading...
Searching...
No Matches
cat_mirage.hpp
Go to the documentation of this file.
1/*********************************************************************/
2// dar - disk archive - a backup/restoration program
3// Copyright (C) 2002-2025 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 CAT_MIRAGE_HPP
27#define CAT_MIRAGE_HPP
28
29#include "../my_config.h"
30
31 extern "C"
32{
33} // end extern "C"
34
35#include "cat_nomme.hpp"
36#include "cat_etoile.hpp"
37
38 namespace libdar
39{
40
43
45
47 class cat_mirage : public cat_nomme
48 {
49 public:
51 enum mirage_format {fmt_mirage,
52 fmt_hard_link,
53 fmt_file_etiquette };
54
55 cat_mirage(const std::string & name, cat_etoile *ref): cat_nomme(name, saved_status::saved) { dup_on(ref); };
56 cat_mirage(const std::shared_ptr<user_interaction> & dialog,
57 const smart_pointer<pile_descriptor> & pdesc,
58 const archive_version & reading_ver,
59 saved_status saved,
60 entree_stats & stats,
61 std::map <infinint, cat_etoile *> & corres,
62 compression default_algo,
63 mirage_format fmt,
64 bool lax,
65 bool small);
66 cat_mirage(const std::shared_ptr<user_interaction> & dialog,
67 const smart_pointer<pile_descriptor> & pdesc,
68 const archive_version & reading_ver,
69 saved_status saved,
70 entree_stats & stats,
71 std::map <infinint, cat_etoile *> & corres,
72 compression default_algo,
73 bool lax,
74 bool small);
75 cat_mirage(const cat_mirage & ref) : cat_nomme (ref) { dup_on(ref.star_ref); };
76 cat_mirage(cat_mirage && ref) noexcept: cat_nomme(std::move(ref)) { try { dup_on(ref.star_ref); } catch(...) {}; };
77 cat_mirage & operator = (const cat_mirage & ref);
78 cat_mirage & operator = (cat_mirage && ref);
79 ~cat_mirage() { star_ref->drop_ref(this); };
80
81 virtual bool operator == (const cat_entree & ref) const override;
82
83 virtual unsigned char signature() const override { return 'm'; };
84 virtual std::string get_description() const override { return "hard linked inode"; };
85
86 virtual cat_entree *clone() const override { return new (std::nothrow) cat_mirage(*this); };
87
88 cat_inode *get_inode() const { if(star_ref == nullptr) throw SRC_BUG; return star_ref->get_inode(); };
89 infinint get_etiquette() const { return star_ref->get_etiquette(); };
90 infinint get_etoile_ref_count() const { return star_ref->get_ref_count(); };
91 cat_etoile *get_etoile() const { return star_ref; };
92
93 bool is_inode_counted() const { return star_ref->is_counted(); };
94 bool is_inode_wrote() const { return star_ref->is_wrote(); };
95 bool is_inode_dumped() const { return star_ref->is_dumped(); };
96 void set_inode_counted(bool val) const { star_ref->set_counted(val); };
97 void set_inode_wrote(bool val) const { star_ref->set_wrote(val); };
98 void set_inode_dumped(bool val) const { star_ref->set_dumped(val); };
99
100 virtual void post_constructor(const pile_descriptor & pdesc) override;
101
103 bool is_first_mirage() const { return star_ref->get_first_ref() == this; };
104
105 // overwriting virtual method from cat_entree
106 virtual void change_location(const smart_pointer<pile_descriptor> & pdesc) override { get_inode()->change_location(pdesc); };
107
109
117 void disable_reduction_to_normal_inode() { star_ref->disable_reduction_to_normal_inode(); };
118
119 protected:
120 virtual void inherited_dump(const pile_descriptor & pdesc, bool small) const override;
121
122 private:
123 cat_etoile *star_ref;
124
125 void init(const std::shared_ptr<user_interaction> & dialog,
126 const smart_pointer<pile_descriptor> & pdesc,
127 const archive_version & reading_ver,
128 saved_status saved,
129 entree_stats & stats,
130 std::map <infinint, cat_etoile *> & corres,
131 compression default_algo,
132 mirage_format fmt,
133 bool lax,
134 bool small);
135
136 void dup_on(cat_etoile * ref);
137 };
138
140
141} // end of namespace
142
143#endif
cat_etoile.hpp
class holding an cat_inode object that get pointed by multiple mirage objects (smart pointers) to rec...
cat_nomme.hpp
base class of all objects contained in a catalogue and that can be named
libdar::archive_version
class archive_version manages the version of the archive format
Definition archive_version.hpp:47
libdar::cat_entree
the root class from all other inherite for any entry in the catalogue
Definition cat_entree.hpp:60
libdar::cat_entree::change_location
virtual void change_location(const smart_pointer< pile_descriptor > &pdesc)
libdar::cat_etoile
the hard link implementation
Definition cat_etoile.hpp:48
libdar::cat_inode
the root class for all cat_inode
Definition cat_inode.hpp:53
libdar::cat_mirage
the hard link implementation, cat_mirage is the named entry owned by a directory it points to a commo...
Definition cat_mirage.hpp:48
libdar::cat_mirage::get_description
virtual std::string get_description() const override
inherited class designation
Definition cat_mirage.hpp:84
libdar::cat_mirage::mirage_format
mirage_format
format of mirage
Definition cat_mirage.hpp:51
libdar::cat_mirage::fmt_hard_link
@ fmt_hard_link
old dual format
Definition cat_mirage.hpp:52
libdar::cat_mirage::fmt_mirage
@ fmt_mirage
new format
Definition cat_mirage.hpp:51
libdar::cat_mirage::post_constructor
virtual void post_constructor(const pile_descriptor &pdesc) override
let inherited classes build object's data after CRC has been read from file in small read mode
libdar::cat_mirage::operator==
virtual bool operator==(const cat_entree &ref) const override
returns true if the two object are the same
libdar::cat_mirage::change_location
virtual void change_location(const smart_pointer< pile_descriptor > &pdesc) override
Definition cat_mirage.hpp:106
libdar::cat_mirage::inherited_dump
virtual void inherited_dump(const pile_descriptor &pdesc, bool small) const override
inherited class may overload this method but shall first call the parent's inherited_dump() in the ov...
libdar::cat_mirage::clone
virtual cat_entree * clone() const override
a way to copy the exact type of an object even if pointed to by a parent class pointer
Definition cat_mirage.hpp:86
libdar::cat_mirage::is_first_mirage
bool is_first_mirage() const
whether we are the mirage that triggered this hard link creation
Definition cat_mirage.hpp:103
libdar::cat_mirage::disable_reduction_to_normal_inode
void disable_reduction_to_normal_inode()
always write the inode as a hardlinked inode
Definition cat_mirage.hpp:117
libdar::cat_mirage::signature
virtual unsigned char signature() const override
inherited class signature
Definition cat_mirage.hpp:83
libdar::cat_nomme
the base class for all entry that have a name
Definition cat_nomme.hpp:45
libdar::smart_pointer
smart pointer class to be used to automagically manage multiple time pointed to address
Definition smart_pointer.hpp:79
libdar::compression
compression
the different compression algorithm available
Definition compression.hpp:46
libdar::saved_status
saved_status
data saved status for an entry
Definition cat_status.hpp:45
libdar::saved_status::saved
@ saved
inode is saved in the archive
my_config.h
include macro defined by the configure script and some specific additional ones
libdar
libdar namespace encapsulate all libdar symbols
Definition archive.hpp:47
libdar::entree_stats
holds the statistics contents of a catalogue
Definition entree_stats.hpp:49