diff options
author | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:22:18 +0200 |
---|---|---|
committer | Daniel Wilhelm <daniel@wili.li> | 2014-04-18 17:22:18 +0200 |
commit | bcc5cc28c6dc5178e8f4fd0cc521034ae5def388 (patch) | |
tree | bacc60d27b435d32172f97643576c5e4e953177d /zen/file_io_base.h | |
parent | 5.9 (diff) | |
download | FreeFileSync-bcc5cc28c6dc5178e8f4fd0cc521034ae5def388.tar.gz FreeFileSync-bcc5cc28c6dc5178e8f4fd0cc521034ae5def388.tar.bz2 FreeFileSync-bcc5cc28c6dc5178e8f4fd0cc521034ae5def388.zip |
5.10
Diffstat (limited to 'zen/file_io_base.h')
-rw-r--r-- | zen/file_io_base.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/zen/file_io_base.h b/zen/file_io_base.h new file mode 100644 index 00000000..f26cd8c2 --- /dev/null +++ b/zen/file_io_base.h @@ -0,0 +1,64 @@ +// ************************************************************************** +// * This file is part of the FreeFileSync project. It is distributed under * +// * GNU General Public License: http://www.gnu.org/licenses/gpl.html * +// * Copyright (C) Zenju (zenju AT gmx DOT de) - All Rights Reserved * +// ************************************************************************** + +#ifndef FILEIO_BASE_H_INCLUDED_23432431789615314 +#define FILEIO_BASE_H_INCLUDED_23432431789615314 + +#include "zstring.h" + +namespace zen +{ +class FileBase +{ +public: + const Zstring& getFilename() const { return filename_; } + +protected: + FileBase(const Zstring& filename) : filename_(filename) {} + ~FileBase() {} + +private: + FileBase(const FileBase&); + FileBase& operator=(const FileBase&); + + const Zstring filename_; +}; + + +class FileInputBase : public FileBase +{ +public: + virtual size_t read(void* buffer, size_t bytesToRead) = 0; //throw FileError; returns actual number of bytes read + bool eof() const { return eofReached; } //end of file reached + +protected: + FileInputBase(const Zstring& filename) : FileBase(filename), eofReached(false) {} + ~FileInputBase() {} + void setEof() { eofReached = true; } + +private: + bool eofReached; +}; + + +class FileOutputBase : public FileBase +{ +public: + enum AccessFlag + { + ACC_OVERWRITE, + ACC_CREATE_NEW + }; + virtual void write(const void* buffer, size_t bytesToWrite) = 0; //throw FileError + +protected: + FileOutputBase(const Zstring& filename) : FileBase(filename) {} + ~FileOutputBase() {} +}; + +} + +#endif //FILEIO_BASE_H_INCLUDED_23432431789615314 |