Disk ARchive  2.4.12
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups
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 
32 #include "../my_config.h"
33 #include "infinint.hpp"
34 #include "deci.hpp"
35 #include "catalogue.hpp"
36 #include "tools.hpp"
37 #include "compressor.hpp"
38 #include "integers.hpp"
39 
40 namespace libdar
41 {
42 
51  class list_entry
52  {
53  public:
54  list_entry();
55 
56  // methods for API users
57  // field that are not set are returned as empty string
58 
59  const std::string & get_name() const { return my_name; };
60  unsigned char get_type() const { return type; };
61  bool is_dir() const { return type == 'd'; };
62  bool is_file() const { return type == 'f'; };
63  bool is_symlink() const { return type == 'l'; };
64  bool is_char_device() const { return type == 'c'; };
65  bool is_block_device() const { return type == 'b'; };
66  bool is_unix_socket() const { return type == 's'; };
67  bool is_named_pipe() const { return type == 'p'; };
68  bool is_hard_linked() const { return hard_link; };
69  bool is_removed_entry() const { return type == 'x'; };
70  bool is_door_inode() const { return type == 'o'; };
71 
72  bool has_data_present_in_the_archive() const { return data_status == s_saved; };
73  bool has_EA() const { return ea_status != inode::ea_none && ea_status != inode::ea_removed; };
74  bool has_EA_saved_in_the_archive() const { return ea_status == inode::ea_full; };
75 
76  std::string get_uid() const { return deci(uid).human(); };
77  std::string get_gid() const { return deci(gid).human(); };
78  std::string get_perm() const { return tools_int2str(perm); };
79  std::string get_last_access() const { return last_access != 0 ? tools_display_date(last_access) : ""; };
80  std::string get_last_modif() const { return last_modif != 0 ? tools_display_date(last_modif) : ""; };
81  std::string get_last_change() const { return last_change != 0 ? tools_display_date(last_change) : ""; };
82  std::string get_file_size() const { return deci(file_size).human(); };
83  std::string get_compression_ratio() const { return tools_get_compression_ratio(storage_size, file_size); };
84  bool is_sparse() const { return sparse_file; };
85  std::string get_compression_algo() const { return compression2string(compression_algo); };
86  bool is_dirty() const { return dirty; };
87  std::string get_link_target() const { return target; };
88  std::string get_major() const { return tools_int2str(major); };
89  std::string get_minor() const { return tools_int2str(minor); };
90 
91  // methods for libdar to setup the object
92 
93  void set_name(const std::string & val) { my_name = val; };
94  void set_type(unsigned char val) { type = val; };
95  void set_hard_link(bool val) { hard_link = val; };
96  void set_uid(const infinint & val) { uid = val; };
97  void set_gid(const infinint & val) { gid = val; };
98  void set_perm(U_16 val) { perm = val; };
99  void set_last_access(const infinint & val) { last_access = val; };
100  void set_last_modif(const infinint & val) { last_modif = val; };
101  void set_saved_status(saved_status val) { data_status = val; };
102  void set_ea_status(inode::ea_status val) { ea_status = val; };
103  void set_last_change(const infinint & val) { last_change = val; };
104  void set_file_size(const infinint & val) { file_size = val; };
105  void set_storage_size(const infinint & val) { storage_size = val; };
106  void set_is_sparse_file(bool val) { sparse_file = val; };
107  void set_compression_algo(compression val) { compression_algo = val; };
108  void set_dirtiness(bool val) { dirty = val; };
109  void set_link_target(const std::string & val) { target = val; };
110  void set_major(int val) { major = val; };
111  void set_minor(int val) { minor = val; };
112 
113  private:
114  std::string my_name;
115  bool hard_link;
116  unsigned char type;
117  infinint uid;
118  infinint gid;
119  U_16 perm;
120  infinint last_access;
121  infinint last_modif;
122  saved_status data_status;
123  inode::ea_status ea_status;
124  infinint last_change;
125  infinint file_size;
126  infinint storage_size;
127  bool sparse_file;
128  compression compression_algo;
129  bool dirty;
130  std::string target;
131  int major;
132  int minor;
133  };
134 
135 } // end of namespace
136 
137 #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
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:51