DEKI/ENGINE docs
manual api reference
Deki 0.40.1
Modular C++ engine with a visual editor, for 2D and 3D
Loading...
Searching...
No Matches
Deki::HostFileSystem Class Reference

The file system of a game that runs as a program on an operating system. More...

#include <deki/providers/HostFileSystem.h>

Inherits Deki::IFileSystem.

Public Member Functions

 HostFileSystem ()
virtual ~HostFileSystem ()
void CloseFile (FileHandle handle) override
bool ConvertPath (const char *virtualPath, char *outBuffer, size_t bufferSize) override
 Turns a virtual path (such as "S:/assets/texture.bin") into this platform's path.
bool FileExists (const char *path) override
long GetFileSize (FileHandle handle) override
 Size in bytes, or -1 on error.
bool Initialize () override
 Returns false on failure.
FileHandle OpenFile (const char *path, OpenMode mode) override
 Opens path (in this filesystem's format). Returns nullptr on failure.
size_t ReadFile (FileHandle handle, void *buffer, size_t size) override
 Reads up to size bytes. Returns the number read.
long SeekFile (FileHandle handle, long offset, SeekOrigin origin) override
 Returns the new position, or -1 on error.
void Shutdown () override
long TellFile (FileHandle handle) override
 Current position, or -1 on error.
size_t WriteFile (FileHandle handle, const void *buffer, size_t size) override
 Writes size bytes. Returns the number written.
Public Member Functions inherited from Deki::IFileSystem
virtual ~IFileSystem ()=default
virtual bool IsStorageMode () const
 True while USB mass storage is active.
virtual bool SetStorageMode (bool enabled)
 Enters or leaves USB mass storage mode, used to deploy assets.
virtual bool SupportsStorageMode () const
 True when the storage can be exposed as a USB drive (mass storage).

Additional Inherited Members

Public Types inherited from Deki::IFileSystem
using FileHandle = void*
 Opaque; each implementation decides what it points to.
enum class  OpenMode { ReadBinary , WriteBinary , ReadText , WriteText }
enum class  SeekOrigin { Begin , Current , End }

Detailed Description

The file system of a game that runs as a program on an operating system.

For the desktop build and Linux handhelds, on the C standard library. Maps the device's virtual mounts to folders beside the program, on Windows, Linux and macOS alike. The hosted entry (src/hosted/HostedMain.cpp) sets it before the engine starts.

F:/ is the board's flash, as on a device: the game's data (the build's export, in ./flash/) is read and never written, and the files the game writes go to ./userdata/, read from there when the game's data has no file of that name.

Constructor & Destructor Documentation

◆ HostFileSystem()

Deki::HostFileSystem::HostFileSystem ( )

◆ ~HostFileSystem()

virtual Deki::HostFileSystem::~HostFileSystem ( )
virtual

Member Function Documentation

◆ CloseFile()

void Deki::HostFileSystem::CloseFile ( FileHandle handle)
overridevirtual

Implements Deki::IFileSystem.

◆ ConvertPath()

bool Deki::HostFileSystem::ConvertPath ( const char * virtualPath,
char * outBuffer,
size_t bufferSize )
overridevirtual

Turns a virtual path (such as "S:/assets/texture.bin") into this platform's path.

Returns false when outBuffer is too small.

Implements Deki::IFileSystem.

◆ FileExists()

bool Deki::HostFileSystem::FileExists ( const char * path)
overridevirtual

Implements Deki::IFileSystem.

◆ GetFileSize()

long Deki::HostFileSystem::GetFileSize ( FileHandle handle)
overridevirtual

Size in bytes, or -1 on error.

Implements Deki::IFileSystem.

◆ Initialize()

bool Deki::HostFileSystem::Initialize ( )
overridevirtual

Returns false on failure.

Implements Deki::IFileSystem.

◆ OpenFile()

FileHandle Deki::HostFileSystem::OpenFile ( const char * path,
OpenMode mode )
overridevirtual

Opens path (in this filesystem's format). Returns nullptr on failure.

Implements Deki::IFileSystem.

◆ ReadFile()

size_t Deki::HostFileSystem::ReadFile ( FileHandle handle,
void * buffer,
size_t size )
overridevirtual

Reads up to size bytes. Returns the number read.

Implements Deki::IFileSystem.

◆ SeekFile()

long Deki::HostFileSystem::SeekFile ( FileHandle handle,
long offset,
SeekOrigin origin )
overridevirtual

Returns the new position, or -1 on error.

Implements Deki::IFileSystem.

◆ Shutdown()

void Deki::HostFileSystem::Shutdown ( )
overridevirtual

Implements Deki::IFileSystem.

◆ TellFile()

long Deki::HostFileSystem::TellFile ( FileHandle handle)
overridevirtual

Current position, or -1 on error.

Implements Deki::IFileSystem.

◆ WriteFile()

size_t Deki::HostFileSystem::WriteFile ( FileHandle handle,
const void * buffer,
size_t size )
overridevirtual

Writes size bytes. Returns the number written.

Implements Deki::IFileSystem.


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