CyberEngineMkIII
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Types | Public Member Functions | List of all members
CYB::API::File Class Referenceabstract

Contains the basic File interface. Does not perform locking of any kind, be aware of possible race conditions. Note that reads and writes that fail should not be retried. More...

#include <File.hpp>

Inheritance diagram for CYB::API::File:
Inheritance graph
[legend]
Collaboration diagram for CYB::API::File:
Collaboration graph
[legend]

Public Types

enum  Method : byte { Method::ANY, Method::EXIST, Method::CREATE, Method::TRUNCATE }
 The method of handling Files that already exist. More...
 
using Constructor = Interop::Constructor< const Path &, const Mode, const Method >
 See Interop Construction. Opens a file for access. More...
 
- Public Types inherited from CYB::API::Interop::Allocatable
enum  ID {
  ID::NULL_ID, ID::File, ID::Mutex, ID::Path,
  ID::Semaphore
}
 Defines the IDs of allocatable engine objects. More...
 
using Constructor = NullConstructor
 Override in descendants.
 
using CopyConstructor = NullConstructor
 Override in descendants.
 
- Public Types inherited from CYB::API::Stream
enum  Mode : byte { Mode::READ = 1, Mode::WRITE, Mode::READ_WRITE }
 The available operations for the Stream. Bitset. More...
 
enum  SeekLocation { SeekLocation::BEGIN, SeekLocation::CURSOR, SeekLocation::END }
 The location to begin a seek operation at. More...
 

Public Member Functions

virtual unsigned long long Size (void) const =0
 Get the current size of the File. More...
 
virtual unsigned long long CursorPosition (void) const noexcept=0
 Get the current position of the read/write cursor in the Stream. Equivalent of Seek(0, SeekLocation::CURSOR) More...
 
virtual const PathGetPath (void) const noexcept=0
 Get the Path indicating the current File. More...
 
virtual Method OpenMethod (void) const noexcept=0
 Gets the opening method of the File. Will never be Method::ANY. More...
 
- Public Member Functions inherited from CYB::API::Interop::Allocatable
virtual ~Allocatable ()=default
 See Default Constructors and Destructor.
 
- Public Member Functions inherited from CYB::API::Stream
virtual void Capabilities (Mode &AMode, bool &ASeek) const noexcept=0
 Get the capabilities of the stream. More...
 
virtual unsigned long long Seek (const long long AOffset, const SeekLocation ALocation) const =0
 Set the cursor position in the Stream. More...
 
virtual unsigned long long Read (void *const ABuffer, const unsigned long long AMaxAmount) const =0
 Read data from a Stream at the current cursor position and advance the cursor by that amount. More...
 
virtual unsigned long long Write (const void *const ABuffer, const unsigned long long AAmount)=0
 Write data to the Stream at the current cursor position and advance the cursor by that amount. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from CYB::API::Interop::Allocatable
template<class AParent >
static constexpr ID GetID (void)
 Returns the ID of an allocatable object. More...
 

Detailed Description

Contains the basic File interface. Does not perform locking of any kind, be aware of possible race conditions. Note that reads and writes that fail should not be retried.

Definition at line 5 of file File.hpp.

Member Typedef Documentation

See Interop Construction. Opens a file for access.

Path
An xvalue of the Path of the File to open
Mode
The Mode of opening the file, subsequent operations must respect this
Method
The Method of handling preexisting files
Thread Safety
This function requires no thread safety
Throws
CYB::Exception::SystemData Error code: CYB::Exception::SystemData::STREAM_NOT_READABLE. Thrown if AMode equals Mode::READ and the file could not be opened
CYB::Exception::SystemData Error code: CYB::Exception::SystemData::STREAM_NOT_WRITABLE. Thrown if AMode equals Mode::WRITE or Mode::READ_WRITE and the file could not be opened
CYB::Exception::SystemData Error code: CYB::Exception::SystemData::FILE_NOT_FOUND. Thrown if AMethod equals Method::EXIST and the file portion of APath does not exist or if it is not valid in other cases.
CYB::Exception::SystemData Error code: CYB::Exception::SystemData::FILE_EXISTS. Thrown if AMethod equals Method::CREATE and the file portion of APath already exists or is a directory
CYB::Exception::SystemData Error code: CYB::Exception::SystemData::HEAP_ALLOCATION_FAILURE. Thrown if the current heap runs out of memory
CYB::Exception::Violation Error code: CYB::Exception::Violation::INVALID_ENUM. Thrown if AMode, or AMethod is invalid
CYB::Exception::Violation Error code: CYB::Exception::Violation::INVALID_PARAMETERS. Thrown if AMode is Mode::READ and AMethod is Method::TRUNCATE. Operating systems require write permissions to truncate a file

Definition at line 34 of file File.hpp.

Member Enumeration Documentation

The method of handling Files that already exist.

Enumerator
ANY 

The File may or may not exist. It will be created if it doesn't. OpenMethod will be set to EXIST or CREATE once constructed to indicate result.

EXIST 

The File must exist.

CREATE 

The File must not exist. It will be created.

TRUNCATE 

Any existing File will be overwritten and an empty file will be created.

Definition at line 8 of file File.hpp.

8  : byte {
9  ANY,
10  EXIST,
11  CREATE,
12  TRUNCATE,
13  };
unsigned char byte
It's a byte, 8 bits, etc...
Definition: Types.hpp:4

Member Function Documentation

virtual unsigned long long CYB::API::File::CursorPosition ( void  ) const
pure virtualnoexcept

Get the current position of the read/write cursor in the Stream. Equivalent of Seek(0, SeekLocation::CURSOR)

Returns
The current position of the cursor in the Stream
Thread Safety
This function requires synchronization at the object level

Implements CYB::API::Stream.

Implemented in CYB::Platform::System::File.

virtual const Path& CYB::API::File::GetPath ( void  ) const
pure virtualnoexcept

Get the Path indicating the current File.

Returns
A reference to the Path indicating the current File
Thread Safety
This function requres no thread safety

Implemented in CYB::Platform::System::File.

virtual Method CYB::API::File::OpenMethod ( void  ) const
pure virtualnoexcept

Gets the opening method of the File. Will never be Method::ANY.

Returns
The opening method of the File. If it was orginally Method::ANY it will be changed to Method::EXIST or Method::CREATE
Thread Safety
This function requres no thread safety

Implemented in CYB::Platform::System::File.

virtual unsigned long long CYB::API::File::Size ( void  ) const
pure virtual

Get the current size of the File.

Returns
The current size of the File
Thread Safety
This function requires no thread safety
Exceptions
CYB::Exception::SystemDataError code: CYB::Exception::SystemData::STREAM_NOT_READABLE. Thrown if the size could not be retrieved

Implemented in CYB::Platform::System::File.


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