libxr  1.0
Want to be the best embedded framework
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
 
FsNodeFindNode (const char *name)
 查找直属子节点 / Find a direct child node
 
FileFindFile (const char *name)
 查找直属文件 / Find a direct child file
 
FileFindFileRev (const char *name)
 递归查找文件 / Find a file recursively
 
DirFindDir (const char *name)
 查找直属目录,支持 "." 和 ".." / Find a direct child directory, supporting "." and ".."
 
DirFindDirRev (const char *name)
 递归查找目录,支持 "." 和 ".." / Find a directory recursively, supporting "." and ".."
 
CustomFindCustom (const char *name)
 查找直属自定义节点 / Find a direct child custom node
 
CustomFindCustomRev (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
 

Private Member Functions

 Dir ()
 构造一个空目录壳 / Construct one empty directory shell
 
 Dir (const char *name)
 构造一个具名目录壳 / Construct one named directory shell
 
void AddNode (FsNode &node)
 把一个节点挂到当前目录下 / Attach one node under the current directory
 
FsNodeFindNodeByType (const char *name, FsNodeType type)
 在当前目录按类型查找直属节点 / Find one direct child node of a given type
 
FsNodeFindNodeRevByType (const char *name, FsNodeType type)
 递归查找指定类型节点 / Find one node of a given type recursively
 

Private Attributes

Tree rbt_
 当前目录直属子节点的名称索引树 / Name index tree of direct child nodes.
 

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
 
FsNodeoperator= (const FsNode &)=delete
 
- Protected Attributes inherited from FsNode
const char * name_ = nullptr
 节点名称缓冲区 / Retained node-name buffer.
 
FsNodeType type_
 节点运行时类型 / Runtime node type.
 
Dirparent_ = nullptr
 父目录;根目录保持为空 / Parent directory; stays null for the root.
 
Tree::Node< FsNode * > tree_node_
 当前节点挂进目录树时使用的树节点包装 / Tree node wrapper used when inserted into a directory tree.
 

Detailed Description

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

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

Definition at line 8 of file dir.hpp.

Constructor & Destructor Documentation

◆ Dir()

Dir::Dir ( const char * name)
explicitprivate

构造一个具名目录壳 / Construct one named directory shell

Parameters
name目录名称 / Directory name

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); }
void AddNode(FsNode &node)
把一个节点挂到当前目录下 / Attach one node under the current directory

◆ 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); }

◆ AddNode()

void Dir::AddNode ( FsNode & node)
private

把一个节点挂到当前目录下 / Attach one node under the current directory

Parameters
node待挂接节点 / Node to attach

◆ 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

◆ FindNodeByType()

FsNode * Dir::FindNodeByType ( const char * name,
FsNodeType type )
private

在当前目录按类型查找直属节点 / Find one direct child node of a given type

Parameters
name节点名称 / Node name
type目标节点类型 / Desired node type
Returns
找到的节点;未找到返回 nullptr / Matching node, or nullptr

◆ FindNodeRevByType()

FsNode * Dir::FindNodeRevByType ( const char * name,
FsNodeType type )
private

递归查找指定类型节点 / Find one node of a given type recursively

Parameters
name节点名称 / Node name
type目标节点类型 / Desired node type
Returns
找到的节点;未找到返回 nullptr / Matching node, 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 }
Tree rbt_
当前目录直属子节点的名称索引树 / Name index tree of direct child nodes.
Definition dir.hpp:127
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.

Field Documentation

◆ rbt_

Tree Dir::rbt_
private

当前目录直属子节点的名称索引树 / Name index tree of direct child nodes.

Definition at line 127 of file dir.hpp.


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