|
libxr
Embedded C++ framework for bare-metal, RTOS and Linux
|
轻量级内存文件系统 / Lightweight in-memory file system More...
#include <ramfs.hpp>
Classes | |
| class | Custom |
| 自定义节点片段 / Custom-node fragment More... | |
| class | Dir |
| 目录节点片段 / Directory-node fragment More... | |
| class | File |
| 文件节点片段 / File-node fragment More... | |
| class | FsNode |
| 节点基类片段 / Base-node fragment More... | |
Public Types | |
| enum class | FsNodeType : uint8_t { FILE , DIR , CUSTOM } |
| 文件系统节点类型 / File-system node type More... | |
Public Member Functions | |
| RamFS (const char *name="ramfs") | |
构造 RamFS,并创建根目录和 bin 目录 / Construct RamFS with root and bin directories | |
| void | Add (File &file) |
| 添加文件节点到根目录 / Add a file node to the root directory | |
| void | Add (Dir &dir) |
| 添加目录节点到根目录 / Add a directory node to the root directory | |
| void | Add (Custom &custom) |
| 添加自定义节点到根目录 / Add a custom node to the root directory | |
| File * | FindFile (const char *name) |
| 从整个 RamFS 递归查找文件 / Find a file recursively from the RamFS root | |
| Dir * | FindDir (const char *name) |
| 从整个 RamFS 递归查找目录 / Find a directory recursively from the RamFS root | |
| Custom * | FindCustom (const char *name) |
| 从整个 RamFS 递归查找自定义节点 / Find a custom node recursively from the RamFS root | |
Static Public Member Functions | |
| template<typename DataType > | |
| static File | CreateFile (const char *name, DataType &raw) |
| 工厂与根入口片段 / Factory and root-entry fragment | |
| template<typename ArgType > | |
| static File | CreateFile (const char *name, int(*exec)(ArgType arg, int argc, char **argv), ArgType &&arg) |
| 创建可执行文件 / Create an executable file | |
| template<typename ArgType > | |
| static File | CreateCommand (const char *name, int(*exec)(ArgType arg, int argc, char **argv), ArgType &&arg) |
| 创建命令兼容入口,返回可执行文件 / Create a command-compatible executable file | |
| static File | CreateCommand (const char *name, int(*exec)(int argc, char **argv)) |
| 创建不需要执行上下文的命令 / Create a command that needs no execution context | |
| static Dir | CreateDir (const char *name) |
| 创建目录节点 / Create a directory node | |
Public Attributes | |
| Dir | root_ |
| Dir | bin_ |
| 预留的可执行文件目录 / Reserved executable-file directory. | |
轻量级内存文件系统 / Lightweight in-memory file system
RamFS 组织外部内存文件、可执行文件、目录和自定义节点 / RamFS organizes external-memory files, executable files, directories, and custom nodes. 文件数据由调用方持有 / File payload storage is owned by the caller.
|
strong |
| RamFS::RamFS | ( | const char * | name = "ramfs" | ) |
构造 RamFS,并创建根目录和 bin 目录 / Construct RamFS with root and bin directories
构造 RamFS,并挂接根目录下的 bin 目录 Construct RamFS and attach the bin directory under the root
| name | 根目录名称 / Root directory name |
| name | 根目录名称 / Root directory name |
Definition at line 10 of file ramfs.cpp.
|
inline |
添加自定义节点到根目录 / Add a custom node to the root directory
| custom | 自定义节点 / Custom node |
Definition at line 151 of file ramfs.hpp.
|
inline |
添加目录节点到根目录 / Add a directory node to the root directory
| dir | 目录节点 / Directory node |
Definition at line 145 of file ramfs.hpp.
|
inline |
添加文件节点到根目录 / Add a file node to the root directory
| file | 文件节点 / File node |
Add(RamFS::CreateCommand(...)) 传入临时对象会留下悬空指针,因此不接受右值。 RamFS only stores the node address, so the node must be an lvalue that lives for the whole run; passing a temporary from CreateCommand(...) would leave a dangling pointer, which is why rvalues are not accepted. Definition at line 139 of file ramfs.hpp.
|
inlinestatic |
创建命令兼容入口,返回可执行文件 / Create a command-compatible executable file
| ArgType | 执行上下文参数类型 / Execution context argument type |
| name | 文件名 / File name |
| exec | 执行函数 / Execution function |
| arg | 执行上下文参数 / Execution context argument |
Definition at line 92 of file ramfs.hpp.
|
inlinestatic |
创建不需要执行上下文的命令 / Create a command that needs no execution context
| name | 文件名 / File name |
| exec | 命令函数,参数为 argc 和 argv / Command function taking argc and argv |
CreateCommand<void*>(name, [](void*, int, char**) {...}, nullptr)。 Equivalent to the form with an execution context, the context being the function itself; CreateCommand<void*>(name, [](void*, int, char**) {...}, nullptr) is no longer needed. Definition at line 112 of file ramfs.hpp.
|
inlinestatic |
创建目录节点 / Create a directory node
| name | 目录名称 / Directory name |
Definition at line 127 of file ramfs.hpp.
|
inlinestatic |
工厂与根入口片段 / Factory and root-entry fragment
RamFS 的工厂与根入口片段 / Factory and root-entry fragment of RamFS
创建引用外部数据的文件 / Create a file referencing external data
| DataType | 外部数据类型 / External data type |
| name | 文件名 / File name |
| raw | 外部数据引用 / External data reference |
|
inlinestatic |
创建可执行文件 / Create an executable file
| ArgType | 执行上下文参数类型 / Execution context argument type |
| name | 文件名 / File name |
| exec | 执行函数 / Execution function |
| arg | 执行上下文参数 / Execution context argument |
Definition at line 51 of file ramfs.hpp.
|
inline |
从整个 RamFS 递归查找自定义节点 / Find a custom node recursively from the RamFS root
| name | 节点名称 / Node name |
Definition at line 173 of file ramfs.hpp.
|
inline |
从整个 RamFS 递归查找目录 / Find a directory recursively from the RamFS root
| name | 目录名 / Directory name |
Definition at line 165 of file ramfs.hpp.
|
inline |
从整个 RamFS 递归查找文件 / Find a file recursively from the RamFS root
| name | 文件名 / File name |
Definition at line 158 of file ramfs.hpp.
| Dir LibXR::RamFS::bin_ |
| Dir LibXR::RamFS::root_ |