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
5
#ifndef __C_FILE_SYSTEM_H_INCLUDED__
6
#define __C_FILE_SYSTEM_H_INCLUDED__
8
#include "IFileSystem.h"
18
class CMountPointReader;
21
FileSystem which uses normal files and one zipfile
23
class CFileSystem : public IFileSystem
31
virtual ~CFileSystem();
33
//! opens a file for read access
34
virtual IReadFile* createAndOpenFile(const io::path& filename);
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);
39
//! Creates an IReadFile interface for accessing files inside files
40
virtual IReadFile* createLimitReadFile(const io::path& fileName, IReadFile* alreadyOpenedFile, long pos, long areaSize);
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);
45
//! Opens a file for write access.
46
virtual IWriteFile* createAndWriteFile(const io::path& filename, bool append=false);
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="");
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="");
60
//! move the hirarchy of the filesystem. moves sourceIndex relative up or down
61
virtual bool moveFileArchive( u32 sourceIndex, s32 relative );
63
//! Adds an external archive loader to the engine.
64
virtual void addArchiveLoader(IArchiveLoader* loader);
66
//! Returns the total number of archive loaders added.
67
virtual u32 getArchiveLoaderCount() const;
69
//! Gets the archive loader by index.
70
virtual IArchiveLoader* getArchiveLoader(u32 index) const;
72
//! gets the file archive count
73
virtual u32 getFileArchiveCount() const;
76
virtual IFileArchive* getFileArchive(u32 index);
78
//! removes an archive from the file system.
79
virtual bool removeFileArchive(u32 index);
81
//! removes an archive from the file system.
82
virtual bool removeFileArchive(const io::path& filename);
84
//! Returns the string of the current working directory
85
virtual const io::path& getWorkingDirectory();
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);
92
//! Converts a relative path to an absolute (unique) path, resolving symbolic links
93
virtual io::path getAbsolutePath(const io::path& filename) const;
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;
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;
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;
107
//! Get the relative filename, relative to the given directory
108
virtual path getRelativeFilename(const path& filename, const path& directory) const;
110
virtual EFileSystemType setFileListSystem(EFileSystemType listType);
112
//! Creates a list of files and directories in the current working directory
114
virtual IFileList* createFileList();
116
//! Creates an empty filelist
117
virtual IFileList* createEmptyFileList(const io::path& path, bool ignoreCase, bool ignorePaths);
119
//! determines if a file exists and would be able to be opened.
120
virtual bool existFile(const io::path& filename) const;
122
//! Creates a XML Reader from a file.
123
virtual IXMLReader* createXMLReader(const io::path& filename);
125
//! Creates a XML Reader from a file.
126
virtual IXMLReader* createXMLReader(IReadFile* file);
128
//! Creates a XML Reader from a file.
129
virtual IXMLReaderUTF8* createXMLReaderUTF8(const io::path& filename);
131
//! Creates a XML Reader from a file.
132
virtual IXMLReaderUTF8* createXMLReaderUTF8(IReadFile* file);
134
//! Creates a XML Writer from a file.
135
virtual IXMLWriter* createXMLWriter(const io::path& filename);
137
//! Creates a XML Writer from a file.
138
virtual IXMLWriter* createXMLWriter(IWriteFile* file);
140
//! Creates a new empty collection of attributes, usable for serialization and more.
141
virtual IAttributes* createEmptyAttributes(video::IVideoDriver* driver);
145
// don't expose, needs refactoring
146
bool changeArchivePassword(const path& filename, const core::stringc& password);
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;
159
} // end namespace irr
160
} // end namespace io