diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/Handle.h | 1 | ||||
-rw-r--r-- | includes/Input.h | 2 | ||||
-rw-r--r-- | includes/ZHandle.h | 20 |
3 files changed, 20 insertions, 3 deletions
diff --git a/includes/Handle.h b/includes/Handle.h index 32a5975..091c59c 100644 --- a/includes/Handle.h +++ b/includes/Handle.h @@ -52,6 +52,7 @@ class Handle { virtual off_t wtell() throw (GeneralException); virtual off_t getSize(); virtual time_t getMTime(); + virtual bool isPendingComplete() { return true; } ssize_t forceRead(void * buf, size_t count, Events::BaseEvent * evt = NULL) throw (GeneralException); ssize_t forceWrite(const void * buf, size_t count, Events::BaseEvent * evt = NULL) throw (GeneralException); ssize_t write(const String & str) { return write(str.to_charp(), str.strlen()); } diff --git a/includes/Input.h b/includes/Input.h index af17107..09e0ee4 100644 --- a/includes/Input.h +++ b/includes/Input.h @@ -15,7 +15,7 @@ class Input : public SeekableHandle { virtual const char * getName(); virtual off_t getSize(); virtual time_t getMTime(); - bool isPendingComplete(); + virtual bool isPendingComplete(); const char * getFName() { return m_fname.to_charp(); } private: int m_fd = -1; diff --git a/includes/ZHandle.h b/includes/ZHandle.h index 5750365..8164853 100644 --- a/includes/ZHandle.h +++ b/includes/ZHandle.h @@ -2,6 +2,7 @@ #include <zlib.h> #include <Handle.h> +#include <Async.h> namespace Balau { @@ -24,13 +25,28 @@ class ZStream : public Handle { void detach() { m_detached = true; } void flush() { doFlush(false); } void setUseAsyncOp(bool useAsyncOp) { m_useAsyncOp = useAsyncOp; } - private: + virtual bool isPendingComplete(); void finish() { doFlush(true); } void doFlush(bool finish); + private: IO<Handle> m_h; z_stream m_zin, m_zout; String m_name; - uint8_t * m_in = NULL; + uint8_t * m_buf = NULL; + uint8_t * m_wptr; + enum { + IDLE, + READING, + WRITING, + COMPRESSING, + COMPRESSING_IDLE, + DECOMPRESSING, + DECOMPRESSING_IDLE, + CLOSING, + } m_phase = IDLE; + size_t m_total, m_count, m_compressed; + AsyncOperation * m_op = NULL; + ssize_t m_status; bool m_detached = false, m_closed = false, m_eof = false, m_useAsyncOp = true; }; |