summaryrefslogtreecommitdiff
path: root/shell/inc
diff options
context:
space:
mode:
authorFridrich Štrba <fridrich.strba@bluewin.ch>2012-03-19 15:09:34 +0100
committerFridrich Štrba <fridrich.strba@bluewin.ch>2012-03-19 15:22:55 +0100
commit04366df3bca16d4e0cbe254551e44427ae6338bb (patch)
tree92fcb6ed5e6f877aecd53777b07c389f643b710e /shell/inc
parent43061897a69fbfc765170e87588f843fbd540e52 (diff)
Simple Zip file-format implementation to avoid the need of minizip
Diffstat (limited to 'shell/inc')
-rw-r--r--shell/inc/internal/basereader.hxx2
-rw-r--r--shell/inc/internal/contentreader.hxx3
-rw-r--r--shell/inc/internal/metainforeader.hxx2
-rw-r--r--shell/inc/internal/stream_helper.hxx24
-rw-r--r--shell/inc/internal/types.hxx17
-rw-r--r--shell/inc/internal/zipfile.hxx29
6 files changed, 53 insertions, 24 deletions
diff --git a/shell/inc/internal/basereader.hxx b/shell/inc/internal/basereader.hxx
index bb5c27645e2a..7a154103e44c 100644
--- a/shell/inc/internal/basereader.hxx
+++ b/shell/inc/internal/basereader.hxx
@@ -46,7 +46,7 @@ public:
protected: // protected because its only an implementation relevant class
CBaseReader( const std::string& DocumentName );
- CBaseReader( void* stream, zlib_filefunc_def* fa );
+ CBaseReader( StreamInterface *stream );
virtual void start_document();
diff --git a/shell/inc/internal/contentreader.hxx b/shell/inc/internal/contentreader.hxx
index 6a7dc594af60..e55a76035b90 100644
--- a/shell/inc/internal/contentreader.hxx
+++ b/shell/inc/internal/contentreader.hxx
@@ -32,6 +32,7 @@
#include "internal/basereader.hxx"
class ITag;
+class StreamInterface;
class CContentReader : public CBaseReader
{
@@ -40,7 +41,7 @@ public:
CContentReader( const std::string& DocumentName, LocaleSet_t const & DocumentLocale );
- CContentReader( void* stream, LocaleSet_t const & DocumentLocale, zlib_filefunc_def* fa );
+ CContentReader( StreamInterface* stream, LocaleSet_t const & DocumentLocale );
/** Get the chunkbuffer.
diff --git a/shell/inc/internal/metainforeader.hxx b/shell/inc/internal/metainforeader.hxx
index 516224571078..a0ed7d9584c1 100644
--- a/shell/inc/internal/metainforeader.hxx
+++ b/shell/inc/internal/metainforeader.hxx
@@ -44,7 +44,7 @@ public:
CMetaInfoReader( const std::string& DocumentName );
- CMetaInfoReader( void* stream, zlib_filefunc_def* fa);
+ CMetaInfoReader( StreamInterface* stream );
/** check if the Tag is in the target meta.xml file.
diff --git a/shell/inc/internal/stream_helper.hxx b/shell/inc/internal/stream_helper.hxx
index bd31ee111315..72eaf7355b2c 100644
--- a/shell/inc/internal/stream_helper.hxx
+++ b/shell/inc/internal/stream_helper.hxx
@@ -31,7 +31,29 @@
#include "internal/types.hxx"
-IStream* PrepareIStream( IStream* pStream, zlib_filefunc_def &zFileFunc );
+class BufferStream : public StreamInterface
+{
+public:
+ BufferStream(IStream *str);
+ ~BufferStream();
+ unsigned long sread (unsigned char *vuf, unsigned long size);
+ long stell ();
+ long sseek (unsigned long offset, int origin);
+private:
+ IStream *stream;
+};
+
+class FileStream : public StreamInterface
+{
+public:
+ FileStream(const char *filename);
+ ~FileStream();
+ unsigned long sread (unsigned char *buf, unsigned long size);
+ long stell ();
+ long sseek (unsigned long offset, int origin);
+private:
+ FILE *file;
+};
#endif
diff --git a/shell/inc/internal/types.hxx b/shell/inc/internal/types.hxx
index 0c6810aec0d0..c6fbfac5e50c 100644
--- a/shell/inc/internal/types.hxx
+++ b/shell/inc/internal/types.hxx
@@ -35,14 +35,6 @@
#include <vector>
#include <stack>
-#if defined SYSTEM_ZLIB
-#include <zlib.h>
-#include <minizip/ioapi.h>
-#else
-#include <external/zlib/zlib.h>
-#include <external/zlib/ioapi.h>
-#endif
-
typedef std::vector<std::wstring> StringList_t;
//+-------------------------------------------------------------------------
@@ -89,6 +81,15 @@ typedef ::std::map<StyleName_t, LocaleSet_t> StyleLocaleMap_t;
const StyleLocalePair_t EMPTY_STYLELOCALE_PAIR = ::std::make_pair(::std::wstring(), EMPTY_LOCALE );
+class StreamInterface
+{
+public:
+ virtual ~StreamInterface() {}
+ virtual unsigned long sread (unsigned char* vuf, unsigned long size) = 0;
+ virtual long stell () = 0;
+ virtual long sseek (unsigned long offset, int origin) = 0;
+};
+
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/shell/inc/internal/zipfile.hxx b/shell/inc/internal/zipfile.hxx
index 062ce38cf1af..24fba6542fcf 100644
--- a/shell/inc/internal/zipfile.hxx
+++ b/shell/inc/internal/zipfile.hxx
@@ -33,16 +33,19 @@
#define _WINDOWS
#endif
-#if defined SYSTEM_ZLIB
-#include <minizip/unzip.h>
+#ifdef SYSTEM_ZLIB
+#include <zlib.h>
#else
-#include <external/zlib/unzip.h>
+#include <external/zlib/zlib.h>
#endif
#include <string>
#include <vector>
#include <memory>
+class StreamInterface;
+class ZipFilePrivate;
+
/** A simple zip content provider based on the zlib
*/
@@ -69,9 +72,9 @@ public:
IOException if the specified file doesn't exist
AccessViolationException if read access to the file is denied
*/
- static bool IsZipFile(const std::string& FileName);
+ static bool IsZipFile(const std::string &FileName);
- static bool IsZipFile(void* stream);
+ static bool IsZipFile(void *stream);
/** Returns wheter the version of the specified zip file may be uncompressed with the
@@ -89,9 +92,9 @@ public:
IOException if the specified file doesn't exist or is no zip file
AccessViolationException if read access to the file is denied
*/
- static bool IsValidZipFileVersionNumber(const std::string& FileName);
+ static bool IsValidZipFileVersionNumber(const std::string &FileName);
- static bool IsValidZipFileVersionNumber(void* stream);
+ static bool IsValidZipFileVersionNumber(void *stream);
public:
@@ -107,9 +110,9 @@ public:
WrongZipVersionException if the zip file cannot be uncompressed
with the used zlib version
*/
- ZipFile(const std::string& FileName);
+ ZipFile(const std::string &FileName);
- ZipFile(void* stream, zlib_filefunc_def* fa);
+ ZipFile(StreamInterface *stream);
/** Destroys a zip file
@@ -134,7 +137,7 @@ public:
ZipContentMissException if the specified zip content
does not exist in this zip file
*/
- void GetUncompressedContent(const std::string& ContentName, /*inout*/ ZipContentBuffer_t& ContentBuffer);
+ void GetUncompressedContent(const std::string &ContentName, /*inout*/ ZipContentBuffer_t &ContentBuffer);
/** Returns a list with the content names contained within this file
@@ -146,7 +149,7 @@ public:
iterating over a ZipFileDirectory returned by
GetDirectory
*/
- bool HasContent(const std::string& ContentName) const;
+ bool HasContent(const std::string &ContentName) const;
private:
@@ -158,7 +161,9 @@ private:
long GetFileLongestFileNameLength() const;
private:
- unzFile m_uzFile;
+ StreamInterface *m_pStream;
+ bool m_bShouldFree;
+ long m_iStartOffset;
};
#endif