目录类,继承自 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 184 of file ramfs.cpp.
185{
186 auto ans = (*this)->rbt.Search<FsNode>(name);
188 {
189 return reinterpret_cast<Device *>(ans);
190 }
191 else
192 {
193 return nullptr;
194 }
195}
◆ 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 142 of file ramfs.cpp.
143{
145
147
149 {
150 FsNode &node = item;
152 {
153 Dir *dir = reinterpret_cast<Dir *>(&item);
154
155 ans = dir->FindDevice(name);
156 if (ans)
157 {
158 return ErrorCode::FAILED;
159 }
160
162 { return fun(child); });
163
164 return ans ? ErrorCode::FAILED : ErrorCode::OK;
165 }
166 return ErrorCode::OK;
167 };
168
169 if (ans == nullptr)
170 {
172 { return fun(item); });
173 }
174 return ans;
175}
红黑树的泛型数据节点,继承自 BaseNode (Generic data node for Red-Black Tree, inheriting from BaseNode).
红黑树实现,支持泛型键和值,并提供线程安全操作 (Red-Black Tree implementation supporting generic keys and values with thread...
Device * FindDevice(const char *name)
在当前目录中查找设备 Finds a device in the current directory
◆ 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 81 of file ramfs.cpp.
82{
83 if (name[0] == '.' && name[1] == '\0')
84 {
85 return this;
86 }
87
88 if (name[0] == '.' && name[1] == '.' && name[2] == '\0')
89 {
90 return reinterpret_cast<Dir *
>(
data_.parent);
91 }
92
94
96 {
97 return reinterpret_cast<Dir *>(ans);
98 }
99 else
100 {
101 return nullptr;
102 }
103}
文件系统节点基类,所有文件和目录均继承自该类 Base class for file system nodes; all files and directories inherit from this
◆ 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 105 of file ramfs.cpp.
106{
108
110
112 {
113 FsNode &node = item;
115 {
116 Dir *dir = reinterpret_cast<Dir *>(&item);
117 if (strcmp(dir->data_.name, name) == 0)
118 {
119 ans = dir;
120 return ErrorCode::OK;
121 }
122 else
123 {
125 { return fun(child); });
126
127 return ans ? ErrorCode::FAILED : ErrorCode::OK;
128 }
129 }
130 return ErrorCode::OK;
131 };
132
133 if (ans == nullptr)
134 {
136 { return fun(item); });
137 }
138
139 return ans;
140}
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
50
52 {
53 FsNode &node = item;
55 {
56 Dir *dir = reinterpret_cast<Dir *>(&item);
57
58 ans = dir->FindFile(name);
59 if (ans)
60 {
61 return ErrorCode::FAILED;
62 }
63
65 { return fun(child); });
66
67 return ans ? ErrorCode::FAILED : ErrorCode::OK;
68 }
69 return ErrorCode::OK;
70 };
71
72 if (ans == nullptr)
73 {
75 { return fun(item); });
76 }
77
78 return ans;
79}
File * FindFile(const char *name)
查找当前目录中的文件 Finds a file in the current directory
The documentation for this class was generated from the following files: