|
libxr
1.0
Want to be the best embedded framework
|
轻量级内存文件系统 / Lightweight in-memory file system More...
#include <ramfs.hpp>
Data Structures | |
| 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 Dir | CreateDir (const char *name) |
| 创建目录节点 / Create a directory node | |
Data Fields | |
| Dir | root_ |
| Dir | bin_ |
| 预留的可执行文件目录 / Reserved executable-file directory. | |
Private Types | |
| enum class | FileType : uint8_t { READ_ONLY , READ_WRITE , EXEC } |
| 文件内部存储形态 / Internal storage kind of one file node More... | |
| using | Tree = RBTree<const char*> |
| RamFS 目录索引树类型 / Directory index tree type used by RamFS. | |
Static Private Member Functions | |
| static int | CompareStr (const char *const &a, const char *const &b) |
| RamFS 名称比较函数 / Name comparator used by RamFS trees. | |
| static char * | DuplicateName (const char *name) |
| 复制并持有一个节点名称 / Duplicate and retain one node name | |
轻量级内存文件系统 / 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.
|
private |
|
strongprivate |
文件内部存储形态 / Internal storage kind of one file node
| Enumerator | |
|---|---|
| READ_ONLY | 只读外部数据映射 / Read-only external-data view |
| READ_WRITE | 可写外部数据映射 / Read-write external-data view |
| EXEC | 可执行命令入口 / Executable command entry |
|
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 123 of file ramfs.hpp.
|
inline |
添加目录节点到根目录 / Add a directory node to the root directory
| dir | 目录节点 / Directory node |
Definition at line 117 of file ramfs.hpp.
|
inline |
添加文件节点到根目录 / Add a file node to the root directory
| file | 文件节点 / File node |
Definition at line 111 of file ramfs.hpp.
|
staticprivate |
RamFS 名称比较函数 / Name comparator used by RamFS trees.
RamFS 目录树里的名称比较函数 Name comparator used by the RamFS directory tree.
| a | 左侧名称 / Left name |
| b | 右侧名称 / Right name |
strcmp() 语义 / Comparison result following strcmp() semantics Definition at line 20 of file ramfs.cpp.
|
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 |
|
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 |
|
staticprivate |
复制并持有一个节点名称 / Duplicate and retain one node name
复制并持有一个节点名称 Duplicate and retain one node name
| name | 原始名称 / Source name |
| name | 原始名称 / Source name |
Definition at line 29 of file ramfs.cpp.
|
inline |
从整个 RamFS 递归查找自定义节点 / Find a custom node recursively from the RamFS root
| name | 节点名称 / Node name |
Definition at line 145 of file ramfs.hpp.
|
inline |
从整个 RamFS 递归查找目录 / Find a directory recursively from the RamFS root
| name | 目录名 / Directory name |
Definition at line 137 of file ramfs.hpp.
|
inline |
从整个 RamFS 递归查找文件 / Find a file recursively from the RamFS root
| name | 文件名 / File name |
Definition at line 130 of file ramfs.hpp.
| Dir LibXR::RamFS::bin_ |
| Dir LibXR::RamFS::root_ |