ESP32 PSRAM Library
Public Member Functions | Protected Attributes | List of all members
esp32_psram::InMemoryFS< VectorType, FileType > Class Template Referenceabstract

Base class for memory-based file systems like PSRAM and HIMEM. More...

#include <InMemoryFS.h>

Public Member Functions

virtual bool begin ()=0
 Initialize the file system. More...
 
bool exists (const char *filename)
 Check if a file exists. More...
 
size_t fileCount () const
 Get the total number of files. More...
 
virtual uint64_t freeBytes ()=0
 Get free space. More...
 
String getFirstFileName ()
 Get the first file in the filesystem. More...
 
String getNextFileName (const char *currentFileName)
 Get the name of the next file after the specified file. More...
 
bool mkdir (const char *dirname)
 Create a directory (no-op for compatibility) More...
 
FileType open (const char *filename, uint8_t mode)
 Open a file. More...
 
bool remove (const char *filename)
 Remove a file. More...
 
bool rmdir (const char *dirname)
 Remove a directory (no-op for compatibility) More...
 
virtual uint64_t totalBytes ()=0
 Get total space. More...
 

Protected Attributes

std::map< std::string, VectorType > fileData
 
bool initialized = false
 

Detailed Description

template<typename VectorType, typename FileType>
class esp32_psram::InMemoryFS< VectorType, FileType >

Base class for memory-based file systems like PSRAM and HIMEM.

This class provides a common interface for in-memory file systems, with methods for file management and traversal.

Template Parameters
VectorTypeThe vector implementation to use (VectorPSRAM or VectorHIMEM)
FileTypeThe file implementation to return (FilePSRAM or FileHIMEM)

Member Function Documentation

◆ begin()

template<typename VectorType , typename FileType >
virtual bool esp32_psram::InMemoryFS< VectorType, FileType >::begin ( )
pure virtual

Initialize the file system.

Returns
true if initialization was successful, false otherwise

Implemented in esp32_psram::PSRAMClass, and esp32_psram::HIMEMClass.

◆ exists()

template<typename VectorType , typename FileType >
bool esp32_psram::InMemoryFS< VectorType, FileType >::exists ( const char *  filename)
inline

Check if a file exists.

Parameters
filenameName of the file to check
Returns
true if the file exists, false otherwise

◆ fileCount()

template<typename VectorType , typename FileType >
size_t esp32_psram::InMemoryFS< VectorType, FileType >::fileCount ( ) const
inline

Get the total number of files.

Returns
Number of files in the filesystem

◆ freeBytes()

template<typename VectorType , typename FileType >
virtual uint64_t esp32_psram::InMemoryFS< VectorType, FileType >::freeBytes ( )
pure virtual

Get free space.

Returns
Free memory size in bytes

Implemented in esp32_psram::PSRAMClass, and esp32_psram::HIMEMClass.

◆ getFirstFileName()

template<typename VectorType , typename FileType >
String esp32_psram::InMemoryFS< VectorType, FileType >::getFirstFileName ( )
inline

Get the first file in the filesystem.

Returns
Name of the first file, or empty string if there are no files

◆ getNextFileName()

template<typename VectorType , typename FileType >
String esp32_psram::InMemoryFS< VectorType, FileType >::getNextFileName ( const char *  currentFileName)
inline

Get the name of the next file after the specified file.

Parameters
currentFileNameName of the current file
Returns
Name of the next file, or empty string if there are no more files

◆ mkdir()

template<typename VectorType , typename FileType >
bool esp32_psram::InMemoryFS< VectorType, FileType >::mkdir ( const char *  dirname)
inline

Create a directory (no-op for compatibility)

Parameters
dirnameName of the directory
Returns
Always returns true for compatibility

◆ open()

template<typename VectorType , typename FileType >
FileType esp32_psram::InMemoryFS< VectorType, FileType >::open ( const char *  filename,
uint8_t  mode 
)
inline

Open a file.

Parameters
filenameName of the file to open
modeMode to open the file in (FILE_READ, FILE_WRITE, etc.)
Returns
A file object for the opened file

◆ remove()

template<typename VectorType , typename FileType >
bool esp32_psram::InMemoryFS< VectorType, FileType >::remove ( const char *  filename)
inline

Remove a file.

Parameters
filenameName of the file to remove
Returns
true if the file was removed, false otherwise

◆ rmdir()

template<typename VectorType , typename FileType >
bool esp32_psram::InMemoryFS< VectorType, FileType >::rmdir ( const char *  dirname)
inline

Remove a directory (no-op for compatibility)

Parameters
dirnameName of the directory
Returns
Always returns true for compatibility

◆ totalBytes()

template<typename VectorType , typename FileType >
virtual uint64_t esp32_psram::InMemoryFS< VectorType, FileType >::totalBytes ( )
pure virtual

Get total space.

Returns
Total memory size in bytes

Implemented in esp32_psram::PSRAMClass, and esp32_psram::HIMEMClass.


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