IFileSystem



Describes minimum requirements from interface providing access to platform file system.

You can find more information in comments below.

class IFileSystem
{
public:
    enum OPEN_MODE // File open modes
    {
        omCreateAlways, // Creates a new file, always
        omCreateNew, // Creates a new file, only if it does not already exist
        omOpenAlways, // Opens a file, always
        omOpenExisting, // Opens a file or device, only if it exists
        omTrancateExisting // Opens a file and truncates it so that its size is zero bytes, only if it exists
    };

    struct SEARCH_FILE_INFO // Describes file/directory
    {
        String Name; // Name without path
        long long Size; // Size
        bool Archieved; // Whether it is archieved
        bool Compressed; // Whether it is compressed
        bool Directory; // Whether it is directory
        bool Encrypted; // Whether it is encrypted
        bool Hidden; // Whether it is hidden
        bool Normal; // Whether it is normal file
        bool Offline; // Whether it is offline
        bool Readonly; // Whether it is readonly
        bool System; // Whether it is system file
        bool Temporary; // Whether it is temporary file
    };

    using SearchFilesResult = std::vector<SEARCH_FILE_INFO>; // Array of file descriptions
    using SearchDrivesResult = std::vector<String>; // Array with found drive names
public:
    virtual bool SearchFiles(const String &filter, SearchFilesResult &result) = 0; // Search files. Filter is like C:\*.* or D:\docs\?ooking*.pdf
    virtual bool FileExists(const String &filename) = 0; // Check whether specified file exists
    virtual bool DirectoryExists(const String &path) = 0; // Check whether specified directory exists
    virtual SearchDrivesResult SearchDrives() = 0; // Return all found drives(volumes) which are mounted as drives
    // Since 5.0.0
    virtual IFile *FileOpen( // Create or open a file. Return nullptr if failed
        const String &filename, // The name of the file or device to be created or opened
        const OPEN_MODE open_mode,
        const bool read, // Whether read access is required
        const bool write, // Whether write access is required
        const bool share_delete = false, // Enables subsequent open operations on a file or device to request delete access
        const bool share_read = false, // Enables subsequent open operations on a file or device to request read access
        const bool share_write = false, // Enables subsequent open operations on a file or device to request write access
        const bool archieved = false, // The file should be archived
        const bool encrypted = false, // The file or directory is encrypted
        const bool hidden = false, // The file is hidden
        const bool offline = false, // The data of a file is not immediately available
        const bool readonly = false, // The file is read only
        const bool system = false, // The file is part of or used exclusively by an operating system
        const bool temporary = false, // The file is being used for temporary storage
        const bool delete_on_close = false, // The file is to be deleted immediately after all of its handles are closed
        const bool no_buffering = false, // The file or device is being opened with no system caching for data reads and writes
        const bool random_access = false) = 0; // Access is intended to be random. The system can use this as a hint to optimize file caching
    virtual bool FileCopy(const String &filename, const String &new_filename, const bool overwrite_existing) = 0; // Copy file
    virtual bool FileMove(const String &filename, const String &new_filename, const bool overwrite_existing) = 0; // Rename file
    virtual bool FileDelete(const String &filename) = 0; // Delete file
    virtual bool DirectoryCreate(const String &path) = 0; // Create new directory
    virtual bool DirectoryMove(const String &path, const String &new_path, const bool overwrite_existing) = 0; // Rename directory
    virtual bool DirectoryDelete(const String &path) = 0; // Delete directory. Usually should be empty
};
Namespace: nitisa
Include: Nitisa/Interfaces/IFileSystem.h