Disk ARchive  2.5.2
Full featured and portable backup and archiving tool
entrepot.hpp
Go to the documentation of this file.
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 // $Id: entrepot.hpp,v 1.1 2012/04/27 11:24:30 edrusb Exp $
00022 //
00023 /*********************************************************************/
00024 
00025 
00036 
00038 
00039 #ifndef ENTREPOT_HPP
00040 #define ENTREPOT_HPP
00041 
00042 #include "../my_config.h"
00043 
00044 #include <string>
00045 #include "infinint.hpp"
00046 #include "generic_file.hpp"
00047 #include "user_interaction.hpp"
00048 #include "fichier_global.hpp"
00049 #include "hash_fichier.hpp"
00050 #include "etage.hpp"
00051 #include "path.hpp"
00052 #include "on_pool.hpp"
00053 
00054 namespace libdar
00055 {
00058 
00060 
00061     class entrepot : public on_pool
00062     {
00063     public:
00064 
00066     entrepot();
00067 
00069     virtual ~entrepot() {};
00070 
00072     bool operator == (const entrepot & ref) const { return get_url() == ref.get_url(); };
00073 
00074 
00076     void set_location(const path & chemin);
00077 
00079     void set_root(const path & p_root) { if(p_root.is_relative()) throw Erange("entrepot::set_root", std::string(gettext("root's entrepot must be an absolute path: ")) + p_root.display()); root = p_root; };
00080 
00082     void set_user_ownership(const std::string & x_user) { user = x_user; };
00083     void set_group_ownership(const std::string & x_group) { group = x_group; };
00084 
00085     const path & get_location() const { return where; }; //< retreives relative to root path the current location points to
00086     const path & get_root() const { return root; };      //< retrieves the given root location
00087     path get_full_path() const;
00088     virtual std::string get_url() const = 0; //< defines an URL-like normalized full location of slices
00089     const std::string & get_user_ownership() const { return user; };
00090     const std::string & get_group_ownership() const { return group; };
00091 
00104     fichier_global *open(user_interaction & dialog,
00105                  const std::string & filename,
00106                  gf_mode mode,
00107                  bool force_permission,
00108                  U_I permission,
00109                  bool fail_if_exists,
00110                  bool erase,
00111                  hash_algo algo) const;
00112 
00114     virtual void read_dir_reset() = 0;
00115     virtual bool read_dir_next(std::string & filename) = 0;
00116 
00117     void unlink(const std::string & filename) const { inherited_unlink(filename); }; //< done this way for homogeneity with open/inherited_open
00118 
00119 
00120     virtual entrepot *clone() const = 0;
00121 
00122     protected:
00123     virtual fichier_global *inherited_open(user_interaction & dialog,     //< for user interaction
00124                            const std::string & filename,  //< filename to open
00125                            gf_mode mode,                  //< mode to use
00126                            bool force_permission,         //< set the permission of the file to open
00127                            U_I permission,                //< value of the permission to assign when force_permission is true
00128                            bool fail_if_exists,           //< whether to fail if file exists (write mode)
00129                            bool erase) const = 0;         //< whether to erase file if file already exists (write mode)
00130 
00131     virtual void inherited_unlink(const std::string & filename) const = 0;
00132 
00133     virtual void read_dir_flush() = 0; //< ends the read_dir_next, (no more entry available)
00134 
00135     private:
00136     path where;
00137         path root;
00138     std::string user;
00139     std::string group;
00140     };
00141 
00143 
00144 } // end of namespace
00145 
00146 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines