Logo Pico-Framework A web-first embedded framework for C++
Loading...
Searching...
No Matches
StorageManager Class Referenceabstract

Abstract base class for storage access and file operations. More...

#include <StorageManager.h>

+ Inheritance diagram for StorageManager:
+ Collaboration diagram for StorageManager:

Public Member Functions

virtual ~StorageManager ()=default
 
virtual bool mount ()=0
 Mount the underlying storage.
 
virtual bool unmount ()=0
 Unmount the storage.
 
virtual bool isMounted () const =0
 Check mounted.
 
virtual bool exists (const std::string &path)=0
 Check whether a file or directory exists at the given path.
 
virtual bool remove (const std::string &path)=0
 Remove a file or directory.
 
virtual bool rename (const std::string &from, const std::string &to)=0
 Rename a file or directory.
 
virtual bool readFile (const std::string &path, std::vector< uint8_t > &buffer)=0
 Read a file into a memory buffer.
 
virtual bool readFileString (const std::string &path, uint32_t startPosition, uint32_t length, std::string &buffer)=0
 Read a file string into a memory buffer.
 
virtual bool writeFile (const std::string &path, const std::vector< uint8_t > &data)=0
 Write a memory buffer to a file.
 
virtual bool writeFile (const std::string &path, const unsigned char *data, size_t size)=0
 Write from a raw buffer.
 
virtual bool streamFile (const std::string &path, std::function< void(const uint8_t *, size_t)> chunkCallback)=0
 Stream a file in chunks via callback.
 
virtual bool listDirectory (const std::string &path, std::vector< FileInfo > &out)=0
 List all entries in the given directory.
 
virtual bool createDirectory (const std::string &path)=0
 Create a directory at the given path (recursive if needed).
 
virtual bool removeDirectory (const std::string &path)=0
 Remove a directory (must be empty, or recursively if supported).
 
virtual size_t getFileSize (const std::string &path)=0
 Get the size of a file.
 
virtual bool appendToFile (const std::string &path, const uint8_t *data, size_t size)=0
 Append data to a file.
 
virtual bool formatStorage ()=0
 Format the storage (if applicable).
 
virtual std::unique_ptr< StorageFileReaderopenReader (const std::string &path)=0
 Open a file for streaming read access.
 

Detailed Description

Definition at line 47 of file StorageManager.h.

Constructor & Destructor Documentation

◆ ~StorageManager()

virtual StorageManager::~StorageManager ( )
virtualdefault

Member Function Documentation

◆ appendToFile()

virtual bool StorageManager::appendToFile ( const std::string &  path,
const uint8_t *  data,
size_t  size 
)
pure virtual

Implemented in FatFsStorageManager, and LittleFsStorageManager.

Referenced by traceLog().

+ Here is the caller graph for this function:

◆ createDirectory()

virtual bool StorageManager::createDirectory ( const std::string &  path)
pure virtual

◆ exists()

virtual bool StorageManager::exists ( const std::string &  path)
pure virtual

Implemented in FatFsStorageManager, and LittleFsStorageManager.

Referenced by MultipartParser::file_exists(), and FileHandler::serveFile().

+ Here is the caller graph for this function:

◆ formatStorage()

virtual bool StorageManager::formatStorage ( )
pure virtual

◆ getFileSize()

virtual size_t StorageManager::getFileSize ( const std::string &  path)
pure virtual

Implemented in FatFsStorageManager, and LittleFsStorageManager.

Referenced by FileHandler::serveFile().

+ Here is the caller graph for this function:

◆ isMounted()

virtual bool StorageManager::isMounted ( ) const
pure virtual

Implemented in FatFsStorageManager, and LittleFsStorageManager.

Referenced by JsonService::load(), JsonService::save(), and FileHandler::serveFile().

+ Here is the caller graph for this function:

◆ listDirectory()

virtual bool StorageManager::listDirectory ( const std::string &  path,
std::vector< FileInfo > &  out 
)
pure virtual

◆ mount()

virtual bool StorageManager::mount ( )
pure virtual

Implemented in FatFsStorageManager, and LittleFsStorageManager.

Referenced by FileHandler::init(), JsonService::load(), JsonService::save(), and FileHandler::serveFile().

+ Here is the caller graph for this function:

◆ openReader()

virtual std::unique_ptr< StorageFileReader > StorageManager::openReader ( const std::string &  path)
pure virtual
Parameters
pathThe file path
Returns
A new reader object, or nullptr on failure

Implemented in FatFsStorageManager, and LittleFsStorageManager.

◆ readFile()

virtual bool StorageManager::readFile ( const std::string &  path,
std::vector< uint8_t > &  buffer 
)
pure virtual

Implemented in FatFsStorageManager, and LittleFsStorageManager.

Referenced by JsonService::load().

+ Here is the caller graph for this function:

◆ readFileString()

virtual bool StorageManager::readFileString ( const std::string &  path,
uint32_t  startPosition,
uint32_t  length,
std::string &  buffer 
)
pure virtual

Implemented in FatFsStorageManager, and LittleFsStorageManager.

Referenced by FileHandler::serveFile().

+ Here is the caller graph for this function:

◆ remove()

virtual bool StorageManager::remove ( const std::string &  path)
pure virtual

◆ removeDirectory()

virtual bool StorageManager::removeDirectory ( const std::string &  path)
pure virtual

◆ rename()

virtual bool StorageManager::rename ( const std::string &  from,
const std::string &  to 
)
pure virtual

◆ streamFile()

virtual bool StorageManager::streamFile ( const std::string &  path,
std::function< void(const uint8_t *, size_t)>  chunkCallback 
)
pure virtual

Implemented in FatFsStorageManager, and LittleFsStorageManager.

Referenced by FileHandler::serveFile().

+ Here is the caller graph for this function:

◆ unmount()

virtual bool StorageManager::unmount ( )
pure virtual

◆ writeFile() [1/2]

virtual bool StorageManager::writeFile ( const std::string &  path,
const std::vector< uint8_t > &  data 
)
pure virtual

Implemented in FatFsStorageManager, and LittleFsStorageManager.

Referenced by JsonService::save(), and HttpResponse::toFile().

+ Here is the caller graph for this function:

◆ writeFile() [2/2]

virtual bool StorageManager::writeFile ( const std::string &  path,
const unsigned char *  data,
size_t  size 
)
pure virtual

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