libDaisy
Hardware Library for Daisy
Loading...
Searching...
No Matches
daisy::FileTable< max_slots > Class Template Reference

Detailed Description

template<size_t max_slots>
class daisy::FileTable< max_slots >

Utility class for creating an index of file names and lengths from a given directory.

Useful for grouping .wav files for playback, etc.

#include <FileTable.h>

Public Member Functions

void Clear ()
 
bool Fill (const char *path, const char *endswith=nullptr)
 
bool WriteLog (const char *log_file_name)
 
bool IsFileInSlot (size_t idx) const
 
size_t GetFileSize (size_t idx) const
 
const char * GetFileName (size_t idx) const
 
size_t GetNumFiles () const
 
bool IsLoadPending () const
 
void ClearLoadPending ()
 
void SetLoadPending (int slot)
 
bool IsSavePending () const
 
void ClearSavePending ()
 
void SetSavePending (int slot)
 
int GetSlotForSaveLoad () const
 

Static Public Attributes

static constexpr const size_t kMaxCustomFileNameLen = _MAX_LFN
 
static constexpr const size_t kMaxFileSlots = max_slots
 

Member Function Documentation

◆ Clear()

template<size_t max_slots>
void daisy::FileTable< max_slots >::Clear ( )
inline

Reset the table to its initial, empty state.

◆ ClearLoadPending()

template<size_t max_slots>
void daisy::FileTable< max_slots >::ClearLoadPending ( )
inline

◆ ClearSavePending()

template<size_t max_slots>
void daisy::FileTable< max_slots >::ClearSavePending ( )
inline

◆ Fill()

template<size_t max_slots>
bool daisy::FileTable< max_slots >::Fill ( const char * path,
const char * endswith = nullptr )
inline

Search the path provided, and fill the table with files that match the pattern provided. The loaded files are sorted alphabetically by filename

Parameters
pathpath to the directory to search.
endswithstring suffix to compare to, often a file extension (i.e. ".wav") if this is null, then all files will be loaded.
Returns
true if files are loaded, otherwise false

◆ GetFileName()

template<size_t max_slots>
const char * daisy::FileTable< max_slots >::GetFileName ( size_t idx) const
inline

Returns the name of the file in the specified slot.

◆ GetFileSize()

template<size_t max_slots>
size_t daisy::FileTable< max_slots >::GetFileSize ( size_t idx) const
inline

Returns the size of the file in the specified slot.

◆ GetNumFiles()

template<size_t max_slots>
size_t daisy::FileTable< max_slots >::GetNumFiles ( ) const
inline

Returns the number of files found in the table.

◆ GetSlotForSaveLoad()

template<size_t max_slots>
int daisy::FileTable< max_slots >::GetSlotForSaveLoad ( ) const
inline

◆ IsFileInSlot()

template<size_t max_slots>
bool daisy::FileTable< max_slots >::IsFileInSlot ( size_t idx) const
inline

Returns whether there is a file present at the index

◆ IsLoadPending()

template<size_t max_slots>
bool daisy::FileTable< max_slots >::IsLoadPending ( ) const
inline

Flag-y bits for Loading and Saving This class can act like an interface for the actual I/O.

This has to be manually managed, but can be used to coordinate loading/storing data.

◆ IsSavePending()

template<size_t max_slots>
bool daisy::FileTable< max_slots >::IsSavePending ( ) const
inline

◆ SetLoadPending()

template<size_t max_slots>
void daisy::FileTable< max_slots >::SetLoadPending ( int slot)
inline

◆ SetSavePending()

template<size_t max_slots>
void daisy::FileTable< max_slots >::SetSavePending ( int slot)
inline

◆ WriteLog()

template<size_t max_slots>
bool daisy::FileTable< max_slots >::WriteLog ( const char * log_file_name)
inline

Generates a simple log file, and writes it to the destination

The file will contain a list of all of the files loaded, with their slot position, and file size.

Member Data Documentation

◆ kMaxCustomFileNameLen

template<size_t max_slots>
const size_t daisy::FileTable< max_slots >::kMaxCustomFileNameLen = _MAX_LFN
staticconstexpr

◆ kMaxFileSlots

template<size_t max_slots>
const size_t daisy::FileTable< max_slots >::kMaxFileSlots = max_slots
staticconstexpr

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