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 "OgrePrerequisites.h"
00029 
00030 #include "OgreArchive.h"
00031 #include "OgreArchiveFactory.h"
00032 
00033 // Forward declaration for zziplib to avoid header file dependency.
00034 typedef struct zzip_dir     ZZIP_DIR;
00035 typedef struct zzip_file    ZZIP_FILE;
00036 
00037 namespace Ogre {
00038 
00045     class _OgreExport ZipArchive : public Archive 
00046     {
00047     protected:
00049         ZZIP_DIR* mZzipDir;
00051         void checkZzipError(int zzipError, const String& operation) const;
00053         FileInfoList mFileList;
00054     public:
00055         ZipArchive(const String& name, const String& archType );
00056         ~ZipArchive();
00058         bool isCaseSensitive(void) const { return false; }
00059 
00061         void load();
00063         void unload();
00064 
00066         DataStreamPtr open(const String& filename) const;
00067 
00069         StringVectorPtr list(bool recursive = true );
00070 
00072         FileInfoListPtr listFileInfo(bool recursive = true );
00073 
00075         StringVectorPtr find(const String& pattern, bool recursive = true);
00076 
00078         FileInfoListPtr findFileInfo(const String& pattern, bool recursive = true);
00079 
00081         bool exists(const String& filename);
00082     };
00083 
00085     class _OgrePrivate ZipArchiveFactory : public ArchiveFactory
00086     {
00087     public:
00088         virtual ~ZipArchiveFactory() {}
00090         const String& getType(void) const;
00092         Archive *createInstance( const String& name ) 
00093         {
00094             return new ZipArchive(name, "Zip");
00095         }
00097         void destroyInstance( Archive* arch) { delete arch; }
00098     };
00099 
00101     class _OgrePrivate ZipDataStream : public DataStream
00102     {
00103     protected:
00104         ZZIP_FILE* mZzipFile;
00106         char mZipTmpArea[OGRE_STREAM_TEMP_SIZE];
00107     public:
00109         ZipDataStream(ZZIP_FILE* zzipFile, size_t uncompressedSize);
00111         ZipDataStream(const String& name, ZZIP_FILE* zzipFile, size_t uncompressedSize);
00112         ~ZipDataStream();
00114         size_t read(void* buf, size_t count);
00116         size_t readLine(char* buf, size_t maxCount, const String& delim = "\n");
00118         size_t skipLine(const String& delim = "\n");
00120         void skip(long count);
00122         void seek( size_t pos );
00124         size_t tell(void) const;
00126         bool eof(void) const;
00128         void close(void);
00129 
00130 
00131     };
00132 
00133 
00134 }
00135 
00136 #endif

Copyright © 2000-2005 by The OGRE Team
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Sun Mar 12 14:37:52 2006