Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: downloads/ogre_src_v1-9-0/OgreMain/include/OgreArchive.h @ 148

Last change on this file since 148 was 148, checked in by patricwi, 6 years ago

Added new dependencies for ogre1.9 and cegui0.8

File size: 9.2 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-2013 Torus Knot Software Ltd
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25THE SOFTWARE.
26-----------------------------------------------------------------------------
27*/
28#ifndef _Archive_H__
29#define _Archive_H__
30
31#include "OgrePrerequisites.h"
32#include "OgreString.h"
33#include "OgreDataStream.h"
34#include "OgreSharedPtr.h"
35#include "OgreStringVector.h"
36#include "OgreException.h"
37#include <ctime>
38#include "OgreHeaderPrefix.h"
39
40namespace Ogre {
41
42        /** \addtogroup Core
43        *  @{
44        */
45        /** \addtogroup Resources
46        *  @{
47        */
48    /** Information about a file/directory within the archive will be
49    returned using a FileInfo struct.
50    @see
51    Archive
52    */
53    struct FileInfo {
54                /// The archive in which the file has been found (for info when performing
55                /// multi-Archive searches, note you should still open through ResourceGroupManager)
56                const Archive* archive;
57        /// The file's fully qualified name
58        String filename;
59        /// Path name; separated by '/' and ending with '/'
60        String path;
61        /// Base filename
62        String basename;
63        /// Compressed size
64        size_t compressedSize;
65        /// Uncompressed size
66        size_t uncompressedSize;
67    };
68
69    typedef vector<FileInfo>::type FileInfoList;
70    typedef SharedPtr<FileInfoList> FileInfoListPtr;
71
72    /** Archive-handling class.
73    @remarks
74        An archive is a generic term for a container of files. This may be a
75        filesystem folder, it may be a compressed archive, it may even be
76        a remote location shared on the web. This class is designed to be
77        subclassed to provide access to a range of file locations.
78    @par
79        Instances of this class are never constructed or even handled by end-user
80        applications. They are constructed by custom ArchiveFactory classes,
81        which plugins can register new instances of using ArchiveManager.
82        End-user applications will typically use ResourceManager or
83        ResourceGroupManager to manage resources at a higher level, rather than
84        reading files directly through this class. Doing it this way allows you
85        to benefit from OGRE's automatic searching of multiple file locations
86        for the resources you are looking for.
87    */
88        class _OgreExport Archive : public ArchiveAlloc
89    {
90    protected:
91        /// Archive name
92        String mName; 
93        /// Archive type code
94        String mType;
95                /// Read-only flag
96                bool mReadOnly;
97    public:
98
99
100        /** Constructor - don't call direct, used by ArchiveFactory.
101        */
102        Archive( const String& name, const String& archType )
103            : mName(name), mType(archType), mReadOnly(true) {}
104
105        /** Default destructor.
106        */
107        virtual ~Archive() {}
108
109                /// Get the name of this archive
110                const String& getName(void) const { return mName; }
111
112        /// Returns whether this archive is case sensitive in the way it matches files
113        virtual bool isCaseSensitive(void) const = 0;
114
115        /** Loads the archive.
116        @remarks
117            This initializes all the internal data of the class.
118        @warning
119            Do not call this function directly, it is meant to be used
120            only by the ArchiveManager class.
121        */
122        virtual void load() = 0;
123
124        /** Unloads the archive.
125        @warning
126            Do not call this function directly, it is meant to be used
127            only by the ArchiveManager class.
128        */
129        virtual void unload() = 0;
130
131                /** Reports whether this Archive is read-only, or whether the contents
132                        can be updated.
133                */
134                virtual bool isReadOnly() const { return mReadOnly; }
135
136        /** Open a stream on a given file.
137        @note
138            There is no equivalent 'close' method; the returned stream
139            controls the lifecycle of this file operation.
140        @param filename The fully qualified name of the file
141                @param readOnly Whether to open the file in read-only mode or not (note,
142                        if the archive is read-only then this cannot be set to false)
143        @return A shared pointer to a DataStream which can be used to
144            read / write the file. If the file is not present, returns a null
145                        shared pointer.
146        */
147        virtual DataStreamPtr open(const String& filename, bool readOnly = true) const = 0;
148
149                /** Create a new file (or overwrite one already there).
150                @note If the archive is read-only then this method will fail.
151                @param filename The fully qualified name of the file
152                @return A shared pointer to a DataStream which can be used to
153                read / write the file.
154                */
155                virtual DataStreamPtr create(const String& filename) const
156                {
157                        (void)filename;
158                        OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, 
159                                "This archive does not support creation of files.", 
160                                "Archive::create");
161                }
162
163                /** Delete a named file.
164                @remarks Not possible on read-only archives
165                @param filename The fully qualified name of the file
166                */
167                virtual void remove(const String& filename) const
168                {
169                        (void)filename;
170                        OGRE_EXCEPT(Exception::ERR_NOT_IMPLEMENTED, 
171                                "This archive does not support removal of files.", 
172                                "Archive::remove");
173                }
174
175        /** List all file names in the archive.
176        @note
177            This method only returns filenames, you can also retrieve other
178            information using listFileInfo.
179        @param recursive Whether all paths of the archive are searched (if the
180            archive has a concept of that)
181        @param dirs Set to true if you want the directories to be listed
182            instead of files
183        @return A list of filenames matching the criteria, all are fully qualified
184        */
185        virtual StringVectorPtr list(bool recursive = true, bool dirs = false) = 0;
186       
187        /** List all files in the archive with accompanying information.
188        @param recursive Whether all paths of the archive are searched (if the
189            archive has a concept of that)
190        @param dirs Set to true if you want the directories to be listed
191            instead of files
192        @return A list of structures detailing quite a lot of information about
193            all the files in the archive.
194        */
195        virtual FileInfoListPtr listFileInfo(bool recursive = true, bool dirs = false) = 0;
196
197        /** Find all file or directory names matching a given pattern
198            in this archive.
199        @note
200            This method only returns filenames, you can also retrieve other
201            information using findFileInfo.
202        @param pattern The pattern to search for; wildcards (*) are allowed
203        @param recursive Whether all paths of the archive are searched (if the
204            archive has a concept of that)
205        @param dirs Set to true if you want the directories to be listed
206            instead of files
207        @return A list of filenames matching the criteria, all are fully qualified
208        */
209        virtual StringVectorPtr find(const String& pattern, bool recursive = true,
210            bool dirs = false) = 0;
211
212        /** Find out if the named file exists (note: fully qualified filename required) */
213        virtual bool exists(const String& filename) = 0; 
214
215                /** Retrieve the modification time of a given file */
216                virtual time_t getModifiedTime(const String& filename) = 0; 
217
218
219        /** Find all files or directories matching a given pattern in this
220            archive and get some detailed information about them.
221        @param pattern The pattern to search for; wildcards (*) are allowed
222        @param recursive Whether all paths of the archive are searched (if the
223        archive has a concept of that)
224        @param dirs Set to true if you want the directories to be listed
225            instead of files
226        @return A list of file information structures for all files matching
227            the criteria.
228        */
229        virtual FileInfoListPtr findFileInfo(const String& pattern, 
230            bool recursive = true, bool dirs = false) const = 0;
231
232        /// Return the type code of this Archive
233        const String& getType(void) const { return mType; }
234       
235    };
236        /** @} */
237        /** @} */
238
239}
240
241#include "OgreHeaderSuffix.h"
242
243#endif
Note: See TracBrowser for help on using the repository browser.