source: GTP/trunk/App/Demos/Geom/OgreStuff/include/OgreZip.h @ 1092

Revision 1092, 4.6 KB checked in by gumbau, 18 years ago (diff)

LodStrips? and LODTrees demos

Line 
1/*
2-----------------------------------------------------------------------------
3This source file is part of OGRE
4(Object-oriented Graphics Rendering Engine)
5For the latest info, see http://www.ogre3d.org/
6
7Copyright (c) 2000-2005 The OGRE Team
8Also see acknowledgements in Readme.html
9
10This program is free software; you can redistribute it and/or modify it under
11the terms of the GNU Lesser General Public License as published by the Free Software
12Foundation; either version 2 of the License, or (at your option) any later
13version.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
18
19You should have received a copy of the GNU Lesser General Public License along with
20this program; if not, write to the Free Software Foundation, Inc., 59 Temple
21Place - Suite 330, Boston, MA 02111-1307, USA, or go to
22http://www.gnu.org/copyleft/lesser.txt.
23-----------------------------------------------------------------------------
24*/
25#ifndef __Zip_H__
26#define __Zip_H__
27
28#include <zzip/zzip.h>
29#include "OgrePrerequisites.h"
30
31#include "OgreArchive.h"
32#include "OgreArchiveFactory.h"
33
34namespace Ogre {
35
36    /** Specialisation of the Archive class to allow reading of files from a zip
37        format source archive.
38    @remarks
39        This archive format supports all archives compressed in the standard
40        zip format, including iD pk3 files.
41    */
42    class _OgreExport ZipArchive : public Archive
43    {
44    protected:
45        /// Handle to root zip file
46        ZZIP_DIR* mZzipDir;
47        /// Handle any errors from zzip
48        void checkZzipError(zzip_error_t zzipError, const String& operation) const;
49        /// File list (since zziplib seems to only allow scanning of dir tree once)
50        FileInfoList mFileList;
51    public:
52        ZipArchive(const String& name, const String& archType );
53        ~ZipArchive();
54        /// @copydoc Archive::isCaseSensitive
55        bool isCaseSensitive(void) const { return false; }
56
57        /// @copydoc Archive::load
58        void load();
59        /// @copydoc Archive::unload
60        void unload();
61
62        /// @copydoc Archive::open
63        DataStreamPtr open(const String& filename) const;
64
65        /// @copydoc Archive::list
66        StringVectorPtr list(bool recursive = true );
67
68        /// @copydoc Archive::listFileInfo
69        FileInfoListPtr listFileInfo(bool recursive = true );
70
71        /// @copydoc Archive::find
72        StringVectorPtr find(const String& pattern, bool recursive = true);
73
74        /// @copydoc Archive::findFileInfo
75        FileInfoListPtr findFileInfo(const String& pattern, bool recursive = true);
76
77        /// @copydoc Archive::exists
78                bool exists(const String& filename);
79    };
80
81    /** Specialisation of ArchiveFactory for Zip files. */
82    class _OgrePrivate ZipArchiveFactory : public ArchiveFactory
83    {
84    public:
85        virtual ~ZipArchiveFactory() {}
86        /// @copydoc FactoryObj::getType
87        const String& getType(void) const;
88        /// @copydoc FactoryObj::createInstance
89        Archive *createInstance( const String& name )
90        {
91            return new ZipArchive(name, "Zip");
92        }
93        /// @copydoc FactoryObj::destroyInstance
94        void destroyInstance( Archive* arch) { delete arch; }
95    };
96
97    /** Specialisation of DataStream to handle streaming data from zip archives. */
98    class _OgrePrivate ZipDataStream : public DataStream
99    {
100    protected:
101        ZZIP_FILE* mZzipFile;
102                /// Temporary zip copy area
103                char mZipTmpArea[OGRE_STREAM_TEMP_SIZE];
104    public:
105        /// Unnamed constructor
106        ZipDataStream(ZZIP_FILE* zzipFile, size_t uncompressedSize);
107        /// Constructor for creating named streams
108        ZipDataStream(const String& name, ZZIP_FILE* zzipFile, size_t uncompressedSize);
109                ~ZipDataStream();
110        /// @copydoc DataStream::read
111        size_t read(void* buf, size_t count);
112        /// @copydoc DataStream::read
113        size_t readLine(char* buf, size_t maxCount, const String& delim = "\n");
114        /// @copydoc DataStream::skipLine
115        size_t skipLine(const String& delim = "\n");
116        /// @copydoc DataStream::skip
117        void skip(long count);
118        /// @copydoc DataStream::seek
119        void seek( size_t pos );
120        /// @copydoc DataStream::seek
121        size_t tell(void) const;
122        /// @copydoc DataStream::eof
123        bool eof(void) const;
124        /// @copydoc DataStream::close
125        void close(void);
126
127
128    };
129
130
131}
132
133#endif
Note: See TracBrowser for help on using the repository browser.