Deki 1.3.0
Modular C++ 2D engine for embedded displays and desktop
Loading...
Searching...
No Matches
DesktopFileSystem Class Reference

Desktop file system implementation using standard C file operations. More...

#include <DesktopFileSystem.h>

Inherits IDekiFileSystem.

Public Member Functions

 DesktopFileSystem ()
virtual ~DesktopFileSystem ()
bool Initialize () override
 Initialize the file system.
void Shutdown () override
 Shutdown the file system and cleanup resources.
FileHandle OpenFile (const char *path, OpenMode mode) override
 Open a file.
void CloseFile (FileHandle handle) override
 Close a file.
size_t ReadFile (FileHandle handle, void *buffer, size_t size) override
 Read data from a file.
size_t WriteFile (FileHandle handle, const void *buffer, size_t size) override
 Write data to a file.
long SeekFile (FileHandle handle, long offset, SeekOrigin origin) override
 Seek to a position in the file.
long TellFile (FileHandle handle) override
 Get current position in file.
long GetFileSize (FileHandle handle) override
 Get file size.
bool FileExists (const char *path) override
 Check if file exists.
bool ConvertPath (const char *virtualPath, char *outBuffer, size_t bufferSize) override
 Convert virtual path to platform-specific path.
Public Member Functions inherited from IDekiFileSystem
virtual ~IDekiFileSystem ()=default
virtual bool SupportsStorageMode () const
 Check if storage mode (USB MSC) is supported.
virtual bool SetStorageMode (bool enabled)
 Enter or exit storage mode (USB Mass Storage).
virtual bool IsStorageMode () const
 Check if currently in storage mode.

Additional Inherited Members

Public Types inherited from IDekiFileSystem
enum class  OpenMode { READ_BINARY , WRITE_BINARY , READ_TEXT , WRITE_TEXT }
 File open modes. More...
enum class  SeekOrigin { BEGIN , CURRENT , END }
 File seek origins. More...
typedef void * FileHandle
 File handle type - platform-specific implementation.

Detailed Description

Desktop file system implementation using standard C file operations.

This implementation maps virtual paths to the local filesystem and uses standard C library functions for file operations. It's suitable for desktop platforms (Windows, Linux, macOS) for both editor and simulator builds.

Constructor & Destructor Documentation

◆ DesktopFileSystem()

DesktopFileSystem::DesktopFileSystem ( )

◆ ~DesktopFileSystem()

virtual DesktopFileSystem::~DesktopFileSystem ( )
virtual

Member Function Documentation

◆ Initialize()

bool DesktopFileSystem::Initialize ( )
overridevirtual

Initialize the file system.

Returns
true if successful, false otherwise

Implements IDekiFileSystem.

◆ Shutdown()

void DesktopFileSystem::Shutdown ( )
overridevirtual

Shutdown the file system and cleanup resources.

Implements IDekiFileSystem.

◆ OpenFile()

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

Open a file.

Parameters
pathPath to the file (platform-specific format)
modeOpen mode
Returns
File handle or nullptr if failed

Implements IDekiFileSystem.

◆ CloseFile()

void DesktopFileSystem::CloseFile ( FileHandle handle)
overridevirtual

Close a file.

Parameters
handleFile handle

Implements IDekiFileSystem.

◆ ReadFile()

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

Read data from a file.

Parameters
handleFile handle
bufferBuffer to read into
sizeNumber of bytes to read
Returns
Number of bytes actually read

Implements IDekiFileSystem.

◆ WriteFile()

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

Write data to a file.

Parameters
handleFile handle
bufferBuffer to write from
sizeNumber of bytes to write
Returns
Number of bytes actually written

Implements IDekiFileSystem.

◆ SeekFile()

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

Seek to a position in the file.

Parameters
handleFile handle
offsetOffset in bytes
originSeek origin
Returns
New position, or -1 on error

Implements IDekiFileSystem.

◆ TellFile()

long DesktopFileSystem::TellFile ( FileHandle handle)
overridevirtual

Get current position in file.

Parameters
handleFile handle
Returns
Current position, or -1 on error

Implements IDekiFileSystem.

◆ GetFileSize()

long DesktopFileSystem::GetFileSize ( FileHandle handle)
overridevirtual

Get file size.

Parameters
handleFile handle
Returns
File size in bytes, or -1 on error

Implements IDekiFileSystem.

◆ FileExists()

bool DesktopFileSystem::FileExists ( const char * path)
overridevirtual

Check if file exists.

Parameters
pathPath to the file
Returns
true if file exists, false otherwise

Implements IDekiFileSystem.

◆ ConvertPath()

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

Convert virtual path to platform-specific path.

Parameters
virtualPathVirtual path (e.g., "S:/assets/texture.bin")
outBufferBuffer to store the converted path
bufferSizeSize of the output buffer
Returns
true if conversion successful, false if buffer too small

Implements IDekiFileSystem.


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