~baltix/+junk/irrlicht-test

« back to all changes in this revision

Viewing changes to source/Irrlicht/CFileSystem.h

  • Committer: Mantas Kriaučiūnas
  • Date: 2011-07-18 13:06:25 UTC
  • Revision ID: mantas@akl.lt-20110718130625-c5pvifp61e7kj1ol
Included whole irrlicht SVN libraries to work around launchpad recipe issue with quilt, see https://answers.launchpad.net/launchpad/+question/165193

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// Copyright (C) 2002-2011 Nikolaus Gebhardt
 
2
// This file is part of the "Irrlicht Engine".
 
3
// For conditions of distribution and use, see copyright notice in irrlicht.h
 
4
 
 
5
#ifndef __C_FILE_SYSTEM_H_INCLUDED__
 
6
#define __C_FILE_SYSTEM_H_INCLUDED__
 
7
 
 
8
#include "IFileSystem.h"
 
9
#include "irrArray.h"
 
10
 
 
11
namespace irr
 
12
{
 
13
namespace io
 
14
{
 
15
 
 
16
        class CZipReader;
 
17
        class CPakReader;
 
18
        class CMountPointReader;
 
19
 
 
20
/*!
 
21
        FileSystem which uses normal files and one zipfile
 
22
*/
 
23
class CFileSystem : public IFileSystem
 
24
{
 
25
public:
 
26
 
 
27
        //! constructor
 
28
        CFileSystem();
 
29
 
 
30
        //! destructor
 
31
        virtual ~CFileSystem();
 
32
 
 
33
        //! opens a file for read access
 
34
        virtual IReadFile* createAndOpenFile(const io::path& filename);
 
35
 
 
36
        //! Creates an IReadFile interface for accessing memory like a file.
 
37
        virtual IReadFile* createMemoryReadFile(void* memory, s32 len, const io::path& fileName, bool deleteMemoryWhenDropped = false);
 
38
 
 
39
        //! Creates an IReadFile interface for accessing files inside files
 
40
        virtual IReadFile* createLimitReadFile(const io::path& fileName, IReadFile* alreadyOpenedFile, long pos, long areaSize);
 
41
 
 
42
        //! Creates an IWriteFile interface for accessing memory like a file.
 
43
        virtual IWriteFile* createMemoryWriteFile(void* memory, s32 len, const io::path& fileName, bool deleteMemoryWhenDropped=false);
 
44
 
 
45
        //! Opens a file for write access.
 
46
        virtual IWriteFile* createAndWriteFile(const io::path& filename, bool append=false);
 
47
 
 
48
        //! Adds an archive to the file system.
 
49
        virtual bool addFileArchive(const io::path& filename,
 
50
                        bool ignoreCase = true, bool ignorePaths = true,
 
51
                        E_FILE_ARCHIVE_TYPE archiveType = EFAT_UNKNOWN,
 
52
                        const core::stringc& password="");
 
53
 
 
54
        //! Adds an archive to the file system.
 
55
        virtual bool addFileArchive(IReadFile* file, bool ignoreCase=true,
 
56
                        bool ignorePaths=true,
 
57
                        E_FILE_ARCHIVE_TYPE archiveType=EFAT_UNKNOWN,
 
58
                        const core::stringc& password="");
 
59
 
 
60
        //! move the hirarchy of the filesystem. moves sourceIndex relative up or down
 
61
        virtual bool moveFileArchive( u32 sourceIndex, s32 relative );
 
62
 
 
63
        //! Adds an external archive loader to the engine.
 
64
        virtual void addArchiveLoader(IArchiveLoader* loader);
 
65
 
 
66
        //! Returns the total number of archive loaders added.
 
67
        virtual u32 getArchiveLoaderCount() const;
 
68
 
 
69
        //! Gets the archive loader by index.
 
70
        virtual IArchiveLoader* getArchiveLoader(u32 index) const;
 
71
 
 
72
        //! gets the file archive count
 
73
        virtual u32 getFileArchiveCount() const;
 
74
 
 
75
        //! gets an archive
 
76
        virtual IFileArchive* getFileArchive(u32 index);
 
77
 
 
78
        //! removes an archive from the file system.
 
79
        virtual bool removeFileArchive(u32 index);
 
80
 
 
81
        //! removes an archive from the file system.
 
82
        virtual bool removeFileArchive(const io::path& filename);
 
83
 
 
84
        //! Returns the string of the current working directory
 
85
        virtual const io::path& getWorkingDirectory();
 
86
 
 
87
        //! Changes the current Working Directory to the string given.
 
88
        //! The string is operating system dependent. Under Windows it will look
 
89
        //! like this: "drive:\directory\sudirectory\"
 
90
        virtual bool changeWorkingDirectoryTo(const io::path& newDirectory);
 
91
 
 
92
        //! Converts a relative path to an absolute (unique) path, resolving symbolic links
 
93
        virtual io::path getAbsolutePath(const io::path& filename) const;
 
94
 
 
95
        //! Returns the directory a file is located in.
 
96
        /** \param filename: The file to get the directory from */
 
97
        virtual io::path getFileDir(const io::path& filename) const;
 
98
 
 
99
        //! Returns the base part of a filename, i.e. the name without the directory
 
100
        //! part. If no directory is prefixed, the full name is returned.
 
101
        /** \param filename: The file to get the basename from */
 
102
        virtual io::path getFileBasename(const io::path& filename, bool keepExtension=true) const;
 
103
 
 
104
        //! flatten a path and file name for example: "/you/me/../." becomes "/you"
 
105
        virtual io::path& flattenFilename( io::path& directory, const io::path& root = "/" ) const;
 
106
 
 
107
        //! Get the relative filename, relative to the given directory
 
108
        virtual path getRelativeFilename(const path& filename, const path& directory) const;
 
109
 
 
110
        virtual EFileSystemType setFileListSystem(EFileSystemType listType);
 
111
 
 
112
        //! Creates a list of files and directories in the current working directory
 
113
        //! and returns it.
 
114
        virtual IFileList* createFileList();
 
115
 
 
116
        //! Creates an empty filelist
 
117
        virtual IFileList* createEmptyFileList(const io::path& path, bool ignoreCase, bool ignorePaths);
 
118
 
 
119
        //! determines if a file exists and would be able to be opened.
 
120
        virtual bool existFile(const io::path& filename) const;
 
121
 
 
122
        //! Creates a XML Reader from a file.
 
123
        virtual IXMLReader* createXMLReader(const io::path& filename);
 
124
 
 
125
        //! Creates a XML Reader from a file.
 
126
        virtual IXMLReader* createXMLReader(IReadFile* file);
 
127
 
 
128
        //! Creates a XML Reader from a file.
 
129
        virtual IXMLReaderUTF8* createXMLReaderUTF8(const io::path& filename);
 
130
 
 
131
        //! Creates a XML Reader from a file.
 
132
        virtual IXMLReaderUTF8* createXMLReaderUTF8(IReadFile* file);
 
133
 
 
134
        //! Creates a XML Writer from a file.
 
135
        virtual IXMLWriter* createXMLWriter(const io::path& filename);
 
136
 
 
137
        //! Creates a XML Writer from a file.
 
138
        virtual IXMLWriter* createXMLWriter(IWriteFile* file);
 
139
 
 
140
        //! Creates a new empty collection of attributes, usable for serialization and more.
 
141
        virtual IAttributes* createEmptyAttributes(video::IVideoDriver* driver);
 
142
 
 
143
private:
 
144
 
 
145
        // don't expose, needs refactoring
 
146
        bool changeArchivePassword(const path& filename, const core::stringc& password);
 
147
 
 
148
        //! Currently used FileSystemType
 
149
        EFileSystemType FileSystemType;
 
150
        //! WorkingDirectory for Native and Virtual filesystems
 
151
        io::path WorkingDirectory [2];
 
152
        //! currently attached ArchiveLoaders
 
153
        core::array<IArchiveLoader*> ArchiveLoader;
 
154
        //! currently attached Archives
 
155
        core::array<IFileArchive*> FileArchives;
 
156
};
 
157
 
 
158
 
 
159
} // end namespace irr
 
160
} // end namespace io
 
161
 
 
162
#endif
 
163