OGRE  2.0
Object-Oriented Graphics Rendering Engine
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OgreArchive.h
Go to the documentation of this file.
1 /*
2 -----------------------------------------------------------------------------
3 This source file is part of OGRE
4 (Object-oriented Graphics Rendering Engine)
5 For the latest info, see http://www.ogre3d.org/
6 
7 Copyright (c) 2000-2014 Torus Knot Software Ltd
8 
9 Permission is hereby granted, free of charge, to any person obtaining a copy
10 of this software and associated documentation files (the "Software"), to deal
11 in the Software without restriction, including without limitation the rights
12 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13 copies of the Software, and to permit persons to whom the Software is
14 furnished to do so, subject to the following conditions:
15 
16 The above copyright notice and this permission notice shall be included in
17 all copies or substantial portions of the Software.
18 
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25 THE SOFTWARE.
26 -----------------------------------------------------------------------------
27 */
28 #ifndef _Archive_H__
29 #define _Archive_H__
30 
31 #include "OgrePrerequisites.h"
32 #include "OgreDataStream.h"
33 #include "OgreStringVector.h"
34 #include "OgreException.h"
35 #include <ctime>
36 #include "OgreHeaderPrefix.h"
37 
38 namespace Ogre {
39 
51  struct FileInfo {
54  const Archive* archive;
65  };
66 
69 
87  {
88  protected:
94  bool mReadOnly;
95  public:
96 
97 
100  Archive( const String& name, const String& archType )
101  : mName(name), mType(archType), mReadOnly(true) {}
102 
105  virtual ~Archive() {}
106 
108  const String& getName(void) const { return mName; }
109 
111  virtual bool isCaseSensitive(void) const = 0;
112 
120  virtual void load() = 0;
121 
127  virtual void unload() = 0;
128 
132  virtual bool isReadOnly() const { return mReadOnly; }
133 
145  virtual DataStreamPtr open(const String& filename, bool readOnly = true) const = 0;
146 
153  virtual DataStreamPtr create(const String& filename) const
154  {
155  (void)filename;
157  "This archive does not support creation of files.",
158  "Archive::create");
159  }
160 
165  virtual void remove(const String& filename) const
166  {
167  (void)filename;
169  "This archive does not support removal of files.",
170  "Archive::remove");
171  }
172 
183  virtual StringVectorPtr list(bool recursive = true, bool dirs = false) = 0;
184 
193  virtual FileInfoListPtr listFileInfo(bool recursive = true, bool dirs = false) = 0;
194 
207  virtual StringVectorPtr find(const String& pattern, bool recursive = true,
208  bool dirs = false) = 0;
209 
211  virtual bool exists(const String& filename) = 0;
212 
214  virtual time_t getModifiedTime(const String& filename) = 0;
215 
216 
227  virtual FileInfoListPtr findFileInfo(const String& pattern,
228  bool recursive = true, bool dirs = false) const = 0;
229 
231  const String& getType(void) const { return mType; }
232 
233  };
237 }
238 
239 #include "OgreHeaderSuffix.h"
240 
241 #endif
size_t uncompressedSize
Uncompressed size.
Definition: OgreArchive.h:64
String path
Path name; separated by '/' and ending with '/'.
Definition: OgreArchive.h:58
#define _OgreExport
Definition: OgrePlatform.h:255
SharedPtr< FileInfoList > FileInfoListPtr
Definition: OgreArchive.h:68
const Archive * archive
The archive in which the file has been found (for info when performing multi-Archive searches...
Definition: OgreArchive.h:54
String filename
The file's fully qualified name.
Definition: OgreArchive.h:56
String basename
Base filename.
Definition: OgreArchive.h:60
virtual ~Archive()
Default destructor.
Definition: OgreArchive.h:105
const String & getType(void) const
Return the type code of this Archive.
Definition: OgreArchive.h:231
Archive(const String &name, const String &archType)
Constructor - don't call direct, used by ArchiveFactory.
Definition: OgreArchive.h:100
#define OGRE_EXCEPT(num, desc, src)
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
size_t compressedSize
Compressed size.
Definition: OgreArchive.h:62
Information about a file/directory within the archive will be returned using a FileInfo struct...
Definition: OgreArchive.h:51
vector< FileInfo >::type FileInfoList
Definition: OgreArchive.h:67
Archive-handling class.
Definition: OgreArchive.h:86
Reference-counted shared pointer, used for objects where implicit destruction is required.
_StringBase String
Definition: OgreCommon.h:53
String mType
Archive type code.
Definition: OgreArchive.h:92
const String & getName(void) const
Get the name of this archive.
Definition: OgreArchive.h:108
String mName
Archive name.
Definition: OgreArchive.h:90
virtual bool isReadOnly() const
Reports whether this Archive is read-only, or whether the contents can be updated.
Definition: OgreArchive.h:132
virtual DataStreamPtr create(const String &filename) const
Create a new file (or overwrite one already there).
Definition: OgreArchive.h:153
bool mReadOnly
Read-only flag.
Definition: OgreArchive.h:94