libxr
Embedded C++ framework for bare-metal, RTOS and Linux
Loading...
Searching...
No Matches
Dir Class Reference

RamFS 的目录节点片段 / Directory-node fragment of RamFS More...

#include <dir.hpp>

Inheritance diagram for Dir:
[legend]
Collaboration diagram for Dir:
[legend]

Public Member Functions

void Add (File &file)
 添加直属文件节点 / Add a direct child file node
 
void Add (Dir &dir)
 添加直属目录节点 / Add a direct child directory node
 
void Add (Custom &custom)
 添加直属自定义节点 / Add a direct child custom node
 
FsNode * FindNode (const char *name)
 查找直属子节点 / Find a direct child node
 
File * FindFile (const char *name)
 查找直属文件 / Find a direct child file
 
File * FindFileRev (const char *name)
 递归查找文件 / Find a file recursively
 
Dir * FindDir (const char *name)
 查找直属目录,支持 "." 和 ".." / Find a direct child directory, supporting "." and ".."
 
Dir * FindDirRev (const char *name)
 递归查找目录,支持 "." 和 ".." / Find a directory recursively, supporting "." and ".."
 
Custom * FindCustom (const char *name)
 查找直属自定义节点 / Find a direct child custom node
 
Custom * FindCustomRev (const char *name)
 递归查找自定义节点 / Find a custom node recursively
 
template<typename Func >
ErrorCode Foreach (Func func)
 遍历直属子节点 / Iterate over direct child nodes
 
- Public Member Functions inherited from FsNode
FsNodeType GetNodeType () const
 获取节点类型 / Get the node type
 
const char * GetName () const
 获取节点名称 / Get the node name
 

Friends

class RamFS
 

Additional Inherited Members

- Protected Member Functions inherited from FsNode
 FsNode (FsNodeType node_type)
 用指定节点类型构造基类部分 / Construct the base node with a given node type
 
 FsNode (const FsNode &other)
 拷贝构造节点基类部分 / Copy-construct the base-node portion
 
FsNode & operator= (const FsNode &)=delete
 
- Protected Attributes inherited from FsNode
const char * name_ = nullptr
 节点名称缓冲区 / Retained node-name buffer.
 
FsNodeType type_
 节点运行时类型 / Runtime node type.
 
Dir * parent_
 父目录;根目录保持为空 / Parent directory; stays null for the root.
 
Tree::Node< FsNode * > tree_node_
 

Detailed Description

RamFS 的目录节点片段 / Directory-node fragment of RamFS

目录节点,管理直属子节点 / Directory node that owns a child namespace

Definition at line 8 of file dir.hpp.

Member Function Documentation

◆ Add() [1/3]

void Dir::Add ( Custom & custom)
inline

添加直属自定义节点 / Add a direct child custom node

Parameters
custom自定义节点 / Custom node

Definition at line 27 of file dir.hpp.

27{ AddNode(custom); }

◆ Add() [2/3]

void Dir::Add ( Dir & dir)
inline

添加直属目录节点 / Add a direct child directory node

Parameters
dir目录节点 / Directory node

Definition at line 21 of file dir.hpp.

21{ AddNode(dir); }

◆ Add() [3/3]

void Dir::Add ( File & file)
inline

添加直属文件节点 / Add a direct child file node

Parameters
file文件节点 / File node

Definition at line 15 of file dir.hpp.

15{ AddNode(file); }

◆ FindCustom()

Custom * Dir::FindCustom ( const char * name)

查找直属自定义节点 / Find a direct child custom node

Parameters
name节点名称 / Node name
Returns
自定义节点指针;未找到返回 nullptr / Custom node pointer, or nullptr

◆ FindCustomRev()

Custom * Dir::FindCustomRev ( const char * name)

递归查找自定义节点 / Find a custom node recursively

Parameters
name节点名称 / Node name
Returns
自定义节点指针;未找到返回 nullptr / Custom node pointer, or nullptr

◆ FindDir()

Dir * Dir::FindDir ( const char * name)

查找直属目录,支持 "." 和 ".." / Find a direct child directory, supporting "." and ".."

Parameters
name目录名 / Directory name
Returns
目录指针;未找到返回 nullptr / Directory pointer, or nullptr

◆ FindDirRev()

Dir * Dir::FindDirRev ( const char * name)

递归查找目录,支持 "." 和 ".." / Find a directory recursively, supporting "." and ".."

Parameters
name目录名 / Directory name
Returns
目录指针;未找到返回 nullptr / Directory pointer, or nullptr

◆ FindFile()

File * Dir::FindFile ( const char * name)

查找直属文件 / Find a direct child file

Parameters
name文件名 / File name
Returns
文件指针;未找到返回 nullptr / File pointer, or nullptr

◆ FindFileRev()

File * Dir::FindFileRev ( const char * name)

递归查找文件 / Find a file recursively

Parameters
name文件名 / File name
Returns
文件指针;未找到返回 nullptr / File pointer, or nullptr

◆ FindNode()

FsNode * Dir::FindNode ( const char * name)

查找直属子节点 / Find a direct child node

Parameters
name节点名称 / Node name
Returns
子节点指针;未找到返回 nullptr / Child node pointer, or nullptr

◆ Foreach()

template<typename Func >
ErrorCode Dir::Foreach ( Func func)
inline

遍历直属子节点 / Iterate over direct child nodes

Template Parameters
Func回调类型 / Callback type
Parameters
func回调函数,返回非 OK 时停止遍历 / Callback; non-OK stops iteration
Returns
遍历结果 / Iteration result

Definition at line 87 of file dir.hpp.

88 {
89 return rbt_.Foreach<FsNode*>([&](Tree::Node<FsNode*>& node)
90 { return func(*node.data_); });
91 }
RamFS 的公共节点基类片段 / Common node-base fragment of RamFS
Definition fs_node.hpp:9

Friends And Related Symbol Documentation

◆ RamFS

friend class RamFS
friend

Definition at line 129 of file dir.hpp.


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