OGRE  1.9.0
OgreFileSystem.h
Go to the documentation of this file.
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-2014 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 __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
38namespace Ogre {
39
50 {
51 protected:
64 void findFiles(const String& pattern, bool recursive, bool dirs,
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 }
140 };
141
145} // namespace Ogre
146
147#include "OgreHeaderSuffix.h"
148
149#endif // __FileSystem_H__
#define _OgreExport
Abstract factory class, archive codec plugins can register concrete subclasses of this.
Archive-handling class.
Definition OgreArchive.h:89
Specialisation of ArchiveFactory for FileSystem files.
void destroyInstance(Archive *ptr)
Destroys an object which was created by this factory.
const String & getType(void) const
Returns the factory type.
Archive * createInstance(const String &name, bool readOnly)
Creates a new object.
Specialisation of the Archive class to allow reading of files from filesystem folders / directories.
time_t getModifiedTime(const String &filename)
Retrieve the modification time of a given file.
DataStreamPtr open(const String &filename, bool readOnly=true) const
Open a stream on a given file.
StringVectorPtr find(const String &pattern, bool recursive=true, bool dirs=false)
Find all file or directory names matching a given pattern in this archive.
bool isCaseSensitive(void) const
Returns whether this archive is case sensitive in the way it matches files.
StringVectorPtr list(bool recursive=true, bool dirs=false)
List all file names in the archive.
void remove(const String &filename) const
Delete a named file.
static bool getIgnoreHidden()
Get whether hidden files are ignored during filesystem enumeration.
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.
void unload()
Unloads the archive.
DataStreamPtr create(const String &filename) const
Create a new file (or overwrite one already there).
FileSystemArchive(const String &name, const String &archType, bool readOnly)
static void setIgnoreHidden(bool ignore)
Set whether filesystem enumeration will include hidden files or not.
FileInfoListPtr listFileInfo(bool recursive=true, bool dirs=false)
List all files in the archive with accompanying information.
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...
void load()
Loads the archive.
bool exists(const String &filename)
Find out if the named file exists (note: fully qualified filename required)
Reference-counted shared pointer, used for objects where implicit destruction is required.
#define OGRE_NEW
#define OGRE_DELETE
_StringBase String