SaturnRingLibrary 0.7
SGL wrapper
 
Loading...
Searching...
No Matches
SRL::Cd::File Struct Reference

Detailed Description

Disk file.

#include <srl_cd.hpp>

Public Member Functions

 File ()=delete
 disable default constructor
 
 File (const char *name)
 Open a file on CD.
 
 File (GfsHn handle, int32_t fid, bool getSize=true)
 Construct a new File object from Gfs handle and identifier.
 
 ~File ()
 Close file.
 

Public Attributes

GfsHn Handle
 File handle.
 
FileSize Size
 Size of the file.
 

File handling and status

void Close ()
 Close file.
 
bool Open ()
 Open file.
 
constexpr bool Exists ()
 File exists.
 
constexpr bool IsOpen ()
 File is open.
 

File reading

int32_t LoadBytes (size_t sectorOffset, int32_t size, void *destination)
 Loads specified amount of bytes from a file.
 
int32_t Read (int32_t size, void *destination)
 Read specified number of bytes from the file and advances file access pointer.
 
int32_t Seek (int32_t offset)
 Seek file access pointer to specific byte.
 

Other

int32_t GetCurrentAccessPointer ()
 
constexpr int32_t GetIdentifier ()
 Get file identifier.
 
int32_t GetSectorCount (size_t bytes)
 Get number sectors take by specified byte count for this file.
 

Constructor & Destructor Documentation

◆ File() [1/2]

SRL::Cd::File::File ( GfsHn handle,
int32_t fid,
bool getSize = true )
inline

Construct a new File object from Gfs handle and identifier.

Parameters
handleGfs handle
fidFile identifier
getSizeFetch file size (will cause file to be open for a bit)

◆ File() [2/2]

SRL::Cd::File::File ( const char * name)
inline

Open a file on CD.

Parameters
nameFile name

Member Function Documentation

◆ Exists()

constexpr bool SRL::Cd::File::Exists ( )
inlineconstexpr

File exists.

Returns
True if exists

◆ GetCurrentAccessPointer()

int32_t SRL::Cd::File::GetCurrentAccessPointer ( )
inline
Returns
Current state of file access pointer

◆ GetIdentifier()

constexpr int32_t SRL::Cd::File::GetIdentifier ( )
inlineconstexpr

Get file identifier.

Returns
File identifier

◆ GetSectorCount()

int32_t SRL::Cd::File::GetSectorCount ( size_t bytes)
inline

Get number sectors take by specified byte count for this file.

Parameters
bytesNumber of bytes
Returns
Number of sectors, -1 on error

◆ IsOpen()

constexpr bool SRL::Cd::File::IsOpen ( )
inlineconstexpr

File is open.

Returns
True if file is open

◆ LoadBytes()

int32_t SRL::Cd::File::LoadBytes ( size_t sectorOffset,
int32_t size,
void * destination )
inline

Loads specified amount of bytes from a file.

Note
This function does not need file to be open
Parameters
sectorOffsetNumber of sectors to skip at the start
sizeNumber of bytes to read (length of the batch)
destinationBuffer to read batch into
Returns
Number of bytes read (if lower than 0, error was encountered)

◆ Open()

bool SRL::Cd::File::Open ( )
inline

Open file.

Returns
True on success

◆ Read()

int32_t SRL::Cd::File::Read ( int32_t size,
void * destination )
inline

Read specified number of bytes from the file and advances file access pointer.

Parameters
sizeNumber of bytes to read
destinationBuffer to read bytes into
Returns
Number of bytes read (if lower than 0, error was encountered)

◆ Seek()

int32_t SRL::Cd::File::Seek ( int32_t offset)
inline

Seek file access pointer to specific byte.

Parameters
offsetoffset from start of the file
Returns
New position of the access pointer otherwise negative on error