[148] | 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" |
---|
| 35 | #include "Threading/OgreThreadHeaders.h" |
---|
| 36 | #include "OgreHeaderPrefix.h" |
---|
| 37 | |
---|
| 38 | namespace Ogre { |
---|
| 39 | |
---|
| 40 | /** \addtogroup Core |
---|
| 41 | * @{ |
---|
| 42 | */ |
---|
| 43 | /** \addtogroup Resources |
---|
| 44 | * @{ |
---|
| 45 | */ |
---|
| 46 | /** Specialisation of the Archive class to allow reading of files from |
---|
| 47 | filesystem folders / directories. |
---|
| 48 | */ |
---|
| 49 | class _OgreExport FileSystemArchive : public Archive |
---|
| 50 | { |
---|
| 51 | protected: |
---|
| 52 | /** Utility method to retrieve all files in a directory matching pattern. |
---|
| 53 | @param pattern |
---|
| 54 | File pattern. |
---|
| 55 | @param recursive |
---|
| 56 | Whether to cascade down directories. |
---|
| 57 | @param dirs |
---|
| 58 | Set to @c true if you want the directories to be listed instead of files. |
---|
| 59 | @param simpleList |
---|
| 60 | Populated if retrieving a simple list. |
---|
| 61 | @param detailList |
---|
| 62 | Populated if retrieving a detailed list. |
---|
| 63 | */ |
---|
| 64 | void findFiles(const String& pattern, bool recursive, bool dirs, |
---|
| 65 | StringVector* simpleList, FileInfoList* detailList) const; |
---|
| 66 | |
---|
| 67 | OGRE_AUTO_MUTEX; |
---|
| 68 | public: |
---|
| 69 | FileSystemArchive(const String& name, const String& archType, bool readOnly ); |
---|
| 70 | ~FileSystemArchive(); |
---|
| 71 | |
---|
| 72 | /// @copydoc Archive::isCaseSensitive |
---|
| 73 | bool isCaseSensitive(void) const; |
---|
| 74 | |
---|
| 75 | /// @copydoc Archive::load |
---|
| 76 | void load(); |
---|
| 77 | /// @copydoc Archive::unload |
---|
| 78 | void unload(); |
---|
| 79 | |
---|
| 80 | /// @copydoc Archive::open |
---|
| 81 | DataStreamPtr open(const String& filename, bool readOnly = true) const; |
---|
| 82 | |
---|
| 83 | /// @copydoc Archive::create |
---|
| 84 | DataStreamPtr create(const String& filename) const; |
---|
| 85 | |
---|
| 86 | /// @copydoc Archive::remove |
---|
| 87 | void remove(const String& filename) const; |
---|
| 88 | |
---|
| 89 | /// @copydoc Archive::list |
---|
| 90 | StringVectorPtr list(bool recursive = true, bool dirs = false); |
---|
| 91 | |
---|
| 92 | /// @copydoc Archive::listFileInfo |
---|
| 93 | FileInfoListPtr listFileInfo(bool recursive = true, bool dirs = false); |
---|
| 94 | |
---|
| 95 | /// @copydoc Archive::find |
---|
| 96 | StringVectorPtr find(const String& pattern, bool recursive = true, |
---|
| 97 | bool dirs = false); |
---|
| 98 | |
---|
| 99 | /// @copydoc Archive::findFileInfo |
---|
| 100 | FileInfoListPtr findFileInfo(const String& pattern, bool recursive = true, |
---|
| 101 | bool dirs = false) const; |
---|
| 102 | |
---|
| 103 | /// @copydoc Archive::exists |
---|
| 104 | bool exists(const String& filename); |
---|
| 105 | |
---|
| 106 | /// @copydoc Archive::getModifiedTime |
---|
| 107 | time_t getModifiedTime(const String& filename); |
---|
| 108 | |
---|
| 109 | /// Set whether filesystem enumeration will include hidden files or not. |
---|
| 110 | /// This should be called prior to declaring and/or initializing filesystem |
---|
| 111 | /// resource locations. The default is true (ignore hidden files). |
---|
| 112 | static void setIgnoreHidden(bool ignore) |
---|
| 113 | { |
---|
| 114 | msIgnoreHidden = ignore; |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | /// Get whether hidden files are ignored during filesystem enumeration. |
---|
| 118 | static bool getIgnoreHidden() |
---|
| 119 | { |
---|
| 120 | return msIgnoreHidden; |
---|
| 121 | } |
---|
| 122 | |
---|
| 123 | static bool msIgnoreHidden; |
---|
| 124 | }; |
---|
| 125 | |
---|
| 126 | /** Specialisation of ArchiveFactory for FileSystem files. */ |
---|
| 127 | class _OgreExport FileSystemArchiveFactory : public ArchiveFactory |
---|
| 128 | { |
---|
| 129 | public: |
---|
| 130 | virtual ~FileSystemArchiveFactory() {} |
---|
| 131 | /// @copydoc FactoryObj::getType |
---|
| 132 | const String& getType(void) const; |
---|
| 133 | /// @copydoc FactoryObj::createInstance |
---|
| 134 | Archive *createInstance( const String& name, bool readOnly ) |
---|
| 135 | { |
---|
| 136 | return OGRE_NEW FileSystemArchive(name, "FileSystem", readOnly); |
---|
| 137 | } |
---|
| 138 | /// @copydoc FactoryObj::destroyInstance |
---|
| 139 | void destroyInstance(Archive* ptr) { OGRE_DELETE ptr; } |
---|
| 140 | }; |
---|
| 141 | |
---|
| 142 | /** @} */ |
---|
| 143 | /** @} */ |
---|
| 144 | |
---|
| 145 | } // namespace Ogre |
---|
| 146 | |
---|
| 147 | #include "OgreHeaderSuffix.h" |
---|
| 148 | |
---|
| 149 | #endif // __FileSystem_H__ |
---|