libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
dir.hpp
1
8 class Dir : public FsNode
9 {
10 public:
15 void Add(File& file) { AddNode(file); }
16
21 void Add(Dir& dir) { AddNode(dir); }
22
27 void Add(Custom& custom) { AddNode(custom); }
28
34 FsNode* FindNode(const char* name);
35
41 File* FindFile(const char* name);
42
48 File* FindFileRev(const char* name);
49
56 Dir* FindDir(const char* name);
57
64 Dir* FindDirRev(const char* name);
65
71 Custom* FindCustom(const char* name);
72
78 Custom* FindCustomRev(const char* name);
79
86 template <typename Func>
87 ErrorCode Foreach(Func func)
88 {
89 return rbt_.Foreach<FsNode*>([&](Tree::Node<FsNode*>& node)
90 { return func(*node.data_); });
91 }
92
93 private:
97 Dir();
98
103 explicit Dir(const char* name);
104
109 void AddNode(FsNode& node);
110
117 FsNode* FindNodeByType(const char* name, FsNodeType type);
118
125 FsNode* FindNodeRevByType(const char* name, FsNodeType type);
126
127 Tree rbt_;
128
129 friend class RamFS;
130 };
RamFS 的自定义节点片段 / Custom-node fragment of RamFS
Definition custom.hpp:10
RamFS 的目录节点片段 / Directory-node fragment of RamFS
Definition dir.hpp:9
Dir * FindDirRev(const char *name)
递归查找目录,支持 "." 和 ".." / Find a directory recursively, supporting "." and ".."
Dir()
构造一个空目录壳 / Construct one empty directory shell
File * FindFileRev(const char *name)
递归查找文件 / Find a file recursively
Dir * FindDir(const char *name)
查找直属目录,支持 "." 和 ".." / Find a direct child directory, supporting "." and ".."
FsNode * FindNodeByType(const char *name, FsNodeType type)
在当前目录按类型查找直属节点 / Find one direct child node of a given type
void AddNode(FsNode &node)
把一个节点挂到当前目录下 / Attach one node under the current directory
void Add(Dir &dir)
添加直属目录节点 / Add a direct child directory node
Definition dir.hpp:21
FsNode * FindNodeRevByType(const char *name, FsNodeType type)
递归查找指定类型节点 / Find one node of a given type recursively
File * FindFile(const char *name)
查找直属文件 / Find a direct child file
FsNode * FindNode(const char *name)
查找直属子节点 / Find a direct child node
ErrorCode Foreach(Func func)
遍历直属子节点 / Iterate over direct child nodes
Definition dir.hpp:87
Tree rbt_
当前目录直属子节点的名称索引树 / Name index tree of direct child nodes.
Definition dir.hpp:127
void Add(Custom &custom)
添加直属自定义节点 / Add a direct child custom node
Definition dir.hpp:27
void Add(File &file)
添加直属文件节点 / Add a direct child file node
Definition dir.hpp:15
Dir(const char *name)
构造一个具名目录壳 / Construct one named directory shell
Custom * FindCustom(const char *name)
查找直属自定义节点 / Find a direct child custom node
Custom * FindCustomRev(const char *name)
递归查找自定义节点 / Find a custom node recursively
RamFS 的文件节点片段 / File-node fragment of RamFS
Definition file.hpp:9
RamFS 的公共节点基类片段 / Common node-base fragment of RamFS
Definition fs_node.hpp:9