文件节点片段 / File-node fragment
More...
#include <ramfs.hpp>
|
| bool | IsReadOnly () const |
| | 判断文件是否只读 / Check whether the file is read-only
|
| |
| bool | IsReadWrite () const |
| | 判断文件是否可写 / Check whether the file is writable
|
| |
| bool | IsExecutable () const |
| | 判断文件是否可执行 / Check whether the file is executable
|
| |
| int | Run (int argc, char **argv) |
| | 执行可执行文件 / Run an executable file
|
| |
| template<typename DataType , SizeLimitMode LimitMode = SizeLimitMode::MORE> |
| decltype(auto) | Data () |
| | 访问类型化数据 / Access typed data
|
| |
| template<typename DataType , SizeLimitMode LimitMode = SizeLimitMode::MORE> |
| decltype(auto) | Data () const |
| | 从 const 文件对象访问类型化只读数据 / Access typed read-only data from a const file object
|
| |
| RawData | Data () |
| | 访问可写原始数据,要求文件为 READ_WRITE / Access writable raw data; requires READ_WRITE
|
| |
| ConstRawData | Data () const |
| | 访问只读原始数据 / Access read-only raw data
|
| |
| FsNodeType | GetNodeType () const |
| | 获取节点类型 / Get the node type
|
| |
| const char * | GetName () const |
| | 获取节点名称 / Get the node name
|
| |
|
| using | ExecFun = int (*)(void* raw, int argc, char** argv) |
| | 可执行文件调用入口类型 / Executable entry function type
|
| |
|
| template<typename DataType > |
| const DataType * | ReadableDataPtr () const |
| | 获取只读数据地址 Get the readable data pointer
|
| |
| template<typename DataType > |
| DataType * | WritableDataPtr () |
| | 获取可写数据地址 Get the writable data pointer
|
| |
| | File () |
| | 构造一个空文件壳 / Construct one empty file shell
|
| |
| | File (const char *name) |
| | 构造一个具名文件壳 / Construct one named file shell
|
| |
|
| | FsNode (FsNodeType node_type) |
| | 用指定节点类型构造基类部分 / Construct the base node with a given node type
|
| |
| | FsNode (const FsNode &other) |
| | 拷贝构造节点基类部分 / Copy-construct the base-node portion
|
| |
|
FsNode & | operator= (const FsNode &)=delete |
| |
| const char * | name_ = nullptr |
| | 节点名称缓冲区 / Retained node-name buffer.
|
| |
| FsNodeType | type_ |
| | 节点运行时类型 / Runtime node type.
|
| |
| Dir * | parent_ |
| | 父目录;根目录保持为空 / Parent directory; stays null for the root.
|
| |
| Tree::Node< FsNode * > | tree_node_ |
| |
文件节点片段 / File-node fragment
RamFS 的文件节点片段 / File-node fragment of RamFS
内存文件或可执行文件 / Memory file or executable file
Definition at line 9 of file ramfs.hpp.
◆ ExecFun
可执行文件调用入口类型 / Executable entry function type
Definition at line 110 of file ramfs.hpp.
◆ File() [1/2]
构造一个空文件壳 / Construct one empty file shell
构造一个空文件壳 Construct one empty file shell
Definition at line 63 of file ramfs.cpp.
size_t size_
数据负载字节数 / Payload size in bytes.
void * arg_
可执行文件上下文块 / Executable context block.
void * addr_
可写数据地址 / Writable payload address.
FsNode(FsNodeType node_type)
用指定节点类型构造基类部分 / Construct the base node with a given node type
◆ File() [2/2]
| RamFS::File::File |
( |
const char * | name | ) |
|
|
explicitprivate |
构造一个具名文件壳 / Construct one named file shell
构造一个具名文件壳 Construct one named file shell
- Parameters
-
Definition at line 70 of file ramfs.cpp.
File()
构造一个空文件壳 / Construct one empty file shell
const char * name_
节点名称缓冲区 / Retained node-name buffer.
static char * DuplicateName(const char *name)
复制并持有一个节点名称 / Duplicate and retain one node name
◆ Data() [1/4]
template<typename DataType ,
SizeLimitMode LimitMode = SizeLimitMode::MORE>
| decltype(auto) LibXR::RamFS::File::Data |
( |
| ) |
|
|
inline |
访问类型化数据 / Access typed data
Data<T>() 返回可写引用并要求 READ_WRITE / Data<T>() returns a writable reference and requires READ_WRITE. Data<const T>() 返回只读引用 / Data<const T>() returns a read-only reference for both READ_ONLY and READ_WRITE.
- Template Parameters
-
| DataType | 数据类型;使用 const T 表示只读访问 / Data type; use const T for read-only access. |
| LimitMode | 大小检查模式 / Size-check mode |
- Returns
- 类型化数据引用 / Typed data reference
Definition at line 52 of file ramfs.hpp.
55 : uint8_t
56 {
60 };
61
@ READ_ONLY
只读外部数据映射 / Read-only external-data view
@ READ_WRITE
可写外部数据映射 / Read-write external-data view
@ EXEC
可执行命令入口 / Executable command entry
◆ Data() [2/4]
| RawData LibXR::RamFS::File::Data |
( |
| ) |
|
|
inlinenodiscard |
访问可写原始数据,要求文件为 READ_WRITE / Access writable raw data; requires READ_WRITE
- Returns
- 可写原始数据视图 / Writable raw data view
Definition at line 95 of file ramfs.hpp.
◆ Data() [3/4]
template<typename DataType ,
SizeLimitMode LimitMode = SizeLimitMode::MORE>
| decltype(auto) LibXR::RamFS::File::Data |
( |
| ) |
const |
|
inline |
从 const 文件对象访问类型化只读数据 / Access typed read-only data from a const file object
- Template Parameters
-
| DataType | 数据类型 / Data type |
| LimitMode | 大小检查模式 / Size-check mode |
- Returns
- 类型化只读数据引用 / Typed read-only data reference
Definition at line 79 of file ramfs.hpp.
◆ Data() [4/4]
访问只读原始数据 / Access read-only raw data
- Returns
- 只读原始数据视图 / Read-only raw data view
Definition at line 101 of file ramfs.hpp.
◆ DataAccessPanic()
| static void LibXR::RamFS::File::DataAccessPanic |
( |
| ) |
|
|
inlinestaticprivate |
处理不应到达的 File 数据访问路径 Handle one File data-access path that should be unreachable
- Note
- 这里保留强约束终止语义,但不再依赖“断言后继续解引用空指针”来满足返回类型, 从而避免发布构建中的未定义行为。 This keeps the strong-failure semantics while no longer relying on "assert then dereference a null pointer" to satisfy the return type, avoiding undefined behavior in release builds.
Definition at line 122 of file ramfs.hpp.
134{
143class RamFS
144{
145 public:
153 RamFS(
const char* name =
"ramfs");
154
159 {
163 };
164
166
167 private:
171 using Tree = RBTree<const char*>;
172
177 {
181 };
182
190 static int CompareStr(
const char*
const& a,
const char*
const& b);
191
192 public:
196#include "fs_node.hpp"
200#include "file.hpp"
204#include "custom.hpp"
208#include "dir.hpp"
212#include "factory.hpp"
213
214 private:
225};
226}
RamFS 的目录节点片段 / Directory-node fragment of RamFS
RamFS(const char *name="ramfs")
构造 RamFS,并创建根目录和 bin 目录 / Construct RamFS with root and bin directories
FsNodeType
文件系统节点类型 / File-system node type
@ CUSTOM
用户自定义节点 / User-defined node
RBTree< const char * > Tree
RamFS 目录索引树类型 / Directory index tree type used by RamFS.
static int CompareStr(const char *const &a, const char *const &b)
RamFS 名称比较函数 / Name comparator used by RamFS trees.
FileType
文件内部存储形态 / Internal storage kind of one file node
◆ IsExecutable()
| bool LibXR::RamFS::File::IsExecutable |
( |
| ) |
const |
|
inlinenodiscard |
判断文件是否可执行 / Check whether the file is executable
- Returns
- 可执行返回 true / True if the file is executable
Definition at line 28 of file ramfs.hpp.
◆ IsReadOnly()
| bool LibXR::RamFS::File::IsReadOnly |
( |
| ) |
const |
|
inlinenodiscard |
判断文件是否只读 / Check whether the file is read-only
- Returns
- 只读返回 true / True if the file is read-only
Definition at line 16 of file ramfs.hpp.
◆ IsReadWrite()
| bool LibXR::RamFS::File::IsReadWrite |
( |
| ) |
const |
|
inlinenodiscard |
判断文件是否可写 / Check whether the file is writable
- Returns
- 可写返回 true / True if the file is writable
Definition at line 22 of file ramfs.hpp.
◆ ReadableDataPtr()
template<typename DataType >
| const DataType * LibXR::RamFS::File::ReadableDataPtr |
( |
| ) |
const |
|
inlineprivate |
获取只读数据地址 Get the readable data pointer
- Template Parameters
-
| DataType | 目标数据类型 / Target data type |
- Returns
- 只读数据指针 / Read-only data pointer
Definition at line 135 of file ramfs.hpp.
147{
156class RamFS
157{
158 public:
166 RamFS(
const char* name =
"ramfs");
167
172 {
176 };
177
179
180 private:
184 using Tree = RBTree<const char*>;
185
190 {
194 };
195
203 static int CompareStr(
const char*
const& a,
const char*
const& b);
204
205 public:
209#include "fs_node.hpp"
213#include "file.hpp"
217#include "custom.hpp"
221#include "dir.hpp"
225#include "factory.hpp"
226
227 private:
238};
239}
◆ Run()
| int RamFS::File::Run |
( |
int | argc, |
|
|
char ** | argv ) |
执行可执行文件 / Run an executable file
执行可执行文件节点 Run one executable file node
- Parameters
-
| argc | 参数数量 / Argument count |
| argv | 参数数组 / Argument vector |
- Returns
- 执行返回值 / Execution return value
Definition at line 79 of file ramfs.cpp.
80{
82 ASSERT(
exec_ !=
nullptr);
84}
ExecFun exec_
可执行入口函数 / Executable entry function.
FileType file_type_
当前文件存储形态 / Current file storage kind.
◆ WritableDataPtr()
template<typename DataType >
| DataType * LibXR::RamFS::File::WritableDataPtr |
( |
| ) |
|
|
inlineprivate |
获取可写数据地址 Get the writable data pointer
- Template Parameters
-
| DataType | 目标数据类型 / Target data type |
- Returns
- 可写数据指针 / Writable data pointer
Definition at line 155 of file ramfs.hpp.
167{
176class RamFS
177{
178 public:
186 RamFS(
const char* name =
"ramfs");
187
192 {
196 };
197
199
200 private:
204 using Tree = RBTree<const char*>;
205
210 {
214 };
215
223 static int CompareStr(
const char*
const& a,
const char*
const& b);
224
225 public:
229#include "fs_node.hpp"
233#include "file.hpp"
237#include "custom.hpp"
241#include "dir.hpp"
245#include "factory.hpp"
246
247 private:
258};
259}
◆ RamFS
◆ [union]
文件负载联合体 / File payload union
The same storage is interpreted either as mutable data, const data, or an executable entry depending on file_type_. 这块存储会根据 file_type_ 被解释成可写数据、只读数据或可执行入口。
◆ addr_
| void* LibXR::RamFS::File::addr_ |
可写数据地址 / Writable payload address.
Definition at line 184 of file ramfs.hpp.
◆ addr_const_
| const void* LibXR::RamFS::File::addr_const_ |
只读数据地址 / Read-only payload address.
Definition at line 185 of file ramfs.hpp.
◆ arg_
| void* LibXR::RamFS::File::arg_ = nullptr |
|
private |
可执行文件上下文块 / Executable context block.
Definition at line 189 of file ramfs.hpp.
◆ exec_
可执行入口函数 / Executable entry function.
Definition at line 186 of file ramfs.hpp.
◆ file_type_
Initial value:
当前文件存储形态 / Current file storage kind.
Definition at line 191 of file ramfs.hpp.
◆ size_
| size_t LibXR::RamFS::File::size_ = 0 |
|
private |
数据负载字节数 / Payload size in bytes.
Definition at line 190 of file ramfs.hpp.
The documentation for this class was generated from the following files: