CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::LocalFileHandle Class Reference

File handle for the local file system. More...

#include <CeresEngine/Platform/Generic/LocalFileHandle.hpp>

Inheritance diagram for CeresEngine::LocalFileHandle:
CeresEngine::IFileHandle CeresEngine::POSIXFileHandle CeresEngine::Win32FileHandle

Public Member Functions

 LocalFileHandle (LocalFileSystem &fileSystem, StringView path)
 
 LocalFileHandle (LocalFileSystem &fileSystem, String &&path)
 
 ~LocalFileHandle () override
 
IFileSystemgetFileSystem () const override
 Gets the backing IFileSystem for the handle.
 
void updateFileInfo () override
 Update file information.
 
StringView getPath () const override
 
bool exists () const override
 Checks if the file exists on the file system.
 
bool isFile () const override
 Checks if item is a file.
 
bool isDirectory () const override
 Checks if item is a directory.
 
bool isSymbolicLink () const override
 Checks if item is a symbolic link.
 
FileIterator begin () const override
 Gets an iterator that points to the first directory entry.
 
UInt64 getSize () const override
 Gets the file size.
 
Int64 getAccessTime () const override
 Gets the time of last access.
 
Int64 getModificationTime () const override
 Gets time of last modification.
 
bool createDirectory () override
 Creates a new directory.
 
bool removeDirectory () override
 Removes a directory.
 
bool copy (IFileHandle &dest) override
 Copies a file.
 
bool move (IFileHandle &dest) override
 Moves a file.
 
bool createLink (IFileHandle &dest) override
 Creates a hard link.
 
bool createSymbolicLink (IFileHandle &dest) override
 Creates a symbolic link.
 
bool rename (StringView filename) override
 Renames a file or directory.
 
bool remove () override
 Removes a file.
 
InputStream createInputStream (std::ios_base::openmode mode) const override
 Creates an input stream to read from the file.
 
OutputStream createOutputStream (std::ios_base::openmode mode) override
 Creates an output stream to write to the file.
 
- Public Member Functions inherited from CeresEngine::IFileHandle
 IFileHandle ()=default
 
virtual ~IFileHandle ()=default
 

Protected Attributes

RC< LocalFileSystemmFileSystem
 The file system that created this handle.
 
FilePath mPath
 Path to file or directory.
 
std::filesystem::path mFileSystemPath
 Same as mPath, but in the C++17 std::filesystem format.
 

Detailed Description

File handle for the local file system.

Constructor & Destructor Documentation

◆ LocalFileHandle() [1/2]

CeresEngine::LocalFileHandle::LocalFileHandle ( LocalFileSystem fileSystem,
StringView  path 
)

◆ LocalFileHandle() [2/2]

CeresEngine::LocalFileHandle::LocalFileHandle ( LocalFileSystem fileSystem,
String &&  path 
)

◆ ~LocalFileHandle()

CeresEngine::LocalFileHandle::~LocalFileHandle ( )
override

Member Function Documentation

◆ begin()

FileIterator CeresEngine::LocalFileHandle::begin ( ) const
overridevirtual

Gets an iterator that points to the first directory entry.

Returns
An iterator to the directory contents.

Implements CeresEngine::IFileHandle.

◆ copy()

bool CeresEngine::LocalFileHandle::copy ( IFileHandle dest)
overridevirtual

Copies a file.

Parameters
destThe destination file or directory.
Returns
true if successful, else false.

Implements CeresEngine::IFileHandle.

◆ createDirectory()

bool CeresEngine::LocalFileHandle::createDirectory ( )
overridevirtual

Creates a new directory.

Returns
true if successful, else false.

Implements CeresEngine::IFileHandle.

◆ createInputStream()

InputStream CeresEngine::LocalFileHandle::createInputStream ( std::ios_base::openmode  mode) const
overridevirtual

Creates an input stream to read from the file.

Returns
The input stream. Can be nullptr if opening the stream failed.

Implements CeresEngine::IFileHandle.

◆ createLink()

bool CeresEngine::LocalFileHandle::createLink ( IFileHandle dest)
overridevirtual

Creates a hard link.

Parameters
destThe destination file or directory.
Returns
true if successful, else false.

Implements CeresEngine::IFileHandle.

◆ createOutputStream()

OutputStream CeresEngine::LocalFileHandle::createOutputStream ( std::ios_base::openmode  mode)
overridevirtual

Creates an output stream to write to the file.

Returns
The output stream. Can be nullptr if opening the stream failed.

