GREM 3.12.0
Game/Rendering Engine Modules for C++
Loading...
Searching...
No Matches
grem::File Class Referenceabstract

Base interface for a file in a Filesystem. More...

#include <GREM/core/system/File.hpp>

Inheritance diagram for grem::File:

Classes

struct  Error
 Exception type for errors that may arise when attempting to access files through the File API. More...
 Record of metadata for a specific file. More...

Public Types

enum class  Kind : uint8_t { REGULAR , DIRECTORY , SYMLINK , OTHER }
 File entry type. More...

Public Member Functions

 File () noexcept=default
 Default constructor.
virtual ~File ()=default
 Virtual destructor.
 File (const File &)=default
 Copy constructor.
 File (File &&) noexcept=default
 Move constructor.
File & operator= (const File &)=default
 Copy assignment.
File & operator= (File &&) noexcept=default
 Move assignment.
 operator bool () const noexcept
 Check if the file handle has an open file associated with it.
virtual void close ()=0
 Close the associated file so that it can no longer be accessed through this handle, and reset the handle to a closed file handle without an associated file.
virtual bool isOpen () const noexcept=0
 Check if the file handle has an open file associated with it.

Static Public Attributes

static constexpr size_t npos = static_cast<size_t>(-1)
 Invalid value for a file offset, used as an end-of-file marker.

Detailed Description

Base interface for a file in a Filesystem.

Member Enumeration Documentation

◆ Kind

enum class grem::File::Kind : uint8_t
strong

File entry type.

Enumerator
REGULAR 

Regular file.

DIRECTORY 

Directory/folder.

SYMLINK 

Symbolic link.

OTHER 

Something else, such as a network socket or a device.

Constructor & Destructor Documentation

◆ File() [1/3]

grem::File::File ( )
defaultnoexcept

Default constructor.

◆ ~File()

virtual grem::File::~File ( )
virtualdefault

Virtual destructor.

Automatically closes the file, ignoring errors.

◆ File() [2/3]

grem::File::File ( const File & )
default

Copy constructor.

◆ File() [3/3]

grem::File::File ( File && )
defaultnoexcept

Move constructor.

Member Function Documentation

◆ operator=() [1/2]

File & grem::File::operator= ( const File & )
default

Copy assignment.

◆ operator=() [2/2]

File & grem::File::operator= ( File && )
defaultnoexcept

Move assignment.

◆ operator bool()

grem::File::operator bool ( ) const
inlineexplicitnoexcept

Check if the file handle has an open file associated with it.

Returns
true if there is an associated open file, false otherwise.

◆ close()

virtual void grem::File::close ( )
pure virtual

Close the associated file so that it can no longer be accessed through this handle, and reset the handle to a closed file handle without an associated file.

Exceptions
File::Erroron failure to close the file.
std::bad_allocon allocation failure.
Note
This function has no effect if the handle has no open file associated with it.

Implemented in grem::application::VirtualInputFile, grem::application::VirtualOutputFile, grem::NativeInputFile, and grem::NativeOutputFile.

◆ isOpen()

virtual bool grem::File::isOpen ( ) const
nodiscardpure virtualnoexcept

Check if the file handle has an open file associated with it.

Returns
true if there is an associated open file, false otherwise.

Implemented in grem::application::VirtualInputFile, grem::application::VirtualOutputFile, grem::NativeInputFile, and grem::NativeOutputFile.

Member Data Documentation

◆ npos

size_t grem::File::npos = static_cast<size_t>(-1)
staticconstexpr

Invalid value for a file offset, used as an end-of-file marker.


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