Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

OgreZip.h

Go to the documentation of this file.
00001 /*
00002 -----------------------------------------------------------------------------
00003 This source file is part of OGRE
00004 (Object-oriented Graphics Rendering Engine)
00005 For the latest info, see http://www.ogre3d.org/
00006 
00007 Copyright (c) 2000-2005 The OGRE Team
00008 Also see acknowledgements in Readme.html
00009 
00010 This program is free software; you can redistribute it and/or modify it under
00011 the terms of the GNU Lesser General Public License as published by the Free Software
00012 Foundation; either version 2 of the License, or (at your option) any later
00013 version.
00014 
00015 This program is distributed in the hope that it will be useful, but WITHOUT
00016 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00017 FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
00018 
00019 You should have received a copy of the GNU Lesser General Public License along with
00020 this program; if not, write to the Free Software Foundation, Inc., 59 Temple
00021 Place - Suite 330, Boston, MA 02111-1307, USA, or go to
00022 http://www.gnu.org/copyleft/lesser.txt.
00023 -----------------------------------------------------------------------------
00024 */
00025 #ifndef __Zip_H__
00026 #define __Zip_H__
00027 
00028 #include <zzip/zzip.h>
00029 #include "OgrePrerequisites.h"
00030 
00031 #include "OgreArchive.h"
00032 #include "OgreArchiveFactory.h"
00033 
00034 namespace Ogre {
00035 
00042     class _OgreExport ZipArchive : public Archive 
00043     {
00044     protected:
00046         ZZIP_DIR* mZzipDir;
00048         void checkZzipError(zzip_error_t zzipError, const String& operation) const;
00050         FileInfoList mFileList;
00051     public:
00052         ZipArchive(const String& name, const String& archType );
00053         ~ZipArchive();
00055         bool isCaseSensitive(void) const { return false; }
00056 
00058         void load();
00060         void unload();
00061 
00063         DataStreamPtr open(const String& filename) const;
00064 
00066         StringVectorPtr list(bool recursive = true );
00067 
00069         FileInfoListPtr listFileInfo(bool recursive = true );
00070 
00072         StringVectorPtr find(const String& pattern, bool recursive = true);
00073 
00075         FileInfoListPtr findFileInfo(const String& pattern, bool recursive = true);
00076 
00078         bool exists(const String& filename);
00079     };
00080 
00082     class ZipArchiveFactory : public ArchiveFactory
00083     {
00084     public:
00085         virtual ~ZipArchiveFactory() {}
00087         const String& getType(void) const;
00089         Archive *createInstance( const String& name ) 
00090         {
00091             return new ZipArchive(name, "Zip");
00092         }
00094         void destroyInstance( Archive* arch) { delete arch; }
00095     };
00096 
00098     class ZipDataStream : public DataStream
00099     {
00100     protected:
00101         ZZIP_FILE* mZzipFile;
00103         char mZipTmpArea[OGRE_STREAM_TEMP_SIZE];
00104     public:
00106         ZipDataStream(ZZIP_FILE* zzipFile, size_t uncompressedSize);
00108         ZipDataStream(const String& name, ZZIP_FILE* zzipFile, size_t uncompressedSize);
00110         size_t read(void* buf, size_t count);
00112         size_t readLine(char* buf, size_t maxCount, const String& delim = "\n");
00114         size_t skipLine(const String& delim = "\n");
00116         void skip(long count);
00118         void seek( size_t pos );
00120         size_t tell(void) const;
00122         bool eof(void) const;
00124         void close(void);
00125 
00126 
00127     };
00128 
00129 
00130 }
00131 
00132 #endif

Copyright © 2000-2005 by The OGRE Team
Last modified Sun Apr 10 23:21:25 2005