1 // Copyright (C) 2002-2012 Nikolaus Gebhardt
\r
2 // This file is part of the "Irrlicht Engine".
\r
3 // For conditions of distribution and use, see copyright notice in irrlicht.h
\r
5 #ifndef __C_FILE_SYSTEM_H_INCLUDED__
\r
6 #define __C_FILE_SYSTEM_H_INCLUDED__
\r
8 #include "IFileSystem.h"
\r
9 #include "irrArray.h"
\r
19 FileSystem which uses normal files and one zipfile
\r
21 class CFileSystem : public IFileSystem
\r
29 virtual ~CFileSystem();
\r
31 //! opens a file for read access
\r
32 IReadFile* createAndOpenFile(const io::path& filename) override;
\r
34 //! Creates an IReadFile interface for accessing memory like a file.
\r
35 IReadFile* createMemoryReadFile(const void* memory, s32 len, const io::path& fileName, bool deleteMemoryWhenDropped = false) override;
\r
37 //! Creates an IReadFile interface for accessing files inside files
\r
38 IReadFile* createLimitReadFile(const io::path& fileName, IReadFile* alreadyOpenedFile, long pos, long areaSize) override;
\r
40 //! Creates an IWriteFile interface for accessing memory like a file.
\r
41 IWriteFile* createMemoryWriteFile(void* memory, s32 len, const io::path& fileName, bool deleteMemoryWhenDropped=false) override;
\r
43 //! Opens a file for write access.
\r
44 IWriteFile* createAndWriteFile(const io::path& filename, bool append=false) override;
\r
46 //! Adds an archive to the file system.
\r
47 virtual bool addFileArchive(const io::path& filename,
\r
48 bool ignoreCase = true, bool ignorePaths = true,
\r
49 E_FILE_ARCHIVE_TYPE archiveType = EFAT_UNKNOWN,
\r
50 const core::stringc& password="",
\r
51 IFileArchive** retArchive = 0) override;
\r
53 //! Adds an archive to the file system.
\r
54 virtual bool addFileArchive(IReadFile* file, bool ignoreCase=true,
\r
55 bool ignorePaths=true,
\r
56 E_FILE_ARCHIVE_TYPE archiveType=EFAT_UNKNOWN,
\r
57 const core::stringc& password="",
\r
58 IFileArchive** retArchive = 0) override;
\r
60 //! Adds an archive to the file system.
\r
61 bool addFileArchive(IFileArchive* archive) override;
\r
63 //! move the hirarchy of the filesystem. moves sourceIndex relative up or down
\r
64 bool moveFileArchive(u32 sourceIndex, s32 relative) override;
\r
66 //! Adds an external archive loader to the engine.
\r
67 void addArchiveLoader(IArchiveLoader* loader) override;
\r
69 //! Returns the total number of archive loaders added.
\r
70 u32 getArchiveLoaderCount() const override;
\r
72 //! Gets the archive loader by index.
\r
73 IArchiveLoader* getArchiveLoader(u32 index) const override;
\r
75 //! gets the file archive count
\r
76 u32 getFileArchiveCount() const override;
\r
79 IFileArchive* getFileArchive(u32 index) override;
\r
81 //! removes an archive from the file system.
\r
82 bool removeFileArchive(u32 index) override;
\r
84 //! removes an archive from the file system.
\r
85 bool removeFileArchive(const io::path& filename) override;
\r
87 //! Removes an archive from the file system.
\r
88 bool removeFileArchive(const IFileArchive* archive) override;
\r
90 //! Returns the string of the current working directory
\r
91 const io::path& getWorkingDirectory() override;
\r
93 //! Changes the current Working Directory to the string given.
\r
94 //! The string is operating system dependent. Under Windows it will look
\r
95 //! like this: "drive:\directory\sudirectory\"
\r
96 bool changeWorkingDirectoryTo(const io::path& newDirectory) override;
\r
98 //! Converts a relative path to an absolute (unique) path, resolving symbolic links
\r
99 io::path getAbsolutePath(const io::path& filename) const override;
\r
101 //! Returns the directory a file is located in.
\r
102 /** \param filename: The file to get the directory from */
\r
103 io::path getFileDir(const io::path& filename) const override;
\r
105 //! Returns the base part of a filename, i.e. the name without the directory
\r
106 //! part. If no directory is prefixed, the full name is returned.
\r
107 /** \param filename: The file to get the basename from */
\r
108 io::path getFileBasename(const io::path& filename, bool keepExtension=true) const override;
\r
110 //! flatten a path and file name for example: "/you/me/../." becomes "/you"
\r
111 io::path& flattenFilename( io::path& directory, const io::path& root = "/" ) const override;
\r
113 //! Get the relative filename, relative to the given directory
\r
114 path getRelativeFilename(const path& filename, const path& directory) const override;
\r
116 EFileSystemType setFileListSystem(EFileSystemType listType) override;
\r
118 //! Creates a list of files and directories in the current working directory
\r
119 //! and returns it.
\r
120 IFileList* createFileList() override;
\r
122 //! Creates an empty filelist
\r
123 IFileList* createEmptyFileList(const io::path& path, bool ignoreCase, bool ignorePaths) override;
\r
125 //! determines if a file exists and would be able to be opened.
\r
126 bool existFile(const io::path& filename) const override;
\r
130 //! Currently used FileSystemType
\r
131 EFileSystemType FileSystemType;
\r
132 //! WorkingDirectory for Native and Virtual filesystems
\r
133 io::path WorkingDirectory [2];
\r
134 //! currently attached ArchiveLoaders
\r
135 core::array<IArchiveLoader*> ArchiveLoader;
\r
136 //! currently attached Archives
\r
137 core::array<IFileArchive*> FileArchives;
\r
141 } // end namespace irr
\r
142 } // end namespace io
\r