| 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-2006 Torus Knot Software Ltd |
|---|
| 8 | Also see acknowledgements in Readme.html |
|---|
| 9 | |
|---|
| 10 | This program is free software; you can redistribute it and/or modify it under |
|---|
| 11 | the terms of the GNU Lesser General Public License as published by the Free Software |
|---|
| 12 | Foundation; either version 2 of the License, or (at your option) any later |
|---|
| 13 | version. |
|---|
| 14 | |
|---|
| 15 | This program is distributed in the hope that it will be useful, but WITHOUT |
|---|
| 16 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
|---|
| 17 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. |
|---|
| 18 | |
|---|
| 19 | You should have received a copy of the GNU Lesser General Public License along with |
|---|
| 20 | this program; if not, write to the Free Software Foundation, Inc., 59 Temple |
|---|
| 21 | Place - Suite 330, Boston, MA 02111-1307, USA, or go to |
|---|
| 22 | http://www.gnu.org/copyleft/lesser.txt. |
|---|
| 23 | |
|---|
| 24 | You may alternatively use this source under the terms of a specific version of |
|---|
| 25 | the OGRE Unrestricted License provided you have obtained such a license from |
|---|
| 26 | Torus Knot Software Ltd. |
|---|
| 27 | ----------------------------------------------------------------------------- |
|---|
| 28 | */ |
|---|
| 29 | #ifndef __FileSystem_H__ |
|---|
| 30 | #define __FileSystem_H__ |
|---|
| 31 | |
|---|
| 32 | #include "OgrePrerequisites.h" |
|---|
| 33 | |
|---|
| 34 | #include "OgreArchive.h" |
|---|
| 35 | #include "OgreArchiveFactory.h" |
|---|
| 36 | |
|---|
| 37 | namespace Ogre { |
|---|
| 38 | |
|---|
| 39 | /** Specialisation of the Archive class to allow reading of files from |
|---|
| 40 | filesystem folders / directories. |
|---|
| 41 | */ |
|---|
| 42 | class _OgreExport FileSystemArchive : public Archive |
|---|
| 43 | { |
|---|
| 44 | protected: |
|---|
| 45 | /** Utility method to retrieve all files in a directory matching pattern. |
|---|
| 46 | @param pattern File pattern |
|---|
| 47 | @param recursive Whether to cascade down directories |
|---|
| 48 | @param dirs Set to true if you want the directories to be listed |
|---|
| 49 | instead of files |
|---|
| 50 | @param simpleList Populated if retrieving a simple list |
|---|
| 51 | @param detailList Populated if retrieving a detailed list |
|---|
| 52 | @param currentDir The current directory relative to the base of the |
|---|
| 53 | archive, for file naming |
|---|
| 54 | */ |
|---|
| 55 | void findFiles(const String& pattern, bool recursive, bool dirs, |
|---|
| 56 | StringVector* simpleList, FileInfoList* detailList); |
|---|
| 57 | |
|---|
| 58 | public: |
|---|
| 59 | FileSystemArchive(const String& name, const String& archType ); |
|---|
| 60 | ~FileSystemArchive(); |
|---|
| 61 | |
|---|
| 62 | /// @copydoc Archive::isCaseSensitive |
|---|
| 63 | bool isCaseSensitive(void) const; |
|---|
| 64 | |
|---|
| 65 | /// @copydoc Archive::load |
|---|
| 66 | void load(); |
|---|
| 67 | /// @copydoc Archive::unload |
|---|
| 68 | void unload(); |
|---|
| 69 | |
|---|
| 70 | /// @copydoc Archive::open |
|---|
| 71 | DataStreamPtr open(const String& filename) const; |
|---|
| 72 | |
|---|
| 73 | /// @copydoc Archive::list |
|---|
| 74 | StringVectorPtr list(bool recursive = true, bool dirs = false); |
|---|
| 75 | |
|---|
| 76 | /// @copydoc Archive::listFileInfo |
|---|
| 77 | FileInfoListPtr listFileInfo(bool recursive = true, bool dirs = false); |
|---|
| 78 | |
|---|
| 79 | /// @copydoc Archive::find |
|---|
| 80 | StringVectorPtr find(const String& pattern, bool recursive = true, |
|---|
| 81 | bool dirs = false); |
|---|
| 82 | |
|---|
| 83 | /// @copydoc Archive::findFileInfo |
|---|
| 84 | FileInfoListPtr findFileInfo(const String& pattern, bool recursive = true, |
|---|
| 85 | bool dirs = false); |
|---|
| 86 | |
|---|
| 87 | /// @copydoc Archive::exists |
|---|
| 88 | bool exists(const String& filename); |
|---|
| 89 | |
|---|
| 90 | }; |
|---|
| 91 | |
|---|
| 92 | /** Specialisation of ArchiveFactory for FileSystem files. */ |
|---|
| 93 | class _OgrePrivate FileSystemArchiveFactory : public ArchiveFactory |
|---|
| 94 | { |
|---|
| 95 | public: |
|---|
| 96 | virtual ~FileSystemArchiveFactory() {} |
|---|
| 97 | /// @copydoc FactoryObj::getType |
|---|
| 98 | const String& getType(void) const; |
|---|
| 99 | /// @copydoc FactoryObj::createInstance |
|---|
| 100 | Archive *createInstance( const String& name ) |
|---|
| 101 | { |
|---|
| 102 | return new FileSystemArchive(name, "FileSystem"); |
|---|
| 103 | } |
|---|
| 104 | /// @copydoc FactoryObj::destroyInstance |
|---|
| 105 | void destroyInstance( Archive* arch) { delete arch; } |
|---|
| 106 | }; |
|---|
| 107 | |
|---|
| 108 | |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | #endif |
|---|