OgreFileSystem.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-2013 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 __FileSystem_H__
29 #define __FileSystem_H__
30 
31 #include "OgrePrerequisites.h"
32 
33 #include "OgreArchive.h"
34 #include "OgreArchiveFactory.h"
36 #include "OgreHeaderPrefix.h"
37 
38 namespace Ogre {
39 
50  {
51  protected:
64  void findFiles(const String& pattern, bool recursive, bool dirs,
65  StringVector* simpleList, FileInfoList* detailList) const;
66 
68  public:
69  FileSystemArchive(const String& name, const String& archType, bool readOnly );
71 
73  bool isCaseSensitive(void) const;
74 
76  void load();
78  void unload();
79 
81  DataStreamPtr open(const String& filename, bool readOnly = true) const;
82 
84  DataStreamPtr create(const String& filename) const;
85 
87  void remove(const String& filename) const;
88 
90  StringVectorPtr list(bool recursive = true, bool dirs = false);
91 
93  FileInfoListPtr listFileInfo(bool recursive = true, bool dirs = false);
94 
96  StringVectorPtr find(const String& pattern, bool recursive = true,
97  bool dirs = false);
98 
100  FileInfoListPtr findFileInfo(const String& pattern, bool recursive = true,
101  bool dirs = false) const;
102 
104  bool exists(const String& filename);
105 
107  time_t getModifiedTime(const String& filename);
108 
112  static void setIgnoreHidden(bool ignore)
113  {
114  msIgnoreHidden = ignore;
115  }
116 
118  static bool getIgnoreHidden()
119  {
120  return msIgnoreHidden;
121  }
122 
123  static bool msIgnoreHidden;
124  };
125 
128  {
129  public:
132  const String& getType(void) const;
134  Archive *createInstance( const String& name, bool readOnly )
135  {
136  return OGRE_NEW FileSystemArchive(name, "FileSystem", readOnly);
137  }
139  void destroyInstance(Archive* ptr) { OGRE_DELETE ptr; }
140  };
141 
145 } // namespace Ogre
146 
147 #include "OgreHeaderSuffix.h"
148 
149 #endif // __FileSystem_H__
OgreHeaderSuffix.h
Ogre::FileSystemArchive::getModifiedTime
time_t getModifiedTime(const String &filename)
Retrieve the modification time of a given file.
Ogre
Definition: OgreAndroidLogListener.h:35
Ogre::FileSystemArchive::list
StringVectorPtr list(bool recursive=true, bool dirs=false)
List all file names in the archive.
Ogre::FileSystemArchiveFactory
Specialisation of ArchiveFactory for FileSystem files.
Definition: OgreFileSystem.h:128
Ogre::FileSystemArchiveFactory::getType
const String & getType(void) const
Returns the factory type.
Ogre::StringVector
vector< String >::type StringVector
Definition: OgreStringVector.h:45
Ogre::FileSystemArchive::OGRE_AUTO_MUTEX
OGRE_AUTO_MUTEX
Definition: OgreFileSystem.h:67
OGRE_DELETE
#define OGRE_DELETE
Definition: OgreMemoryAllocatorConfig.h:474
Ogre::FileSystemArchive::listFileInfo
FileInfoListPtr listFileInfo(bool recursive=true, bool dirs=false)
List all files in the archive with accompanying information.
Ogre::FileSystemArchive::remove
void remove(const String &filename) const
Delete a named file.
Ogre::String
_StringBase String
Definition: OgrePrerequisites.h:439
Ogre::FileSystemArchive::find
StringVectorPtr find(const String &pattern, bool recursive=true, bool dirs=false)
Find all file or directory names matching a given pattern in this archive.
Ogre::ArchiveFactory
Abstract factory class, archive codec plugins can register concrete subclasses of this.
Definition: OgreArchiveFactory.h:60
Ogre::FileSystemArchive::findFileInfo
FileInfoListPtr findFileInfo(const String &pattern, bool recursive=true, bool dirs=false) const
Find all files or directories matching a given pattern in this archive and get some detailed informat...
Ogre::FileSystemArchiveFactory::createInstance
Archive * createInstance(const String &name, bool readOnly)
Creates a new object.
Definition: OgreFileSystem.h:134
OgreArchiveFactory.h
Ogre::FileSystemArchive::unload
void unload()
Unloads the archive.
OgreHeaderPrefix.h
Ogre::FileSystemArchive::setIgnoreHidden
static void setIgnoreHidden(bool ignore)
Set whether filesystem enumeration will include hidden files or not.
Definition: OgreFileSystem.h:112
Ogre::FileSystemArchive::~FileSystemArchive
~FileSystemArchive()
Ogre::FileSystemArchive::findFiles
void findFiles(const String &pattern, bool recursive, bool dirs, StringVector *simpleList, FileInfoList *detailList) const
Utility method to retrieve all files in a directory matching pattern.
Ogre::FileSystemArchive::exists
bool exists(const String &filename)
Find out if the named file exists (note: fully qualified filename required)
OgrePrerequisites.h
Ogre::FileSystemArchiveFactory::destroyInstance
void destroyInstance(Archive *ptr)
Destroys an object which was created by this factory.
Definition: OgreFileSystem.h:139
OgreThreadHeaders.h
Ogre::FileSystemArchive::getIgnoreHidden
static bool getIgnoreHidden()
Get whether hidden files are ignored during filesystem enumeration.
Definition: OgreFileSystem.h:118
_OgreExport
#define _OgreExport
Definition: OgrePlatform.h:257
Ogre::FileSystemArchive
Specialisation of the Archive class to allow reading of files from filesystem folders / directories.
Definition: OgreFileSystem.h:50
Ogre::SharedPtr< DataStream >
Ogre::FileInfoList
vector< FileInfo >::type FileInfoList
Definition: OgreArchive.h:69
Ogre::FileSystemArchive::load
void load()
Loads the archive.
Ogre::FileSystemArchive::msIgnoreHidden
static bool msIgnoreHidden
Definition: OgreFileSystem.h:123
Ogre::FileSystemArchive::isCaseSensitive
bool isCaseSensitive(void) const
Returns whether this archive is case sensitive in the way it matches files.
Ogre::Archive
Archive-handling class.
Definition: OgreArchive.h:89
OGRE_NEW
#define OGRE_NEW
Definition: OgreMemoryAllocatorConfig.h:473
Ogre::FileSystemArchiveFactory::~FileSystemArchiveFactory
virtual ~FileSystemArchiveFactory()
Definition: OgreFileSystem.h:130
Ogre::FileSystemArchive::open
DataStreamPtr open(const String &filename, bool readOnly=true) const
Open a stream on a given file.
Ogre::FileSystemArchive::create
DataStreamPtr create(const String &filename) const
Create a new file (or overwrite one already there).
Ogre::FileSystemArchive::FileSystemArchive
FileSystemArchive(const String &name, const String &archType, bool readOnly)
OgreArchive.h

Copyright © 2012 Torus Knot Software Ltd
Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.