StorageHelperRK
Public Member Functions
StorageHelperRK::FileSystemBase Class Referenceabstract

Abstract base class for file system-based storage. More...

#include <StorageHelperRK.h>

Public Member Functions

 FileSystemBase ()
 Abstract base constructor. Doesn't do anything.
 
virtual ~FileSystemBase ()
 Abstract base destructor. Doesn't do anything.
 
virtual bool open (const char *filename, int mode)=0
 Open the events file. More...
 
virtual bool close ()=0
 Close the events file.
 
virtual bool seek (int seekTo)=0
 Set file position. More...
 
virtual bool truncate (size_t size)=0
 Truncate a file to a specified length in bytes. More...
 
virtual size_t read (uint8_t *buffer, size_t length)=0
 Read bytes from the file. More...
 
virtual size_t write (const uint8_t *buffer, size_t length)=0
 Write bytes to the file. More...
 
virtual int getLength ()=0
 Get length of the file (or a negative error code on error)
 

Detailed Description

Abstract base class for file system-based storage.

Member Function Documentation

◆ open()

virtual bool StorageHelperRK::FileSystemBase::open ( const char *  filename,
int  mode 
)
pure virtual

Open the events file.

Parameters
filenameThe name of the file to open
modeThe open mode, such as O_RDWR | O_CREAT

◆ read()

virtual size_t StorageHelperRK::FileSystemBase::read ( uint8_t *  buffer,
size_t  length 
)
pure virtual

Read bytes from the file.

Parameters
bufferBuffer to fill with data
lengthNumber of bytes to read. Can be > than the number of bytes in the file.
Returns
Number of bytes read. Returns 0 on error.

◆ seek()

virtual bool StorageHelperRK::FileSystemBase::seek ( int  seekTo)
pure virtual

Set file position.

Parameters
seekToThe file offset to seek to if >= 0. Must be <= file length. Or pass -1 to seek to the end of the file to append.
Returns
true on success or false on error

◆ truncate()

virtual bool StorageHelperRK::FileSystemBase::truncate ( size_t  size)
pure virtual

Truncate a file to a specified length in bytes.

Parameters
sizeSize is bytes. Must be <= the current length of the file.

Note: Do not use truncate to make the file larger! While this works for POSIX, it does not work for SPIFFS so we just always assumes it does not work.

◆ write()

virtual size_t StorageHelperRK::FileSystemBase::write ( const uint8_t *  buffer,
size_t  length 
)
pure virtual

Write bytes to the file.

Parameters
bufferBuffer to write to the file
lengthNumber of bytes to write.

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