Loading...
Searching...
No Matches
fichier_global.hpp
Go to the documentation of this file.
/*********************************************************************/
// dar - disk archive - a backup/restoration program
// Copyright (C) 2002-2026 Denis Corbin
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; either version 2
// of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// to contact the author, see the AUTHOR file
/*********************************************************************/
#ifndef FICHIER_GLOBAL_HPP
#define FICHIER_GLOBAL_HPP
#include "../my_config.h"
extern "C"
{
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
} // end extern "C"
#include "integers.hpp"
#include "generic_file.hpp"
#include "thread_cancellation.hpp"
#include "user_interaction.hpp"
#include "mem_ui.hpp"
#include <string>
namespace libdar
{
class fichier_global : public generic_file, public thread_cancellation, public mem_ui
{
public :
enum advise
{
advise_normal,
advise_sequential,
advise_random,
advise_noreuse,
advise_willneed,
advise_dontneed
};
fichier_global(const std::shared_ptr<user_interaction> & dialog,
gf_mode mode): generic_file(mode),
mem_ui(dialog),
disk_full(false) {};
fichier_global(const fichier_global & ref) = default;
fichier_global(fichier_global && ref) noexcept = default;
fichier_global & operator = (const fichier_global & ref) = default;
fichier_global & operator = (fichier_global && ref) noexcept = default;
// destructor
~fichier_global() = default;
virtual void change_ownership(const std::string & user, const std::string & group) = 0;
virtual void change_permission(U_I perm) = 0;
virtual infinint get_size() const = 0;
virtual void fadvise(advise adv) const = 0;
protected :
virtual U_I fichier_global_inherited_write(const char *a, U_I size) = 0;
virtual bool fichier_global_inherited_read(char *a, U_I size, U_I & read, std::string & message) = 0;
private:
bool disk_full;
// inherited from generic_file class and relocated as private methods
virtual void inherited_write(const char *a, U_I size) override;
virtual U_I inherited_read(char *a, U_I size) override;
};
} // end of namespace
#endif
libdar::fichier_global::inherited_read
virtual U_I inherited_read(char *a, U_I size) override
implementation of read() operation
libdar::fichier_global::advise
advise
Definition fichier_global.hpp:62
libdar::fichier_global::advise_random
@ advise_random
application expect to read the data in random order
Definition fichier_global.hpp:65
libdar::fichier_global::advise_noreuse
@ advise_noreuse
application does not expect to read the data more than once
Definition fichier_global.hpp:66
libdar::fichier_global::advise_willneed
@ advise_willneed
application expect to read the data again in near future
Definition fichier_global.hpp:67
libdar::fichier_global::advise_dontneed
@ advise_dontneed
application will not read the data in near future
Definition fichier_global.hpp:68
libdar::fichier_global::advise_sequential
@ advise_sequential
application expect to read the data sequentially
Definition fichier_global.hpp:64
libdar::fichier_global::advise_normal
@ advise_normal
no advise given by the application
Definition fichier_global.hpp:63
libdar::fichier_global::disk_full
bool disk_full
whether user refused to continue due to disk being full
Definition fichier_global.hpp:135
libdar::fichier_global::get_size
virtual infinint get_size() const =0
return the size of the file
libdar::fichier_global::fichier_global
fichier_global(const fichier_global &ref)=default
copy constructor
libdar::fichier_global::change_permission
virtual void change_permission(U_I perm)=0
change the permission of the file
libdar::fichier_global::fadvise
virtual void fadvise(advise adv) const =0
set posix_fadvise for the whole file
libdar::fichier_global::operator=
fichier_global & operator=(const fichier_global &ref)=default
assignment operator
libdar::fichier_global::fichier_global
fichier_global(fichier_global &&ref) noexcept=default
move constructor
libdar::fichier_global::fichier_global_inherited_write
virtual U_I fichier_global_inherited_write(const char *a, U_I size)=0
replaces generic_file::inherited_write() method, to allow the return of partial writings
libdar::fichier_global::change_ownership
virtual void change_ownership(const std::string &user, const std::string &group)=0
set the ownership of the file
libdar::fichier_global::inherited_write
virtual void inherited_write(const char *a, U_I size) override
implementation of the write() operation
libdar::fichier_global::fichier_global_inherited_read
virtual bool fichier_global_inherited_read(char *a, U_I size, U_I &read, std::string &message)=0
replaces generic_file::inherited_read() method, to allow the return of partial reading
libdar::fichier_global::fichier_global
fichier_global(const std::shared_ptr< user_interaction > &dialog, gf_mode mode)
constructor
Definition fichier_global.hpp:76
libdar::generic_file::generic_file
generic_file(gf_mode m)
main constructor
Definition generic_file.hpp:80
libdar::generic_file::read
virtual U_I read(char *a, U_I size) override
read data from the generic_file inherited from proto_generic_file
libdar::infinint
the arbitrary large positive integer class
Definition real_infinint.hpp:62
libdar::mem_ui::mem_ui
mem_ui(const std::shared_ptr< user_interaction > &dialog)
constructor
libdar::thread_cancellation::thread_cancellation
thread_cancellation()
the constructor
generic_file.hpp
class generic_file is defined here as well as class fichier
libdar::gf_mode
gf_mode
generic_file openning modes
Definition gf_mode.hpp:44
integers.hpp
are defined here basic integer types that tend to be portable
mem_ui.hpp
class mem_ui definition. This class is to be used as parent class to handle user_interaction object m...
my_config.h
include macro defined by the configure script and some specific additional ones
libdar
libdar namespace encapsulate all libdar symbols
Definition archive.hpp:47
thread_cancellation.hpp
to be able to cancel libdar operation while running in a given thread.
user_interaction.hpp
defines the interaction interface between libdar and users.