目录类,继承自 RBTree 节点,用于管理文件、子目录和设备 Directory class, inheriting from RBTree node, used for managing files, subdirectories, and devices
More...
#include <ramfs.hpp>
|
void | Add (File &file) |
| 添加文件到当前目录 Adds a file to the current directory
|
|
void | Add (Dir &dir) |
| 添加子目录到当前目录 Adds a subdirectory to the current directory
|
|
void | Add (Device &dev) |
| 添加设备到当前目录 Adds a device to the current directory
|
|
File * | FindFile (const char *name) |
| 查找当前目录中的文件 Finds a file in the current directory
|
|
File * | FindFileRev (const char *name) |
| 递归查找文件 Recursively searches for a file
|
|
Dir * | FindDir (const char *name) |
| 查找当前目录中的子目录 Finds a subdirectory in the current directory
|
|
Dir * | FindDirRev (const char *name) |
| 递归查找子目录 Recursively searches for a subdirectory
|
|
Device * | FindDeviceRev (const char *name) |
| 递归查找设备 Recursively searches for a device
|
|
Device * | FindDevice (const char *name) |
| 在当前目录中查找设备 Finds a device in the current directory
|
|
| Node () |
| 默认构造函数,初始化数据为空 (Default constructor initializing an empty node).
|
|
| Node (const DirNode &data) |
| 使用指定数据构造节点 (Constructor initializing a node with the given data).
|
|
| Node (Args... args) |
| 通过参数列表构造节点 (Constructor initializing a node using arguments list).
|
|
| operator DirNode & () |
|
Node & | operator= (const DirNode &data) |
|
DirNode * | operator-> () |
|
const DirNode * | operator-> () const |
|
DirNode & | operator* () |
|
目录类,继承自 RBTree 节点,用于管理文件、子目录和设备 Directory class, inheriting from RBTree node, used for managing files, subdirectories, and devices
Definition at line 228 of file ramfs.hpp.
◆ Add() [1/3]
void LibXR::RamFS::Dir::Add |
( |
Device & | dev | ) |
|
|
inline |
添加设备到当前目录 Adds a device to the current directory
- Parameters
-
dev | 要添加的设备 The device to be added |
Definition at line 256 of file ramfs.hpp.
257 {
258 (*this)->rbt.Insert(dev, dev->name);
259 dev->parent = this;
260 }
◆ Add() [2/3]
void LibXR::RamFS::Dir::Add |
( |
Dir & | dir | ) |
|
|
inline |
添加子目录到当前目录 Adds a subdirectory to the current directory
- Parameters
-
dir | 要添加的子目录 The subdirectory to be added |
Definition at line 246 of file ramfs.hpp.
247 {
248 (*this)->rbt.Insert(dir, dir->name);
249 dir->parent = this;
250 }
◆ Add() [3/3]
void LibXR::RamFS::Dir::Add |
( |
File & | file | ) |
|
|
inline |
添加文件到当前目录 Adds a file to the current directory
- Parameters
-
file | 要添加的文件 The file to be added |
Definition at line 236 of file ramfs.hpp.
237 {
238 (*this)->rbt.Insert(file, file->name);
239 file->parent = this;
240 }
◆ FindDevice()
在当前目录中查找设备 Finds a device in the current directory
- Parameters
-
name | 设备名 The name of the device |
- Returns
- Device* 指向设备的指针,如果未找到则返回 nullptr Pointer to the device, returns nullptr if not found
Definition at line 185 of file ramfs.cpp.
186{
187 auto ans = (*this)->rbt.Search<FsNode>(name);
189 {
190 return reinterpret_cast<Device *>(ans);
191 }
192 else
193 {
194 return nullptr;
195 }
196}
◆ FindDeviceRev()
递归查找设备 Recursively searches for a device
- Parameters
-
name | 设备名 The name of the device |
- Returns
- Device* 指向设备的指针,如果未找到则返回 nullptr Pointer to the device, returns nullptr if not found
Definition at line 141 of file ramfs.cpp.
142{
144 if (ans)
145 {
146 return ans;
147 }
148
149 struct FindDevRevFn
150 {
151 const char *name;
154 {
156 if (node.type == FsNodeType::DIR)
157 {
158 auto *dir =
reinterpret_cast<RamFS::Dir *
>(&item);
159
161 if (d)
162 {
163 ans = d;
164 return ErrorCode::FAILED;
165 }
166
168 return ans ? ErrorCode::FAILED : ErrorCode::OK;
169 }
170 return ErrorCode::OK;
171 }
172 };
173
174 data_.rbt.Foreach<FsNode>(FindDevRevFn{name, ans});
175 return ans;
176}
Data data_
存储的数据 (Stored data).
红黑树实现,支持泛型键和值,并提供线程安全操作 (Red-Black Tree implementation supporting generic keys and values with thread...
设备类,继承自红黑树节点 DeviceNode Device class inheriting from Red-Black tree node DeviceNode
目录类,继承自 RBTree 节点,用于管理文件、子目录和设备 Directory class, inheriting from RBTree node, used for managing files...
Device * FindDevice(const char *name)
在当前目录中查找设备 Finds a device in the current directory
文件系统节点基类,所有文件和目录均继承自该类 Base class for file system nodes; all files and directories inherit from this
◆ FindDir()
RamFS::Dir * RamFS::Dir::FindDir |
( |
const char * | name | ) |
|
查找当前目录中的子目录 Finds a subdirectory in the current directory
- Parameters
-
name | 目录名 The name of the directory |
- Returns
- Dir* 指向目录的指针,如果未找到则返回 nullptr Pointer to the directory, returns nullptr if not found
Definition at line 82 of file ramfs.cpp.
83{
84 if (name[0] == '.' && name[1] == '\0')
85 {
86 return this;
87 }
88
89 if (name[0] == '.' && name[1] == '.' && name[2] == '\0')
90 {
91 return reinterpret_cast<Dir *
>(
data_.parent);
92 }
93
95
97 {
98 return reinterpret_cast<Dir *>(ans);
99 }
100 else
101 {
102 return nullptr;
103 }
104}
◆ FindDirRev()
RamFS::Dir * RamFS::Dir::FindDirRev |
( |
const char * | name | ) |
|
递归查找子目录 Recursively searches for a subdirectory
- Parameters
-
name | 目录名 The name of the directory |
- Returns
- Dir* 指向目录的指针,如果未找到则返回 nullptr Pointer to the directory, returns nullptr if not found
Definition at line 106 of file ramfs.cpp.
107{
109 if (ans)
110 {
111 return ans;
112 }
113
114 struct FindDirRevFn
115 {
116 const char *name;
119 {
121 if (node.type == FsNodeType::DIR)
122 {
123 auto *dir =
reinterpret_cast<RamFS::Dir *
>(&item);
124 if (strcmp(dir->data_.name, name) == 0)
125 {
126 ans = dir;
127 return ErrorCode::FAILED;
128 }
129
131 return ans ? ErrorCode::FAILED : ErrorCode::OK;
132 }
133 return ErrorCode::OK;
134 }
135 };
136
137 data_.rbt.Foreach<FsNode>(FindDirRevFn{name, ans});
138 return ans;
139}
Dir * FindDir(const char *name)
查找当前目录中的子目录 Finds a subdirectory in the current directory
◆ FindFile()
RamFS::File * RamFS::Dir::FindFile |
( |
const char * | name | ) |
|
查找当前目录中的文件 Finds a file in the current directory
- Parameters
-
name | 文件名 The name of the file |
- Returns
- File* 指向文件的指针,如果未找到则返回 nullptr Pointer to the file, returns nullptr if not found
Definition at line 32 of file ramfs.cpp.
33{
34 auto ans = (*this)->rbt.Search<FsNode>(name);
36 {
37 return reinterpret_cast<File *>(ans);
38 }
39 else
40 {
41 return nullptr;
42 }
43}
◆ FindFileRev()
RamFS::File * RamFS::Dir::FindFileRev |
( |
const char * | name | ) |
|
递归查找文件 Recursively searches for a file
- Parameters
-
name | 文件名 The name of the file |
- Returns
- File* 指向文件的指针,如果未找到则返回 nullptr Pointer to the file, returns nullptr if not found
Definition at line 45 of file ramfs.cpp.
46{
48 if (ans)
49 {
50 return ans;
51 }
52
53 struct FindFileRevFn
54 {
55 const char *name;
58 {
60 if (node.type == FsNodeType::DIR)
61 {
62 auto *dir =
reinterpret_cast<RamFS::Dir *
>(&item);
63
65 if (f)
66 {
67 ans = f;
68 return ErrorCode::FAILED;
69 }
70
72 return ans ? ErrorCode::FAILED : ErrorCode::OK;
73 }
74 return ErrorCode::OK;
75 }
76 };
77
78 data_.rbt.Foreach<FsNode>(FindFileRevFn{name, ans});
79 return ans;
80}
红黑树的泛型数据节点,继承自 BaseNode (Generic data node for Red-Black Tree, inheriting from BaseNode).
File * FindFile(const char *name)
查找当前目录中的文件 Finds a file in the current directory
The documentation for this class was generated from the following files: