aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/others/irrlicht-1.8.1/include/IFileSystem.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/others/irrlicht-1.8.1/include/IFileSystem.h')
-rw-r--r--src/others/irrlicht-1.8.1/include/IFileSystem.h385
1 files changed, 385 insertions, 0 deletions
diff --git a/src/others/irrlicht-1.8.1/include/IFileSystem.h b/src/others/irrlicht-1.8.1/include/IFileSystem.h
new file mode 100644
index 0000000..f158363
--- /dev/null
+++ b/src/others/irrlicht-1.8.1/include/IFileSystem.h
@@ -0,0 +1,385 @@
1// Copyright (C) 2002-2012 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 __I_FILE_SYSTEM_H_INCLUDED__
6#define __I_FILE_SYSTEM_H_INCLUDED__
7
8#include "IReferenceCounted.h"
9#include "IXMLReader.h"
10#include "IFileArchive.h"
11
12namespace irr
13{
14namespace video
15{
16 class IVideoDriver;
17} // end namespace video
18namespace io
19{
20
21class IReadFile;
22class IWriteFile;
23class IFileList;
24class IXMLWriter;
25class IAttributes;
26
27
28//! The FileSystem manages files and archives and provides access to them.
29/** It manages where files are, so that modules which use the the IO do not
30need to know where every file is located. A file could be in a .zip-Archive or
31as file on disk, using the IFileSystem makes no difference to this. */
32class IFileSystem : public virtual IReferenceCounted
33{
34public:
35
36 //! Opens a file for read access.
37 /** \param filename: Name of file to open.
38 \return Pointer to the created file interface.
39 The returned pointer should be dropped when no longer needed.
40 See IReferenceCounted::drop() for more information. */
41 virtual IReadFile* createAndOpenFile(const path& filename) =0;
42
43 //! Creates an IReadFile interface for accessing memory like a file.
44 /** This allows you to use a pointer to memory where an IReadFile is requested.
45 \param memory: A pointer to the start of the file in memory
46 \param len: The length of the memory in bytes
47 \param fileName: The name given to this file
48 \param deleteMemoryWhenDropped: True if the memory should be deleted
49 along with the IReadFile when it is dropped.
50 \return Pointer to the created file interface.
51 The returned pointer should be dropped when no longer needed.
52 See IReferenceCounted::drop() for more information.
53 */
54 virtual IReadFile* createMemoryReadFile(void* memory, s32 len, const path& fileName, bool deleteMemoryWhenDropped=false) =0;
55
56 //! Creates an IReadFile interface for accessing files inside files.
57 /** This is useful e.g. for archives.
58 \param fileName: The name given to this file
59 \param alreadyOpenedFile: Pointer to the enclosing file
60 \param pos: Start of the file inside alreadyOpenedFile
61 \param areaSize: The length of the file
62 \return A pointer to the created file interface.
63 The returned pointer should be dropped when no longer needed.
64 See IReferenceCounted::drop() for more information.
65 */
66 virtual IReadFile* createLimitReadFile(const path& fileName,
67 IReadFile* alreadyOpenedFile, long pos, long areaSize) =0;
68
69 //! Creates an IWriteFile interface for accessing memory like a file.
70 /** This allows you to use a pointer to memory where an IWriteFile is requested.
71 You are responsible for allocating enough memory.
72 \param memory: A pointer to the start of the file in memory (allocated by you)
73 \param len: The length of the memory in bytes
74 \param fileName: The name given to this file
75 \param deleteMemoryWhenDropped: True if the memory should be deleted
76 along with the IWriteFile when it is dropped.
77 \return Pointer to the created file interface.
78 The returned pointer should be dropped when no longer needed.
79 See IReferenceCounted::drop() for more information.
80 */
81 virtual IWriteFile* createMemoryWriteFile(void* memory, s32 len, const path& fileName, bool deleteMemoryWhenDropped=false) =0;
82
83
84 //! Opens a file for write access.
85 /** \param filename: Name of file to open.
86 \param append: If the file already exist, all write operations are
87 appended to the file.
88 \return Pointer to the created file interface. 0 is returned, if the
89 file could not created or opened for writing.
90 The returned pointer should be dropped when no longer needed.
91 See IReferenceCounted::drop() for more information. */
92 virtual IWriteFile* createAndWriteFile(const path& filename, bool append=false) =0;
93
94 //! Adds an archive to the file system.
95 /** After calling this, the Irrlicht Engine will also search and open
96 files directly from this archive. This is useful for hiding data from
97 the end user, speeding up file access and making it possible to access
98 for example Quake3 .pk3 files, which are just renamed .zip files. By
99 default Irrlicht supports ZIP, PAK, TAR, PNK, and directories as
100 archives. You can provide your own archive types by implementing
101 IArchiveLoader and passing an instance to addArchiveLoader.
102 Irrlicht supports AES-encrypted zip files, and the advanced compression
103 techniques lzma and bzip2.
104 \param filename: Filename of the archive to add to the file system.
105 \param ignoreCase: If set to true, files in the archive can be accessed without
106 writing all letters in the right case.
107 \param ignorePaths: If set to true, files in the added archive can be accessed
108 without its complete path.
109 \param archiveType: If no specific E_FILE_ARCHIVE_TYPE is selected then
110 the type of archive will depend on the extension of the file name. If
111 you use a different extension then you can use this parameter to force
112 a specific type of archive.
113 \param password An optional password, which is used in case of encrypted archives.
114 \param retArchive A pointer that will be set to the archive that is added.
115 \return True if the archive was added successfully, false if not. */
116 virtual bool addFileArchive(const path& filename, bool ignoreCase=true,
117 bool ignorePaths=true,
118 E_FILE_ARCHIVE_TYPE archiveType=EFAT_UNKNOWN,
119 const core::stringc& password="",
120 IFileArchive** retArchive=0) =0;
121
122 //! Adds an archive to the file system.
123 /** After calling this, the Irrlicht Engine will also search and open
124 files directly from this archive. This is useful for hiding data from
125 the end user, speeding up file access and making it possible to access
126 for example Quake3 .pk3 files, which are just renamed .zip files. By
127 default Irrlicht supports ZIP, PAK, TAR, PNK, and directories as
128 archives. You can provide your own archive types by implementing
129 IArchiveLoader and passing an instance to addArchiveLoader.
130 Irrlicht supports AES-encrypted zip files, and the advanced compression
131 techniques lzma and bzip2.
132 If you want to add a directory as an archive, prefix its name with a
133 slash in order to let Irrlicht recognize it as a folder mount (mypath/).
134 Using this technique one can build up a search order, because archives
135 are read first, and can be used more easily with relative filenames.
136 \param file: Archive to add to the file system.
137 \param ignoreCase: If set to true, files in the archive can be accessed without
138 writing all letters in the right case.
139 \param ignorePaths: If set to true, files in the added archive can be accessed
140 without its complete path.
141 \param archiveType: If no specific E_FILE_ARCHIVE_TYPE is selected then
142 the type of archive will depend on the extension of the file name. If
143 you use a different extension then you can use this parameter to force
144 a specific type of archive.
145 \param password An optional password, which is used in case of encrypted archives.
146 \param retArchive A pointer that will be set to the archive that is added.
147 \return True if the archive was added successfully, false if not. */
148 virtual bool addFileArchive(IReadFile* file, bool ignoreCase=true,
149 bool ignorePaths=true,
150 E_FILE_ARCHIVE_TYPE archiveType=EFAT_UNKNOWN,
151 const core::stringc& password="",
152 IFileArchive** retArchive=0) =0;
153
154 //! Adds an archive to the file system.
155 /** \param archive: The archive to add to the file system.
156 \return True if the archive was added successfully, false if not. */
157 virtual bool addFileArchive(IFileArchive* archive) =0;
158
159 //! Get the number of archives currently attached to the file system
160 virtual u32 getFileArchiveCount() const =0;
161
162 //! Removes an archive from the file system.
163 /** This will close the archive and free any file handles, but will not
164 close resources which have already been loaded and are now cached, for
165 example textures and meshes.
166 \param index: The index of the archive to remove
167 \return True on success, false on failure */
168 virtual bool removeFileArchive(u32 index) =0;
169
170 //! Removes an archive from the file system.
171 /** This will close the archive and free any file handles, but will not
172 close resources which have already been loaded and are now cached, for
173 example textures and meshes. Note that a relative filename might be
174 interpreted differently on each call, depending on the current working
175 directory. In case you want to remove an archive that was added using
176 a relative path name, you have to change to the same working directory
177 again. This means, that the filename given on creation is not an
178 identifier for the archive, but just a usual filename that is used for
179 locating the archive to work with.
180 \param filename The archive pointed to by the name will be removed
181 \return True on success, false on failure */
182 virtual bool removeFileArchive(const path& filename) =0;
183
184 //! Removes an archive from the file system.
185 /** This will close the archive and free any file handles, but will not
186 close resources which have already been loaded and are now cached, for
187 example textures and meshes.
188 \param archive The archive to remove.
189 \return True on success, false on failure */
190 virtual bool removeFileArchive(const IFileArchive* archive) =0;
191
192 //! Changes the search order of attached archives.
193 /**
194 \param sourceIndex: The index of the archive to change
195 \param relative: The relative change in position, archives with a lower index are searched first */
196 virtual bool moveFileArchive(u32 sourceIndex, s32 relative) =0;
197
198 //! Get the archive at a given index.
199 virtual IFileArchive* getFileArchive(u32 index) =0;
200
201 //! Adds an external archive loader to the engine.
202 /** Use this function to add support for new archive types to the
203 engine, for example proprietary or encrypted file storage. */
204 virtual void addArchiveLoader(IArchiveLoader* loader) =0;
205
206 //! Gets the number of archive loaders currently added
207 virtual u32 getArchiveLoaderCount() const = 0;
208
209 //! Retrieve the given archive loader
210 /** \param index The index of the loader to retrieve. This parameter is an 0-based
211 array index.
212 \return A pointer to the specified loader, 0 if the index is incorrect. */
213 virtual IArchiveLoader* getArchiveLoader(u32 index) const = 0;
214
215 //! Adds a zip archive to the file system.
216 /** \deprecated This function is provided for compatibility
217 with older versions of Irrlicht and may be removed in Irrlicht 1.9,
218 you should use addFileArchive instead.
219 After calling this, the Irrlicht Engine will search and open files directly from this archive too.
220 This is useful for hiding data from the end user, speeding up file access and making it possible to
221 access for example Quake3 .pk3 files, which are no different than .zip files.
222 \param filename: Filename of the zip archive to add to the file system.
223 \param ignoreCase: If set to true, files in the archive can be accessed without
224 writing all letters in the right case.
225 \param ignorePaths: If set to true, files in the added archive can be accessed
226 without its complete path.
227 \return True if the archive was added successfully, false if not. */
228 _IRR_DEPRECATED_ virtual bool addZipFileArchive(const c8* filename, bool ignoreCase=true, bool ignorePaths=true)
229 {
230 return addFileArchive(filename, ignoreCase, ignorePaths, EFAT_ZIP);
231 }
232
233 //! Adds an unzipped archive (or basedirectory with subdirectories..) to the file system.
234 /** \deprecated This function is provided for compatibility
235 with older versions of Irrlicht and may be removed in Irrlicht 1.9,
236 you should use addFileArchive instead.
237 Useful for handling data which will be in a zip file
238 \param filename: Filename of the unzipped zip archive base directory to add to the file system.
239 \param ignoreCase: If set to true, files in the archive can be accessed without
240 writing all letters in the right case.
241 \param ignorePaths: If set to true, files in the added archive can be accessed
242 without its complete path.
243 \return True if the archive was added successful, false if not. */
244 _IRR_DEPRECATED_ virtual bool addFolderFileArchive(const c8* filename, bool ignoreCase=true, bool ignorePaths=true)
245 {
246 return addFileArchive(filename, ignoreCase, ignorePaths, EFAT_FOLDER);
247 }
248
249 //! Adds a pak archive to the file system.
250 /** \deprecated This function is provided for compatibility
251 with older versions of Irrlicht and may be removed in Irrlicht 1.9,
252 you should use addFileArchive instead.
253 After calling this, the Irrlicht Engine will search and open files directly from this archive too.
254 This is useful for hiding data from the end user, speeding up file access and making it possible to
255 access for example Quake2/KingPin/Hexen2 .pak files
256 \param filename: Filename of the pak archive to add to the file system.
257 \param ignoreCase: If set to true, files in the archive can be accessed without
258 writing all letters in the right case.
259 \param ignorePaths: If set to true, files in the added archive can be accessed
260 without its complete path.(should not use with Quake2 paks
261 \return True if the archive was added successful, false if not. */
262 _IRR_DEPRECATED_ virtual bool addPakFileArchive(const c8* filename, bool ignoreCase=true, bool ignorePaths=true)
263 {
264 return addFileArchive(filename, ignoreCase, ignorePaths, EFAT_PAK);
265 }
266
267 //! Get the current working directory.
268 /** \return Current working directory as a string. */
269 virtual const path& getWorkingDirectory() =0;
270
271 //! Changes the current working directory.
272 /** \param newDirectory: A string specifying the new working directory.
273 The string is operating system dependent. Under Windows it has
274 the form "<drive>:\<directory>\<sudirectory>\<..>". An example would be: "C:\Windows\"
275 \return True if successful, otherwise false. */
276 virtual bool changeWorkingDirectoryTo(const path& newDirectory) =0;
277
278 //! Converts a relative path to an absolute (unique) path, resolving symbolic links if required
279 /** \param filename Possibly relative file or directory name to query.
280 \result Absolute filename which points to the same file. */
281 virtual path getAbsolutePath(const path& filename) const =0;
282
283 //! Get the directory a file is located in.
284 /** \param filename: The file to get the directory from.
285 \return String containing the directory of the file. */
286 virtual path getFileDir(const path& filename) const =0;
287
288 //! Get the base part of a filename, i.e. the name without the directory part.
289 /** If no directory is prefixed, the full name is returned.
290 \param filename: The file to get the basename from
291 \param keepExtension True if filename with extension is returned otherwise everything
292 after the final '.' is removed as well. */
293 virtual path getFileBasename(const path& filename, bool keepExtension=true) const =0;
294
295 //! flatten a path and file name for example: "/you/me/../." becomes "/you"
296 virtual path& flattenFilename(path& directory, const path& root="/") const =0;
297
298 //! Get the relative filename, relative to the given directory
299 virtual path getRelativeFilename(const path& filename, const path& directory) const =0;
300
301 //! Creates a list of files and directories in the current working directory and returns it.
302 /** \return a Pointer to the created IFileList is returned. After the list has been used
303 it has to be deleted using its IFileList::drop() method.
304 See IReferenceCounted::drop() for more information. */
305 virtual IFileList* createFileList() =0;
306
307 //! Creates an empty filelist
308 /** \return a Pointer to the created IFileList is returned. After the list has been used
309 it has to be deleted using its IFileList::drop() method.
310 See IReferenceCounted::drop() for more information. */
311 virtual IFileList* createEmptyFileList(const io::path& path, bool ignoreCase, bool ignorePaths) =0;
312
313 //! Set the active type of file system.
314 virtual EFileSystemType setFileListSystem(EFileSystemType listType) =0;
315
316 //! Determines if a file exists and could be opened.
317 /** \param filename is the string identifying the file which should be tested for existence.
318 \return True if file exists, and false if it does not exist or an error occured. */
319 virtual bool existFile(const path& filename) const =0;
320
321 //! Creates a XML Reader from a file which returns all parsed strings as wide characters (wchar_t*).
322 /** Use createXMLReaderUTF8() if you prefer char* instead of wchar_t*. See IIrrXMLReader for
323 more information on how to use the parser.
324 \return 0, if file could not be opened, otherwise a pointer to the created
325 IXMLReader is returned. After use, the reader
326 has to be deleted using its IXMLReader::drop() method.
327 See IReferenceCounted::drop() for more information. */
328 virtual IXMLReader* createXMLReader(const path& filename) =0;
329
330 //! Creates a XML Reader from a file which returns all parsed strings as wide characters (wchar_t*).
331 /** Use createXMLReaderUTF8() if you prefer char* instead of wchar_t*. See IIrrXMLReader for
332 more information on how to use the parser.
333 \return 0, if file could not be opened, otherwise a pointer to the created
334 IXMLReader is returned. After use, the reader
335 has to be deleted using its IXMLReader::drop() method.
336 See IReferenceCounted::drop() for more information. */
337 virtual IXMLReader* createXMLReader(IReadFile* file) =0;
338
339 //! Creates a XML Reader from a file which returns all parsed strings as ASCII/UTF-8 characters (char*).
340 /** Use createXMLReader() if you prefer wchar_t* instead of char*. See IIrrXMLReader for
341 more information on how to use the parser.
342 \return 0, if file could not be opened, otherwise a pointer to the created
343 IXMLReader is returned. After use, the reader
344 has to be deleted using its IXMLReaderUTF8::drop() method.
345 See IReferenceCounted::drop() for more information. */
346 virtual IXMLReaderUTF8* createXMLReaderUTF8(const path& filename) =0;
347
348 //! Creates a XML Reader from a file which returns all parsed strings as ASCII/UTF-8 characters (char*).
349 /** Use createXMLReader() if you prefer wchar_t* instead of char*. See IIrrXMLReader for
350 more information on how to use the parser.
351 \return 0, if file could not be opened, otherwise a pointer to the created
352 IXMLReader is returned. After use, the reader
353 has to be deleted using its IXMLReaderUTF8::drop() method.
354 See IReferenceCounted::drop() for more information. */
355 virtual IXMLReaderUTF8* createXMLReaderUTF8(IReadFile* file) =0;
356
357 //! Creates a XML Writer from a file.
358 /** \return 0, if file could not be opened, otherwise a pointer to the created
359 IXMLWriter is returned. After use, the reader
360 has to be deleted using its IXMLWriter::drop() method.
361 See IReferenceCounted::drop() for more information. */
362 virtual IXMLWriter* createXMLWriter(const path& filename) =0;
363
364 //! Creates a XML Writer from a file.
365 /** \return 0, if file could not be opened, otherwise a pointer to the created
366 IXMLWriter is returned. After use, the reader
367 has to be deleted using its IXMLWriter::drop() method.
368 See IReferenceCounted::drop() for more information. */
369 virtual IXMLWriter* createXMLWriter(IWriteFile* file) =0;
370
371 //! Creates a new empty collection of attributes, usable for serialization and more.
372 /** \param driver: Video driver to be used to load textures when specified as attribute values.
373 Can be null to prevent automatic texture loading by attributes.
374 \return Pointer to the created object.
375 If you no longer need the object, you should call IAttributes::drop().
376 See IReferenceCounted::drop() for more information. */
377 virtual IAttributes* createEmptyAttributes(video::IVideoDriver* driver=0) =0;
378};
379
380
381} // end namespace io
382} // end namespace irr
383
384#endif
385