Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/OgreMain/include/OgreArchive.h @ 1

Last change on this file since 1 was 1, checked in by landauf, 17 years ago
File size: 7.7 KB
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-2006 Torus Knot Software Ltd
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
24You may alternatively use this source under the terms of a specific version of
25the OGRE Unrestricted License provided you have obtained such a license from
26Torus Knot Software Ltd.
27-----------------------------------------------------------------------------
28*/
29#ifndef _Archive_H__
30#define _Archive_H__
31
32#include "OgrePrerequisites.h"
33#include "OgreString.h"
34#include "OgreDataStream.h"
35#include "OgreSharedPtr.h"
36#include "OgreStringVector.h"
37
38namespace Ogre {
39
40    /** Information about a file/directory within the archive will be
41    returned using a FileInfo struct.
42    @see
43    Archive
44    */
45    struct FileInfo {
46                /// The archive in which the file has been found (for info when performing
47                /// multi-Archive searches, note you should still open through ResourceGroupManager)
48                Archive* archive;
49        /// The file's fully qualified name
50        String filename;
51        /// Path name; separated by '/' and ending with '/'
52        String path;
53        /// Base filename
54        String basename;
55        /// Compressed size
56        size_t compressedSize;
57        /// Uncompressed size
58        size_t uncompressedSize;
59    };
60
61    typedef std::vector<FileInfo> FileInfoList;
62    typedef SharedPtr<FileInfoList> FileInfoListPtr;
63
64    /** Archive-handling class.
65    @remarks
66        An archive is a generic term for a container of files. This may be a
67        filesystem folder, it may be a compressed archive, it may even be
68        a remote location shared on the web. This class is designed to be
69        subclassed to provide access to a range of file locations.
70    @par
71        Instances of this class are never constructed or even handled by end-user
72        applications. They are constructed by custom ArchiveFactory classes,
73        which plugins can register new instances of using ArchiveManager.
74        End-user applications will typically use ResourceManager or
75        ResourceGroupManager to manage resources at a higher level, rather than
76        reading files directly through this class. Doing it this way allows you
77        to benefit from OGRE's automatic searching of multiple file locations
78        for the resources you are looking for.
79    */
80    class _OgreExport Archive 
81    {
82    protected:
83        /// Archive name
84        String mName; 
85        /// Archive type code
86        String mType;
87    public:
88
89
90        /** Constructor - don't call direct, used by ArchiveFactory.
91        */
92        Archive( const String& name, const String& archType )
93            : mName(name), mType(archType) {}
94
95        /** Default destructor.
96        */
97        virtual ~Archive() {}
98
99                /// Get the name of this archive
100                const String& getName(void) const { return mName; }
101
102        /// Returns whether this archive is case sensitive in the way it matches files
103        virtual bool isCaseSensitive(void) const = 0;
104
105        /** Loads the archive.
106        @remarks
107            This initializes all the internal data of the class.
108        @warning
109            Do not call this function directly, it is ment to be used
110            only by the ArchiveManager class.
111        */
112        virtual void load() = 0;
113
114        /** Unloads the archive.
115        @warning
116            Do not call this function directly, it is ment to be used
117            only by the ArchiveManager class.
118        */
119        virtual void unload() = 0;
120
121        /** Open a stream on a given file.
122        @note
123            There is no equivalent 'close' method; the returned stream
124            controls the lifecycle of this file operation.
125        @param filename The fully qualified name of the file
126        @returns A shared pointer to a DataStream which can be used to
127            read / write the file. If the file is not present, returns a null
128                        shared pointer.
129        */
130        virtual DataStreamPtr open(const String& filename) const = 0;
131
132        /** List all file names in the archive.
133        @note
134            This method only returns filenames, you can also retrieve other
135            information using listFileInfo.
136        @param recursive Whether all paths of the archive are searched (if the
137            archive has a concept of that)
138        @param dirs Set to true if you want the directories to be listed
139            instead of files
140        @returns A list of filenames matching the criteria, all are fully qualified
141        */
142        virtual StringVectorPtr list(bool recursive = true, bool dirs = false) = 0;
143       
144        /** List all files in the archive with accompanying information.
145        @param recursive Whether all paths of the archive are searched (if the
146            archive has a concept of that)
147        @param dirs Set to true if you want the directories to be listed
148            instead of files
149        @returns A list of structures detailing quite a lot of information about
150            all the files in the archive.
151        */
152        virtual FileInfoListPtr listFileInfo(bool recursive = true, bool dirs = false) = 0;
153
154        /** Find all file or directory names matching a given pattern
155            in this archive.
156        @note
157            This method only returns filenames, you can also retrieve other
158            information using findFileInfo.
159        @param pattern The pattern to search for; wildcards (*) are allowed
160        @param recursive Whether all paths of the archive are searched (if the
161            archive has a concept of that)
162        @param dirs Set to true if you want the directories to be listed
163            instead of files
164        @returns A list of filenames matching the criteria, all are fully qualified
165        */
166        virtual StringVectorPtr find(const String& pattern, bool recursive = true,
167            bool dirs = false) = 0;
168
169        /** Find out if the named file exists (note: fully qualified filename required) */
170        virtual bool exists(const String& filename) = 0; 
171
172        /** Find all files or directories matching a given pattern in this
173            archive and get some detailed information about them.
174        @param pattern The pattern to search for; wildcards (*) are allowed
175        @param recursive Whether all paths of the archive are searched (if the
176        archive has a concept of that)
177        @param dirs Set to true if you want the directories to be listed
178            instead of files
179        @returns A list of file information structures for all files matching
180            the criteria.
181        */
182        virtual FileInfoListPtr findFileInfo(const String& pattern, 
183            bool recursive = true, bool dirs = false) = 0;
184
185        /// Return the type code of this Archive
186        const String& getType(void) const { return mType; }
187       
188    };
189}
190
191#endif
Note: See TracBrowser for help on using the repository browser.