Disk ARchive  2.5.1
Full featured and portable backup and archiving tool
list_entry.hpp
Go to the documentation of this file.
1 /*********************************************************************/
2 // dar - disk archive - a backup/restoration program
3 // Copyright (C) 2002-2052 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 //
19 // to contact the author : http://dar.linux.free.fr/email.html
20 /*********************************************************************/
21 
25 
26 
27 #ifndef LIST_ENTRY_HPP
28 #define LIST_ENTRY_HPP
29 
30 #include <string>
31 #include <set>
32 
33 #include "../my_config.h"
34 #include "infinint.hpp"
35 #include "deci.hpp"
36 #include "catalogue.hpp"
37 #include "tools.hpp"
38 #include "compressor.hpp"
39 #include "integers.hpp"
40 #include "on_pool.hpp"
41 #include "datetime.hpp"
42 #include "range.hpp"
43 
44 namespace libdar
45 {
46 
55  class list_entry : public on_pool
56  {
57  public:
58  list_entry();
59 
60  // methods for API users
61  // field that are not set are returned as empty string
62 
63  const std::string & get_name() const { return my_name; };
64  unsigned char get_type() const { return type; };
65  bool is_dir() const { return type == 'd'; };
66  bool is_file() const { return type == 'f'; };
67  bool is_symlink() const { return type == 'l'; };
68  bool is_char_device() const { return type == 'c'; };
69  bool is_block_device() const { return type == 'b'; };
70  bool is_unix_socket() const { return type == 's'; };
71  bool is_named_pipe() const { return type == 'p'; };
72  bool is_hard_linked() const { return hard_link; };
73  bool is_removed_entry() const { return type == 'x'; };
74  bool is_door_inode() const { return type == 'o'; };
75 
76  bool has_data_present_in_the_archive() const { return data_status == s_saved; };
77  bool has_EA() const { return ea_status != cat_inode::ea_none && ea_status != cat_inode::ea_removed; };
78  bool has_EA_saved_in_the_archive() const { return ea_status == cat_inode::ea_full; };
79  bool has_FSA() const { return fsa_status != cat_inode::fsa_none; };
80  bool has_FSA_saved_in_the_archive() const { return fsa_status == cat_inode::fsa_full; };
81 
82  std::string get_uid() const { return deci(uid).human(); };
83  std::string get_gid() const { return deci(gid).human(); };
84  std::string get_perm() const { return tools_get_permission_string(type, perm, hard_link); };
85  std::string get_last_access() const { return last_access.is_null() ? "" : tools_display_date(last_access); };
86  std::string get_last_modif() const { return last_modif.is_null() ? "" : tools_display_date(last_modif); };
87  std::string get_last_change() const { return last_change.is_null() ? "" : tools_display_date(last_change); };
88  time_t get_last_access_s() const { return datetime2time_t(last_access); };
89  time_t get_last_modif_s() const { return datetime2time_t(last_modif); };
90  time_t get_last_change_s() const { return datetime2time_t(last_change); };
91 
97  void get_last_access(datetime::time_unit tu, time_t & second, time_t & fraction) const
98  { last_access.get_value(second, fraction, tu); }
99 
101  void get_last_modif(datetime::time_unit tu, time_t & second, time_t & fraction) const
102  { last_modif.get_value(second, fraction, tu); }
103 
105  void get_last_change(datetime::time_unit tu, time_t & second, time_t & fraction) const
106  { last_change.get_value(second, fraction, tu); }
107 
108  std::string get_file_size() const { return deci(file_size).human(); };
109  std::string get_compression_ratio() const { return tools_get_compression_ratio(storage_size, file_size, compression_algo != none); };
110  bool is_sparse() const { return sparse_file; };
111  std::string get_compression_algo() const { return compression2string(compression_algo); };
112  bool is_dirty() const { return dirty; };
113  std::string get_link_target() const { return target; };
114  std::string get_major() const { return tools_int2str(major); };
115  std::string get_minor() const { return tools_int2str(minor); };
116  const range & get_slices() const { return slices; };
117 
118 
119  // methods for libdar to setup the object
120 
121  void set_name(const std::string & val) { my_name = val; };
122  void set_type(unsigned char val) { type = val; };
123  void set_hard_link(bool val) { hard_link = val; };
124  void set_uid(const infinint & val) { uid = val; };
125  void set_gid(const infinint & val) { gid = val; };
126  void set_perm(U_16 val) { perm = val; };
127  void set_last_access(const datetime & val) { last_access = val; };
128  void set_last_modif(const datetime & val) { last_modif = val; };
129  void set_saved_status(saved_status val) { data_status = val; };
130  void set_ea_status(cat_inode::ea_status val) { ea_status = val; };
131  void set_last_change(const datetime & val) { last_change = val; };
132  void set_fsa_status(cat_inode::fsa_status val) { fsa_status = val; };
133  void set_file_size(const infinint & val) { file_size = val; };
134  void set_storage_size(const infinint & val) { storage_size = val; };
135  void set_is_sparse_file(bool val) { sparse_file = val; };
136  void set_compression_algo(compression val) { compression_algo = val; };
137  void set_dirtiness(bool val) { dirty = val; };
138  void set_link_target(const std::string & val) { target = val; };
139  void set_major(int val) { major = val; };
140  void set_minor(int val) { minor = val; };
141  void set_slices(const range & sl) { slices = sl; };
142 
143  private:
144  std::string my_name;
145  bool hard_link;
146  unsigned char type;
147  infinint uid;
148  infinint gid;
149  U_16 perm;
150  datetime last_access;
151  datetime last_modif;
152  saved_status data_status;
153  cat_inode::ea_status ea_status;
154  datetime last_change;
155  cat_inode::fsa_status fsa_status;
156  infinint file_size;
157  infinint storage_size;
158  bool sparse_file;
159  compression compression_algo;
160  bool dirty;
161  std::string target;
162  int major;
163  int minor;
164  range slices;
165 
166  static time_t datetime2time_t(const datetime & val);
167  };
168 
169 } // end of namespace
170 
171 #endif
are defined here basic integer types that tend to be portable
a set of general purpose routines
decimal class, convert infinint from and to decimal represention
Definition: deci.hpp:50
void get_last_change(datetime::time_unit tu, time_t &second, time_t &fraction) const
yet an alternative method to get the last change date (see get_last_access() for details) ...
Definition: list_entry.hpp:105
no compression
Definition: compressor.hpp:45
void get_last_modif(datetime::time_unit tu, time_t &second, time_t &fraction) const
yet an alternative method to get the last modification date (see get_last_access() for details) ...
Definition: list_entry.hpp:101
std::string tools_display_date(const datetime &date)
convert a date in second to its human readable representation
void get_last_access(datetime::time_unit tu, time_t &second, time_t &fraction) const
Definition: list_entry.hpp:97
std::string tools_int2str(S_I x)
convert integer to string
std::string tools_get_permission_string(char type, U_32 perm, bool hard)
convert a permission number into its string representation (rwxrwxrwx)
switch module to limitint (32 ou 64 bits integers) or infinint
manages the decimal representation of infinint
compression
the different compression algorithm available
Definition: compressor.hpp:43
this file contains the definition of class datetime that stores unix times in a portable way ...
compression engine implementation
this is the base class of object that can be allocated on a memory pool
std::string tools_get_compression_ratio(const infinint &storage_size, const infinint &file_size, bool compressed)
return the string about compression ratio
class than provide a way to manipulate and represent range of integer numbers (infinint) ...
std::string human() const
this produce a string from the decimal stored in the current object
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:47
here is defined the many classed which is build of the catalogue
Definition: list_entry.hpp:55