![]() |
Disk ARchive
2.5.2
Full featured and portable backup and archiving tool
|
00001 /*********************************************************************/ 00002 // dar - disk archive - a backup/restoration program 00003 // Copyright (C) 2002-2052 Denis Corbin 00004 // 00005 // This program is free software; you can redistribute it and/or 00006 // modify it under the terms of the GNU General Public License 00007 // as published by the Free Software Foundation; either version 2 00008 // of the License, or (at your option) any later version. 00009 // 00010 // This program is distributed in the hope that it will be useful, 00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 // GNU General Public License for more details. 00014 // 00015 // You should have received a copy of the GNU General Public License 00016 // along with this program; if not, write to the Free Software 00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00018 // 00019 // to contact the author : http://dar.linux.free.fr/email.html 00020 /*********************************************************************/ 00021 00025 00026 00027 #ifndef LIST_ENTRY_HPP 00028 #define LIST_ENTRY_HPP 00029 00030 #include <string> 00031 #include <set> 00032 00033 #include "../my_config.h" 00034 #include "infinint.hpp" 00035 #include "deci.hpp" 00036 #include "catalogue.hpp" 00037 #include "tools.hpp" 00038 #include "compressor.hpp" 00039 #include "integers.hpp" 00040 #include "on_pool.hpp" 00041 #include "datetime.hpp" 00042 #include "range.hpp" 00043 00044 namespace libdar 00045 { 00046 00055 class list_entry : public on_pool 00056 { 00057 public: 00058 list_entry(); 00059 00060 // methods for API users 00061 // field that are not set are returned as empty string 00062 00063 const std::string & get_name() const { return my_name; }; 00064 unsigned char get_type() const { return type; }; 00065 bool is_dir() const { return type == 'd'; }; 00066 bool is_file() const { return type == 'f'; }; 00067 bool is_symlink() const { return type == 'l'; }; 00068 bool is_char_device() const { return type == 'c'; }; 00069 bool is_block_device() const { return type == 'b'; }; 00070 bool is_unix_socket() const { return type == 's'; }; 00071 bool is_named_pipe() const { return type == 'p'; }; 00072 bool is_hard_linked() const { return hard_link; }; 00073 bool is_removed_entry() const { return type == 'x'; }; 00074 bool is_door_inode() const { return type == 'o'; }; 00075 00076 bool has_data_present_in_the_archive() const { return data_status == s_saved; }; 00077 bool has_EA() const { return ea_status != cat_inode::ea_none && ea_status != cat_inode::ea_removed; }; 00078 bool has_EA_saved_in_the_archive() const { return ea_status == cat_inode::ea_full; }; 00079 bool has_FSA() const { return fsa_status != cat_inode::fsa_none; }; 00080 bool has_FSA_saved_in_the_archive() const { return fsa_status == cat_inode::fsa_full; }; 00081 00082 std::string get_uid() const { return deci(uid).human(); }; 00083 std::string get_gid() const { return deci(gid).human(); }; 00084 std::string get_perm() const { return tools_get_permission_string(type, perm, hard_link); }; 00085 std::string get_last_access() const { return last_access.is_null() ? "" : tools_display_date(last_access); }; 00086 std::string get_last_modif() const { return last_modif.is_null() ? "" : tools_display_date(last_modif); }; 00087 std::string get_last_change() const { return last_change.is_null() ? "" : tools_display_date(last_change); }; 00088 time_t get_last_access_s() const { return datetime2time_t(last_access); }; 00089 time_t get_last_modif_s() const { return datetime2time_t(last_modif); }; 00090 time_t get_last_change_s() const { return datetime2time_t(last_change); }; 00091 00097 void get_last_access(datetime::time_unit tu, time_t & second, time_t & fraction) const 00098 { last_access.get_value(second, fraction, tu); } 00099 00101 void get_last_modif(datetime::time_unit tu, time_t & second, time_t & fraction) const 00102 { last_modif.get_value(second, fraction, tu); } 00103 00105 void get_last_change(datetime::time_unit tu, time_t & second, time_t & fraction) const 00106 { last_change.get_value(second, fraction, tu); } 00107 00108 std::string get_file_size() const { return deci(file_size).human(); }; 00109 std::string get_compression_ratio() const { return tools_get_compression_ratio(storage_size, file_size, compression_algo != none); }; 00110 bool is_sparse() const { return sparse_file; }; 00111 std::string get_compression_algo() const { return compression2string(compression_algo); }; 00112 bool is_dirty() const { return dirty; }; 00113 std::string get_link_target() const { return target; }; 00114 std::string get_major() const { return tools_int2str(major); }; 00115 std::string get_minor() const { return tools_int2str(minor); }; 00116 const range & get_slices() const { return slices; }; 00117 00118 00119 // methods for libdar to setup the object 00120 00121 void set_name(const std::string & val) { my_name = val; }; 00122 void set_type(unsigned char val) { type = val; }; 00123 void set_hard_link(bool val) { hard_link = val; }; 00124 void set_uid(const infinint & val) { uid = val; }; 00125 void set_gid(const infinint & val) { gid = val; }; 00126 void set_perm(U_16 val) { perm = val; }; 00127 void set_last_access(const datetime & val) { last_access = val; }; 00128 void set_last_modif(const datetime & val) { last_modif = val; }; 00129 void set_saved_status(saved_status val) { data_status = val; }; 00130 void set_ea_status(cat_inode::ea_status val) { ea_status = val; }; 00131 void set_last_change(const datetime & val) { last_change = val; }; 00132 void set_fsa_status(cat_inode::fsa_status val) { fsa_status = val; }; 00133 void set_file_size(const infinint & val) { file_size = val; }; 00134 void set_storage_size(const infinint & val) { storage_size = val; }; 00135 void set_is_sparse_file(bool val) { sparse_file = val; }; 00136 void set_compression_algo(compression val) { compression_algo = val; }; 00137 void set_dirtiness(bool val) { dirty = val; }; 00138 void set_link_target(const std::string & val) { target = val; }; 00139 void set_major(int val) { major = val; }; 00140 void set_minor(int val) { minor = val; }; 00141 void set_slices(const range & sl) { slices = sl; }; 00142 00143 private: 00144 std::string my_name; 00145 bool hard_link; 00146 unsigned char type; 00147 infinint uid; 00148 infinint gid; 00149 U_16 perm; 00150 datetime last_access; 00151 datetime last_modif; 00152 saved_status data_status; 00153 cat_inode::ea_status ea_status; 00154 datetime last_change; 00155 cat_inode::fsa_status fsa_status; 00156 infinint file_size; 00157 infinint storage_size; 00158 bool sparse_file; 00159 compression compression_algo; 00160 bool dirty; 00161 std::string target; 00162 int major; 00163 int minor; 00164 range slices; 00165 00166 static time_t datetime2time_t(const datetime & val); 00167 }; 00168 00169 } // end of namespace 00170 00171 #endif