RamFS 的文件节点片段 / File-node fragment of RamFS
More...
#include <file.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
|
| |
|
| | 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_ |
| |
RamFS 的文件节点片段 / File-node fragment of RamFS
内存文件或可执行文件 / Memory file or executable file
Definition at line 8 of file file.hpp.
◆ Data() [1/4]
template<typename DataType , SizeLimitMode LimitMode = SizeLimitMode::MORE>
| decltype(auto) 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 51 of file file.hpp.
52 {
53 using RequestedType = std::remove_reference_t<DataType>;
54 using StoredType = std::remove_cv_t<RequestedType>;
55 static_assert(!std::is_reference_v<DataType>);
56 static_assert(!std::is_volatile_v<RequestedType>);
57
59 if constexpr (std::is_const_v<RequestedType>)
60 {
61 return *ReadableDataPtr<StoredType>();
62 }
63 else
64 {
65 return *WritableDataPtr<StoredType>();
66 }
67 }
constexpr bool SizeLimitCheck(SizeLimitMode mode, size_t limit, size_t size) noexcept
尺寸约束的纯判断函数 / Pure predicate for size-limit comparisons
◆ Data() [2/4]
访问可写原始数据,要求文件为 READ_WRITE / Access writable raw data; requires READ_WRITE
- Returns
- 可写原始数据视图 / Writable raw data view
Definition at line 94 of file file.hpp.
94{ return RawData(WritableDataPtr<void>(), size_); }
◆ Data() [3/4]
template<typename DataType , SizeLimitMode LimitMode = SizeLimitMode::MORE>
| decltype(auto) 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 78 of file file.hpp.
79 {
80 using RequestedType = std::remove_reference_t<DataType>;
81 using StoredType = std::remove_cv_t<RequestedType>;
82 static_assert(!std::is_reference_v<DataType>);
83 static_assert(!std::is_volatile_v<RequestedType>);
84
86 return *ReadableDataPtr<StoredType>();
87 }
◆ Data() [4/4]
| ConstRawData File::Data |
( |
| ) |
const |
|
inlinenodiscard |
访问只读原始数据 / Access read-only raw data
- Returns
- 只读原始数据视图 / Read-only raw data view
Definition at line 100 of file file.hpp.
101 {
102 return ConstRawData(ReadableDataPtr<void>(), size_);
103 }
◆ IsExecutable()
| bool File::IsExecutable |
( |
| ) |
const |
|
inlinenodiscard |
判断文件是否可执行 / Check whether the file is executable
- Returns
- 可执行返回 true / True if the file is executable
Definition at line 27 of file file.hpp.
27{ return file_type_ == FileType::EXEC; }
◆ IsReadOnly()
| bool File::IsReadOnly |
( |
| ) |
const |
|
inlinenodiscard |
判断文件是否只读 / Check whether the file is read-only
- Returns
- 只读返回 true / True if the file is read-only
Definition at line 15 of file file.hpp.
15{ return file_type_ == FileType::READ_ONLY; }
◆ IsReadWrite()
| bool File::IsReadWrite |
( |
| ) |
const |
|
inlinenodiscard |
判断文件是否可写 / Check whether the file is writable
- Returns
- 可写返回 true / True if the file is writable
Definition at line 21 of file file.hpp.
21{ return file_type_ == FileType::READ_WRITE; }
◆ Run()
| int File::Run |
( |
int | argc, |
|
|
char ** | argv ) |
执行可执行文件 / Run an executable file
- Parameters
-
| argc | 参数数量 / Argument count |
| argv | 参数数组 / Argument vector |
- Returns
- 执行返回值 / Execution return value
◆ RamFS
◆ addr_
可写数据地址 / Writable payload address.
Definition at line 183 of file file.hpp.
◆ addr_const_
| const void* File::addr_const_ |
只读数据地址 / Read-only payload address.
Definition at line 184 of file file.hpp.
◆ exec_
可执行入口函数 / Executable entry function.
Definition at line 185 of file file.hpp.
The documentation for this class was generated from the following file: