diff options
author | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2014-06-03 02:14:32 -0700 |
---|---|---|
committer | Nicolas "Pixel" Noble <pixel@nobis-crew.org> | 2014-06-03 02:14:32 -0700 |
commit | 0243f128ddc7ee44db1a8b95f76eb726122ee1d5 (patch) | |
tree | 849119ab62379a31ef28f6fb8303b8824d0bb142 /includes | |
parent | 185dc2e4a06c52937a3f260b2469cda7d62f6112 (diff) |
Added MMap Handle object.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/Buffer.h | 22 | ||||
-rw-r--r-- | includes/MMap.h | 22 |
2 files changed, 34 insertions, 10 deletions
diff --git a/includes/Buffer.h b/includes/Buffer.h index c0d269a..6b5318f 100644 --- a/includes/Buffer.h +++ b/includes/Buffer.h @@ -8,19 +8,21 @@ class Buffer : public SeekableHandle { public: Buffer(const uint8_t * buffer, size_t s) : m_buffer(const_cast<uint8_t *>(buffer)), m_bufSize(s), m_fromConst(true) { } Buffer() throw (GeneralException) { } - virtual ~Buffer(); - virtual void close() throw (GeneralException); - virtual ssize_t read(void * buf, size_t count) throw (GeneralException); - virtual ssize_t write(const void * buf, size_t count) throw (GeneralException); - virtual bool isClosed(); - virtual bool isEOF(); - virtual bool canRead(); - virtual bool canWrite(); - virtual const char * getName(); - virtual off64_t getSize(); + virtual ~Buffer() override; + virtual void close() throw (GeneralException) override; + virtual ssize_t read(void * buf, size_t count) throw (GeneralException) override; + virtual ssize_t write(const void * buf, size_t count) throw (GeneralException) override; + virtual bool isClosed() override; + virtual bool isEOF() override; + virtual bool canRead() override; + virtual bool canWrite() override; + virtual const char * getName() override; + virtual off64_t getSize() override; const uint8_t * getBuffer() { return m_buffer + rtell(); } void reset(); + void clear(); void rewind() { rseek(0); wseek(0); } + void borrow(const uint8_t * buffer, size_t s); private: uint8_t * m_buffer = NULL; bool m_fromConst = false; diff --git a/includes/MMap.h b/includes/MMap.h new file mode 100644 index 0000000..ad55e4c --- /dev/null +++ b/includes/MMap.h @@ -0,0 +1,22 @@ +#pragma once + +#include <Buffer.h> + +namespace Balau { + +class MMapPlatform; + +class MMap : public Buffer { + public: + MMap(const char * fname); + virtual ~MMap() override; + void open() throw (GeneralException); + virtual const char * getName() override { return m_name.to_charp(); } + virtual void close() override; + private: + MMapPlatform * m_platform = NULL; + String m_name; + String m_fname; +}; + +}; |