source: OGRE/trunk/ogrenew/OgreMain/include/OgreFileSystem.h @ 692

Revision 692, 4.4 KB checked in by mattausch, 19 years ago (diff)

adding ogre 1.2 and dependencies

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