2020-01-03 20:05:16 +01:00
|
|
|
// Copyright (C) 2002-2012 Nikolaus Gebhardt
|
|
|
|
// This file is part of the "Irrlicht Engine".
|
|
|
|
// For conditions of distribution and use, see copyright notice in irrlicht.h
|
|
|
|
|
|
|
|
#ifndef __C_FILE_SYSTEM_H_INCLUDED__
|
|
|
|
#define __C_FILE_SYSTEM_H_INCLUDED__
|
|
|
|
|
|
|
|
#include "IFileSystem.h"
|
|
|
|
#include "irrArray.h"
|
|
|
|
|
|
|
|
namespace irr
|
|
|
|
{
|
|
|
|
namespace io
|
|
|
|
{
|
|
|
|
|
|
|
|
class CZipReader;
|
|
|
|
|
|
|
|
/*!
|
|
|
|
FileSystem which uses normal files and one zipfile
|
|
|
|
*/
|
|
|
|
class CFileSystem : public IFileSystem
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
|
|
|
//! constructor
|
|
|
|
CFileSystem();
|
|
|
|
|
|
|
|
//! destructor
|
|
|
|
virtual ~CFileSystem();
|
|
|
|
|
|
|
|
//! opens a file for read access
|
2022-10-09 20:57:28 +02:00
|
|
|
IReadFile* createAndOpenFile(const io::path& filename) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Creates an IReadFile interface for accessing memory like a file.
|
2022-10-09 20:57:28 +02:00
|
|
|
IReadFile* createMemoryReadFile(const void* memory, s32 len, const io::path& fileName, bool deleteMemoryWhenDropped = false) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Creates an IReadFile interface for accessing files inside files
|
2022-10-09 20:57:28 +02:00
|
|
|
IReadFile* createLimitReadFile(const io::path& fileName, IReadFile* alreadyOpenedFile, long pos, long areaSize) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Creates an IWriteFile interface for accessing memory like a file.
|
2022-10-09 20:57:28 +02:00
|
|
|
IWriteFile* createMemoryWriteFile(void* memory, s32 len, const io::path& fileName, bool deleteMemoryWhenDropped=false) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Opens a file for write access.
|
2022-10-09 20:57:28 +02:00
|
|
|
IWriteFile* createAndWriteFile(const io::path& filename, bool append=false) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Adds an archive to the file system.
|
|
|
|
virtual bool addFileArchive(const io::path& filename,
|
|
|
|
bool ignoreCase = true, bool ignorePaths = true,
|
|
|
|
E_FILE_ARCHIVE_TYPE archiveType = EFAT_UNKNOWN,
|
|
|
|
const core::stringc& password="",
|
2022-10-09 20:57:28 +02:00
|
|
|
IFileArchive** retArchive = 0) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Adds an archive to the file system.
|
|
|
|
virtual bool addFileArchive(IReadFile* file, bool ignoreCase=true,
|
|
|
|
bool ignorePaths=true,
|
|
|
|
E_FILE_ARCHIVE_TYPE archiveType=EFAT_UNKNOWN,
|
|
|
|
const core::stringc& password="",
|
2022-10-09 20:57:28 +02:00
|
|
|
IFileArchive** retArchive = 0) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Adds an archive to the file system.
|
2022-10-09 20:57:28 +02:00
|
|
|
bool addFileArchive(IFileArchive* archive) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! move the hirarchy of the filesystem. moves sourceIndex relative up or down
|
2022-10-09 20:57:28 +02:00
|
|
|
bool moveFileArchive(u32 sourceIndex, s32 relative) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Adds an external archive loader to the engine.
|
2022-10-09 20:57:28 +02:00
|
|
|
void addArchiveLoader(IArchiveLoader* loader) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Returns the total number of archive loaders added.
|
2022-10-09 20:57:28 +02:00
|
|
|
u32 getArchiveLoaderCount() const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Gets the archive loader by index.
|
2022-10-09 20:57:28 +02:00
|
|
|
IArchiveLoader* getArchiveLoader(u32 index) const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! gets the file archive count
|
2022-10-09 20:57:28 +02:00
|
|
|
u32 getFileArchiveCount() const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! gets an archive
|
2022-10-09 20:57:28 +02:00
|
|
|
IFileArchive* getFileArchive(u32 index) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! removes an archive from the file system.
|
2022-10-09 20:57:28 +02:00
|
|
|
bool removeFileArchive(u32 index) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! removes an archive from the file system.
|
2022-10-09 20:57:28 +02:00
|
|
|
bool removeFileArchive(const io::path& filename) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Removes an archive from the file system.
|
2022-10-09 20:57:28 +02:00
|
|
|
bool removeFileArchive(const IFileArchive* archive) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Returns the string of the current working directory
|
2022-10-09 20:57:28 +02:00
|
|
|
const io::path& getWorkingDirectory() override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Changes the current Working Directory to the string given.
|
|
|
|
//! The string is operating system dependent. Under Windows it will look
|
|
|
|
//! like this: "drive:\directory\sudirectory\"
|
2022-10-09 20:57:28 +02:00
|
|
|
bool changeWorkingDirectoryTo(const io::path& newDirectory) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Converts a relative path to an absolute (unique) path, resolving symbolic links
|
2022-10-09 20:57:28 +02:00
|
|
|
io::path getAbsolutePath(const io::path& filename) const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Returns the directory a file is located in.
|
|
|
|
/** \param filename: The file to get the directory from */
|
2022-10-09 20:57:28 +02:00
|
|
|
io::path getFileDir(const io::path& filename) const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Returns the base part of a filename, i.e. the name without the directory
|
|
|
|
//! part. If no directory is prefixed, the full name is returned.
|
|
|
|
/** \param filename: The file to get the basename from */
|
2022-10-09 20:57:28 +02:00
|
|
|
io::path getFileBasename(const io::path& filename, bool keepExtension=true) const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! flatten a path and file name for example: "/you/me/../." becomes "/you"
|
2022-10-09 20:57:28 +02:00
|
|
|
io::path& flattenFilename( io::path& directory, const io::path& root = "/" ) const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Get the relative filename, relative to the given directory
|
2022-10-09 20:57:28 +02:00
|
|
|
path getRelativeFilename(const path& filename, const path& directory) const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
2022-10-09 20:57:28 +02:00
|
|
|
EFileSystemType setFileListSystem(EFileSystemType listType) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Creates a list of files and directories in the current working directory
|
|
|
|
//! and returns it.
|
2022-10-09 20:57:28 +02:00
|
|
|
IFileList* createFileList() override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! Creates an empty filelist
|
2022-10-09 20:57:28 +02:00
|
|
|
IFileList* createEmptyFileList(const io::path& path, bool ignoreCase, bool ignorePaths) override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
//! determines if a file exists and would be able to be opened.
|
2022-10-09 20:57:28 +02:00
|
|
|
bool existFile(const io::path& filename) const override;
|
2020-01-03 20:05:16 +01:00
|
|
|
|
|
|
|
private:
|
|
|
|
|
|
|
|
//! Currently used FileSystemType
|
|
|
|
EFileSystemType FileSystemType;
|
|
|
|
//! WorkingDirectory for Native and Virtual filesystems
|
|
|
|
io::path WorkingDirectory [2];
|
|
|
|
//! currently attached ArchiveLoaders
|
|
|
|
core::array<IArchiveLoader*> ArchiveLoader;
|
|
|
|
//! currently attached Archives
|
|
|
|
core::array<IFileArchive*> FileArchives;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
} // end namespace irr
|
|
|
|
} // end namespace io
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|