Disk ARchive  2.4.17
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules
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 extern "C"
31 {
32 #if HAVE_SYS_TYPES_H
33 #include <sys/types.h>
34 #endif
35 
36 #if HAVE_SYS_STAT_H
37 #include <sys/stat.h>
38 #endif
39 
40 #if HAVE_UNISTD_H
41 #include <unistd.h>
42 #endif
43 }
44 
45 #include <string>
46 
47 #include "../my_config.h"
48 #include "infinint.hpp"
49 #include "deci.hpp"
50 #include "catalogue.hpp"
51 #include "tools.hpp"
52 #include "compressor.hpp"
53 #include "integers.hpp"
54 
55 namespace libdar
56 {
57 
66  class list_entry
67  {
68  public:
69  list_entry();
70 
71  // methods for API users
72  // field that are not set are returned as empty string
73 
74  const std::string & get_name() const { return my_name; };
75  unsigned char get_type() const { return type; };
76  bool is_dir() const { return type == 'd'; };
77  bool is_file() const { return type == 'f'; };
78  bool is_symlink() const { return type == 'l'; };
79  bool is_char_device() const { return type == 'c'; };
80  bool is_block_device() const { return type == 'b'; };
81  bool is_unix_socket() const { return type == 's'; };
82  bool is_named_pipe() const { return type == 'p'; };
83  bool is_hard_linked() const { return hard_link; };
84  bool is_removed_entry() const { return type == 'x'; };
85  bool is_door_inode() const { return type == 'o'; };
86 
87  bool has_data_present_in_the_archive() const { return data_status == s_saved; };
88  bool has_EA() const { return ea_status != inode::ea_none && ea_status != inode::ea_removed; };
89  bool has_EA_saved_in_the_archive() const { return ea_status == inode::ea_full; };
90 
91  std::string get_uid() const { return deci(uid).human(); };
92  std::string get_gid() const { return deci(gid).human(); };
93  std::string get_perm() const { return tools_int2str(perm); };
94  std::string get_last_access() const { return last_access != 0 ? tools_display_date(last_access) : ""; };
95  time_t get_last_access_s() const { return infinint2time_t(last_access); };
96  std::string get_last_modif() const { return last_modif != 0 ? tools_display_date(last_modif) : ""; };
97  time_t get_last_modif_s() const { return infinint2time_t(last_modif); };
98  std::string get_last_change() const { return last_change != 0 ? tools_display_date(last_change) : ""; };
99  time_t get_last_change_s() const { return infinint2time_t(last_change); };
100  std::string get_file_size() const { return deci(file_size).human(); };
101  std::string get_compression_ratio() const { return tools_get_compression_ratio(storage_size, file_size); };
102  bool is_sparse() const { return sparse_file; };
103  std::string get_compression_algo() const { return compression2string(compression_algo); };
104  bool is_dirty() const { return dirty; };
105  std::string get_link_target() const { return target; };
106  std::string get_major() const { return tools_int2str(major); };
107  std::string get_minor() const { return tools_int2str(minor); };
108 
109 
110  // methods for libdar to setup the object
111 
112  void set_name(const std::string & val) { my_name = val; };
113  void set_type(unsigned char val) { type = val; };
114  void set_hard_link(bool val) { hard_link = val; };
115  void set_uid(const infinint & val) { uid = val; };
116  void set_gid(const infinint & val) { gid = val; };
117  void set_perm(U_16 val) { perm = val; };
118  void set_last_access(const infinint & val) { last_access = val; };
119  void set_last_modif(const infinint & val) { last_modif = val; };
120  void set_saved_status(saved_status val) { data_status = val; };
121  void set_ea_status(inode::ea_status val) { ea_status = val; };
122  void set_last_change(const infinint & val) { last_change = val; };
123  void set_file_size(const infinint & val) { file_size = val; };
124  void set_storage_size(const infinint & val) { storage_size = val; };
125  void set_is_sparse_file(bool val) { sparse_file = val; };
126  void set_compression_algo(compression val) { compression_algo = val; };
127  void set_dirtiness(bool val) { dirty = val; };
128  void set_link_target(const std::string & val) { target = val; };
129  void set_major(int val) { major = val; };
130  void set_minor(int val) { minor = val; };
131 
132  private:
133  std::string my_name;
134  bool hard_link;
135  unsigned char type;
136  infinint uid;
137  infinint gid;
138  U_16 perm;
139  infinint last_access;
140  infinint last_modif;
141  saved_status data_status;
142  inode::ea_status ea_status;
143  infinint last_change;
144  infinint file_size;
145  infinint storage_size;
146  bool sparse_file;
147  compression compression_algo;
148  bool dirty;
149  std::string target;
150  int major;
151  int minor;
152 
153  static time_t infinint2time_t(infinint val);
154  };
155 
156 } // end of namespace
157 
158 #endif
are defined here basic integer types that tend to be portable
std::string tools_display_date(infinint date)
convert a date in second to its human readable representation
a set of general purpose routines
decimal class, convert infinint from and to decimal represention
Definition: deci.hpp:49
std::string tools_int2str(S_I x)
convert integer to string
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
compression engine implementation
the arbitrary large positive integer class
std::string human() const
this produce a string fromr the decimal stored in the current object
libdar namespace encapsulate all libdar symbols
Definition: archive.hpp:43
std::string tools_get_compression_ratio(const infinint &storage_size, const infinint &file_size)
return the string about compression ratio
here is defined the many classed which is build of the catalogue
Definition: list_entry.hpp:66