Implements CeresEngine::IFileHandle.

◆ createSymbolicLink()

bool CeresEngine::LocalFileHandle::createSymbolicLink ( IFileHandle dest)
overridevirtual

Creates a symbolic link.

Parameters
destThe destination file or directory.
Returns
true if successful, else false.

Implements CeresEngine::IFileHandle.

◆ exists()

bool CeresEngine::LocalFileHandle::exists ( ) const
overridevirtual

Checks if the file exists on the file system.

Returns
true if it exists, else false.

Implements CeresEngine::IFileHandle.

◆ getAccessTime()

Int64 CeresEngine::LocalFileHandle::getAccessTime ( ) const
overridevirtual

Gets the time of last access.

Implements CeresEngine::IFileHandle.

Reimplemented in CeresEngine::Win32FileHandle, and CeresEngine::POSIXFileHandle.

◆ getFileSystem()

IFileSystem * CeresEngine::LocalFileHandle::getFileSystem ( ) const
overridevirtual

Gets the backing IFileSystem for the handle.

Can be nullptr if the handle is empty.

Implements CeresEngine::IFileHandle.

◆ getModificationTime()

Int64 CeresEngine::LocalFileHandle::getModificationTime ( ) const
overridevirtual

Gets time of last modification.

Implements CeresEngine::IFileHandle.

Reimplemented in CeresEngine::Win32FileHandle, and CeresEngine::POSIXFileHandle.

◆ getPath()

StringView CeresEngine::LocalFileHandle::getPath ( ) const
overridevirtual

Returns
The path to file or directory

Implements CeresEngine::IFileHandle.

◆ getSize()

UInt64 CeresEngine::LocalFileHandle::getSize ( ) const
overridevirtual

Gets the file size.

Returns
The file size if handle points to a file, else 0.

Implements CeresEngine::IFileHandle.

◆ isDirectory()

bool CeresEngine::LocalFileHandle::isDirectory ( ) const
overridevirtual

Checks if item is a directory.

Returns
true if it is a directory, else false.

Implements CeresEngine::IFileHandle.

◆ isFile()

bool CeresEngine::LocalFileHandle::isFile ( ) const
overridevirtual

Checks if item is a file.

Returns
true if it is a file, else false.

Implements CeresEngine::IFileHandle.

◆ isSymbolicLink()

bool CeresEngine::LocalFileHandle::isSymbolicLink ( ) const
overridevirtual

Checks if item is a symbolic link.

Returns
true if it is a symbolic link, else false.

Implements CeresEngine::IFileHandle.

◆ move()

bool CeresEngine::LocalFileHandle::move ( IFileHandle dest)
overridevirtual

Moves a file.

Parameters
destThe destination file or directory.
Returns
true if successful, else false.

Implements CeresEngine::IFileHandle.

◆ remove()

bool CeresEngine::LocalFileHandle::remove ( )
overridevirtual

Removes a file.

Returns
true if successful, else false.
Note
Only works if the handle points to a valid file, not a directory.

Implements CeresEngine::IFileHandle.

◆ removeDirectory()

bool CeresEngine::LocalFileHandle::removeDirectory ( )
overridevirtual

Removes a directory.

Returns
true if successful, else false.
Note
If RemoveDirectoryFlag::Recursive is not set, the call will only succeed if the directory exists and is empty.

Implements CeresEngine::IFileHandle.

◆ rename()

bool CeresEngine::LocalFileHandle::rename ( StringView  filename)
overridevirtual

Renames a file or directory.

Parameters
filenameThe new file name to rename the file to.
Returns
true if successful, else false.

Implements CeresEngine::IFileHandle.

◆ updateFileInfo()

void CeresEngine::LocalFileHandle::updateFileInfo ( )
overridevirtual

Update file information.

Must reload and update the file information. It will for example be called after a file has been created, copied, or removed to ensure that the file information returned by the handle is correct.

Implements CeresEngine::IFileHandle.

Reimplemented in CeresEngine::Win32FileHandle, and CeresEngine::POSIXFileHandle.

Member Data Documentation

◆ mFileSystem

RC<LocalFileSystem> CeresEngine::LocalFileHandle::mFileSystem
protected

The file system that created this handle.

◆ mFileSystemPath

std::filesystem::path CeresEngine::LocalFileHandle::mFileSystemPath
protected

Same as mPath, but in the C++17 std::filesystem format.

◆ mPath

FilePath CeresEngine::LocalFileHandle::mPath
protected

Path to file or directory.


The documentation for this class was generated from the following file: