Arduino DLNA Server
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
tiny_dlna::SdFatDirectoryTree< FS > Class Template Reference

Simple in-memory directory tree built using SdFat recursive directory listing. More...

#include <SdFatDirectoryTree.h>

Public Member Functions

bool begin (FS &SD, const char *beginPath="/")
 Initializes the tree by scanning from a starting path.
 
void end ()
 Releases all dynamically allocated nodes and clears the tree.
 
TreeNoderoot ()
 Returns the root node of the tree.
 
TreeNodegetTreeNodeById (uint32_t id)
 Finds a node by its numeric id.
 
std::vector< TreeNode *, AllocatorPSRAM< TreeNode * > > getAllFiles ()
 Collects all file nodes (non-directories) under the root.
 
stringPSRAM path (uint32_t id)
 Convenience helper to get a path by node id.
 
size_t size ()
 Returns the total number of nodes in the tree.
 

Protected Member Functions

void collectAllFilesFrom (TreeNode &node, std::vector< TreeNode *, AllocatorPSRAM< TreeNode * > > &result)
 
void buildTree (TreeNode &node)
 

Static Protected Member Functions

static void onParsedCallback (SdFatFileInfo &info, void *ref)
 

Protected Attributes

SdFatParser parser
 
FS * p_sd = nullptr
 
std::vector< TreeNode *, AllocatorPSRAM< TreeNode * > > tree_nodes
 
std::vector< TreeNode * > parent_stack
 

Detailed Description

template<typename FS>
class tiny_dlna::SdFatDirectoryTree< FS >

Simple in-memory directory tree built using SdFat recursive directory listing.

The tree is constructed by asking SdFat to list recursively (LS_R). Each line of output is parsed into a node, with indentation (two spaces per level) determining the hierarchy and a trailing '/' indicating directories.

Template Parameters
FSFilesystem type that exposes chdir() and ls(Print*, uint8_t flags) compatible with SdFat's API.

Member Function Documentation

◆ begin()

template<typename FS >
bool tiny_dlna::SdFatDirectoryTree< FS >::begin ( FS &  SD,
const char *  beginPath = "/" 
)
inline

Initializes the tree by scanning from a starting path.

Parameters
SDFilesystem instance (e.g., SdFs).
beginPathRoot path to start scanning from (defaults to "/").
Returns
true on success.

◆ buildTree()

template<typename FS >
void tiny_dlna::SdFatDirectoryTree< FS >::buildTree ( TreeNode node)
inlineprotected

◆ collectAllFilesFrom()

template<typename FS >
void tiny_dlna::SdFatDirectoryTree< FS >::collectAllFilesFrom ( TreeNode node,
std::vector< TreeNode *, AllocatorPSRAM< TreeNode * > > &  result 
)
inlineprotected

◆ end()

template<typename FS >
void tiny_dlna::SdFatDirectoryTree< FS >::end ( )
inline

Releases all dynamically allocated nodes and clears the tree.

◆ getAllFiles()

template<typename FS >
std::vector< TreeNode *, AllocatorPSRAM< TreeNode * > > tiny_dlna::SdFatDirectoryTree< FS >::getAllFiles ( )
inline

Collects all file nodes (non-directories) under the root.

Returns
Vector with pointers to file nodes.

◆ getTreeNodeById()

template<typename FS >
TreeNode & tiny_dlna::SdFatDirectoryTree< FS >::getTreeNodeById ( uint32_t  id)
inline

Finds a node by its numeric id.

Parameters
idThe node id assigned during tree construction.
Returns
Reference to the located TreeNode.

◆ onParsedCallback()

template<typename FS >
static void tiny_dlna::SdFatDirectoryTree< FS >::onParsedCallback ( SdFatFileInfo info,
void *  ref 
)
inlinestaticprotected

◆ path()

template<typename FS >
stringPSRAM tiny_dlna::SdFatDirectoryTree< FS >::path ( uint32_t  id)
inline

Convenience helper to get a path by node id.

◆ root()

template<typename FS >
TreeNode & tiny_dlna::SdFatDirectoryTree< FS >::root ( )
inline

Returns the root node of the tree.

◆ size()

template<typename FS >
size_t tiny_dlna::SdFatDirectoryTree< FS >::size ( )
inline

Returns the total number of nodes in the tree.

Member Data Documentation

◆ p_sd

template<typename FS >
FS* tiny_dlna::SdFatDirectoryTree< FS >::p_sd = nullptr
protected

◆ parent_stack

template<typename FS >
std::vector<TreeNode*> tiny_dlna::SdFatDirectoryTree< FS >::parent_stack
protected

◆ parser

template<typename FS >
SdFatParser tiny_dlna::SdFatDirectoryTree< FS >::parser
protected

◆ tree_nodes

template<typename FS >
std::vector<TreeNode*, AllocatorPSRAM<TreeNode*> > tiny_dlna::SdFatDirectoryTree< FS >::tree_nodes
protected

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