|
Disk ARchive
2.4.12
|
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 00032 #include "../my_config.h" 00033 #include "infinint.hpp" 00034 #include "deci.hpp" 00035 #include "catalogue.hpp" 00036 #include "tools.hpp" 00037 #include "compressor.hpp" 00038 #include "integers.hpp" 00039 00040 namespace libdar 00041 { 00042 00051 class list_entry 00052 { 00053 public: 00054 list_entry(); 00055 00056 // methods for API users 00057 // field that are not set are returned as empty string 00058 00059 const std::string & get_name() const { return my_name; }; 00060 unsigned char get_type() const { return type; }; 00061 bool is_dir() const { return type == 'd'; }; 00062 bool is_file() const { return type == 'f'; }; 00063 bool is_symlink() const { return type == 'l'; }; 00064 bool is_char_device() const { return type == 'c'; }; 00065 bool is_block_device() const { return type == 'b'; }; 00066 bool is_unix_socket() const { return type == 's'; }; 00067 bool is_named_pipe() const { return type == 'p'; }; 00068 bool is_hard_linked() const { return hard_link; }; 00069 bool is_removed_entry() const { return type == 'x'; }; 00070 bool is_door_inode() const { return type == 'o'; }; 00071 00072 bool has_data_present_in_the_archive() const { return data_status == s_saved; }; 00073 bool has_EA() const { return ea_status != inode::ea_none && ea_status != inode::ea_removed; }; 00074 bool has_EA_saved_in_the_archive() const { return ea_status == inode::ea_full; }; 00075 00076 std::string get_uid() const { return deci(uid).human(); }; 00077 std::string get_gid() const { return deci(gid).human(); }; 00078 std::string get_perm() const { return tools_int2str(perm); }; 00079 std::string get_last_access() const { return last_access != 0 ? tools_display_date(last_access) : ""; }; 00080 std::string get_last_modif() const { return last_modif != 0 ? tools_display_date(last_modif) : ""; }; 00081 std::string get_last_change() const { return last_change != 0 ? tools_display_date(last_change) : ""; }; 00082 std::string get_file_size() const { return deci(file_size).human(); }; 00083 std::string get_compression_ratio() const { return tools_get_compression_ratio(storage_size, file_size); }; 00084 bool is_sparse() const { return sparse_file; }; 00085 std::string get_compression_algo() const { return compression2string(compression_algo); }; 00086 bool is_dirty() const { return dirty; }; 00087 std::string get_link_target() const { return target; }; 00088 std::string get_major() const { return tools_int2str(major); }; 00089 std::string get_minor() const { return tools_int2str(minor); }; 00090 00091 // methods for libdar to setup the object 00092 00093 void set_name(const std::string & val) { my_name = val; }; 00094 void set_type(unsigned char val) { type = val; }; 00095 void set_hard_link(bool val) { hard_link = val; }; 00096 void set_uid(const infinint & val) { uid = val; }; 00097 void set_gid(const infinint & val) { gid = val; }; 00098 void set_perm(U_16 val) { perm = val; }; 00099 void set_last_access(const infinint & val) { last_access = val; }; 00100 void set_last_modif(const infinint & val) { last_modif = val; }; 00101 void set_saved_status(saved_status val) { data_status = val; }; 00102 void set_ea_status(inode::ea_status val) { ea_status = val; }; 00103 void set_last_change(const infinint & val) { last_change = val; }; 00104 void set_file_size(const infinint & val) { file_size = val; }; 00105 void set_storage_size(const infinint & val) { storage_size = val; }; 00106 void set_is_sparse_file(bool val) { sparse_file = val; }; 00107 void set_compression_algo(compression val) { compression_algo = val; }; 00108 void set_dirtiness(bool val) { dirty = val; }; 00109 void set_link_target(const std::string & val) { target = val; }; 00110 void set_major(int val) { major = val; }; 00111 void set_minor(int val) { minor = val; }; 00112 00113 private: 00114 std::string my_name; 00115 bool hard_link; 00116 unsigned char type; 00117 infinint uid; 00118 infinint gid; 00119 U_16 perm; 00120 infinint last_access; 00121 infinint last_modif; 00122 saved_status data_status; 00123 inode::ea_status ea_status; 00124 infinint last_change; 00125 infinint file_size; 00126 infinint storage_size; 00127 bool sparse_file; 00128 compression compression_algo; 00129 bool dirty; 00130 std::string target; 00131 int major; 00132 int minor; 00133 }; 00134 00135 } // end of namespace 00136 00137 #endif
1.7.6.1