目录类,继承自 RBTree 节点,用于管理文件、子目录和设备 Directory class, inheriting from RBTree node, used for managing files, subdirectories, and devices
More...
#include <ramfs.hpp>
目录类,继承自 RBTree 节点,用于管理文件、子目录和设备 Directory class, inheriting from RBTree node, used for managing files, subdirectories, and devices
Definition at line 249 of file ramfs.hpp.
◆ Add() [1/3]
添加设备到当前目录 Adds a device to the current directory
- Parameters
-
dev | 要添加的设备 The device to be added |
Definition at line 277 of file ramfs.hpp.
278 {
279 (*this)->rbt.Insert(
dev,
dev->name);
281 }
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值
◆ 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 267 of file ramfs.hpp.
268 {
269 (*this)->rbt.Insert(
dir,
dir->name);
271 }
◆ 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 257 of file ramfs.hpp.
258 {
259 (*this)->rbt.Insert(file, file->name);
260 file->parent = this;
261 }
◆ 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 470 of file ramfs.hpp.
471 {
472 auto ans = (*this)->rbt.Search<FsNode>(name);
474 {
475 return reinterpret_cast<Device *
>(
ans);
476 }
477 else
478 {
479 return nullptr;
480 }
481 }
◆ 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 428 of file ramfs.hpp.
429 {
431
433
434 fun = [&](RBTree<const char *>::Node<FsNode> &
item) -> ErrorCode
435 {
438 {
439 Dir *
dir =
reinterpret_cast<Dir *
>(&
item);
440
441 ans =
dir->FindDevice(name);
443 {
444 return ErrorCode::FAILED;
445 }
446
447 dir->data_.rbt.Foreach<FsNode>([&](RBTree<const char *>::Node<FsNode> &child)
448 { return fun(child); });
449
450 return ans ? ErrorCode::FAILED : ErrorCode::OK;
451 }
452 return ErrorCode::OK;
453 };
454
456 {
457 data_.rbt.Foreach<FsNode>([&](RBTree<const char *>::Node<FsNode> &
item)
458 {
return fun(
item); });
459 }
461 }
DirNode data_
存储的数据 (Stored data).
Device * FindDevice(const char *name)
在当前目录中查找设备 Finds a device in the current directory
◆ FindDir()
查找当前目录中的子目录 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 353 of file ramfs.hpp.
354 {
355 if (name[0] == '.' && name[1] == '\0')
356 {
357 return this;
358 }
359
360 if (name[0] == '.' && name[1] == '.' && name[2] == '\0')
361 {
362 return reinterpret_cast<Dir *
>(
data_.parent);
363 }
364
365 auto ans = (*this)->rbt.Search<RamFS::FsNode>(name);
366
368 {
369 return reinterpret_cast<Dir *
>(
ans);
370 }
371 else
372 {
373 return nullptr;
374 }
375 }
◆ FindDirRev()
递归查找子目录 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 384 of file ramfs.hpp.
385 {
387
389
390 fun = [&](RBTree<const char *>::Node<FsNode> &
item) -> ErrorCode
391 {
394 {
395 Dir *
dir =
reinterpret_cast<Dir *
>(&
item);
397 {
399 return ErrorCode::OK;
400 }
401 else
402 {
403 dir->data_.rbt.Foreach<FsNode>([&](RBTree<const char *>::Node<FsNode> &child)
404 { return fun(child); });
405
406 return ans ? ErrorCode::FAILED : ErrorCode::OK;
407 }
408 }
409 return ErrorCode::OK;
410 };
411
413 {
414 data_.rbt.Foreach<FsNode>([&](RBTree<const char *>::Node<FsNode> &
item)
415 {
return fun(
item); });
416 }
417
419 }
Dir * FindDir(const char *name)
查找当前目录中的子目录 Finds a subdirectory in the current directory
◆ FindFile()
File * LibXR::RamFS::Dir::FindFile |
( |
const char * |
name | ) |
|
|
inline |
查找当前目录中的文件 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 290 of file ramfs.hpp.
291 {
292 auto ans = (*this)->rbt.Search<FsNode>(name);
294 {
295 return reinterpret_cast<File *
>(
ans);
296 }
297 else
298 {
299 return nullptr;
300 }
301 }
◆ FindFileRev()
File * LibXR::RamFS::Dir::FindFileRev |
( |
const char * |
name | ) |
|
|
inline |
递归查找文件 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 310 of file ramfs.hpp.
311 {
313
315
316 fun = [&](RBTree<const char *>::Node<FsNode> &
item) -> ErrorCode
317 {
320 {
321 Dir *
dir =
reinterpret_cast<Dir *
>(&
item);
322
323 ans =
dir->FindFile(name);
325 {
326 return ErrorCode::FAILED;
327 }
328
329 dir->data_.rbt.Foreach<FsNode>([&](RBTree<const char *>::Node<FsNode> &child)
330 { return fun(child); });
331
332 return ans ? ErrorCode::FAILED : ErrorCode::OK;
333 }
334 return ErrorCode::OK;
335 };
336
338 {
339 data_.rbt.Foreach<FsNode>([&](RBTree<const char *>::Node<FsNode> &
item)
340 {
return fun(
item); });
341 }
342
344 }
File * FindFile(const char *name)
查找当前目录中的文件 Finds a file in the current directory
The documentation for this class was generated from the following file: