|
dtkio
dtk library for dtkio.
|
用以管理文件的类,对文件进行打开、关闭、写入等操作,以及获取其状态等 更多...
#include <dfile.h>
Public 成员函数 | |
| DFile (const QUrl &url) | |
| 构造函数, 通过 传入的url字符串 创建一个Dfile对象管理该url指向的文件 | |
| DTK_CORE_NAMESPACE::DExpected< QUrl > | url () const |
| 返回构造当前文件的url参数 | |
| DTK_CORE_NAMESPACE::DExpected< bool > | open (OpenFlags mode) |
| 以指定模式来打开目标文件 | |
| DTK_CORE_NAMESPACE::DExpected< bool > | close () |
| 关闭文件,同时清理掉DFile对象中的输入输出流信息 | |
| bool | isOpen () const |
| 返回文件是否打开 | |
| DTK_CORE_NAMESPACE::DExpected< size_t > | read (QByteArray *data, size_t maxSize) |
| 从文件中读取数据 | |
| DTK_CORE_NAMESPACE::DExpected< QByteArray > | readAll () |
| 将文件中数据全部读出 | |
| DTK_CORE_NAMESPACE::DExpected< size_t > | write (const QByteArray &data, size_t len) |
| 向文件中写入指定长度的数据 | |
| DTK_CORE_NAMESPACE::DExpected< size_t > | write (const QByteArray &data) |
| 向文件中写入数据 | |
| DTK_CORE_NAMESPACE::DExpected< bool > | seek (ssize_t pos, SeekType type=SeekType::Begin) const |
| 设置文件当前的位置 | |
| DTK_CORE_NAMESPACE::DExpected< ssize_t > | pos () const |
| 获取文件当前位置的偏移量 | |
| DTK_CORE_NAMESPACE::DExpected< bool > | flush () |
| 刷新文件当前输出流,并强制写出缓冲的输出字节 | |
| DTK_CORE_NAMESPACE::DExpected< size_t > | size () const |
| 获取文件的大小 | |
| bool | exists () const |
| 查看文件是否存在 | |
| DTK_CORE_NAMESPACE::DExpected< Permissions > | permissions () const |
| 获取文件的权限状态 | |
| DTK_CORE_NAMESPACE::DExpected< bool > | setPermissions (Permissions permission) |
| 设置文件的权限状态 | |
| DTK_CORE_NAMESPACE::DExpected< bool > | setAttribute (AttributeID id, const QVariant &value) |
| 设置文件属性 | |
| DTK_CORE_NAMESPACE::DExpected< bool > | setAttribute (const QByteArray &key, const QVariant &value, const AttributeType type, const FileQueryInfoFlags flag=FileQueryInfoFlags::TypeNoFollowSymlinks) |
| 设置文件属性 | |
| DFileFuture * | openAsync (OpenFlags mode, int ioPriority, QObject *parent=nullptr) |
| 以异步的方式打开文件 | |
| DFileFuture * | closeAsync (int ioPriority, QObject *parent=nullptr) |
| 以异步的方式关闭文件 | |
| DFileFuture * | readAsync (size_t maxSize, int ioPriority, QObject *parent=nullptr) |
| 以异步的方式读取文件数据 | |
| DFileFuture * | readAllAsync (int ioPriority, QObject *parent=nullptr) |
| 以异步的方式读取文件数据 | |
| DFileFuture * | writeAsync (const QByteArray &data, size_t len, int ioPriority, QObject *parent=nullptr) |
| 以异步的方式写入文件数据 | |
| DFileFuture * | writeAsync (const QByteArray &data, int ioPriority, QObject *parent=nullptr) |
| 以异步的方式写入文件数据 | |
| DFileFuture * | flushAsync (int ioPriority, QObject *parent=nullptr) |
| 以异步的方式刷新文件输出流并强制输出 | |
| DFileFuture * | sizeAsync (int ioPriority, QObject *parent=nullptr) |
| 以异步的方式获取文件的大小 | |
| DFileFuture * | existsAsync (int ioPriority, QObject *parent=nullptr) |
| 以异步的方式获取文件是否存在 | |
| DFileFuture * | permissionsAsync (int ioPriority, QObject *parent=nullptr) |
| 以异步的方式获取文件的权限属性 | |
| DFileFuture * | setPermissionsAsync (Permissions permission, int ioPriority, QObject *parent=nullptr) |
| 以异步的方式设置文件的权限属性 | |
| DTK_CORE_NAMESPACE::DError | lastError () const |
| 获取当前文件操作的错误码 | |
用以管理文件的类,对文件进行打开、关闭、写入等操作,以及获取其状态等
|
explicit |
构造函数, 通过 传入的url字符串 创建一个Dfile对象管理该url指向的文件
| [in] | url | 目标文件的url字符串 |
| DExpected< bool > DFile::close | ( | ) |
关闭文件,同时清理掉DFile对象中的输入输出流信息
| DFileFuture * DFile::closeAsync | ( | int | ioPriority, |
| QObject * | parent = nullptr |
||
| ) |
以异步的方式关闭文件
| [in] | ioPriority | 暂未使用到的参数 |
| [in] | parent | 父对象,默认为nullptr |
| bool DFile::exists | ( | ) | const |
查看文件是否存在
| DFileFuture * DFile::existsAsync | ( | int | ioPriority, |
| QObject * | parent = nullptr |
||
| ) |
以异步的方式获取文件是否存在
| [in] | ioPriority | 优先级控制 |
| [in] | parent | 父对象,默认为nullptr |
| DExpected< bool > DFile::flush | ( | ) |
刷新文件当前输出流,并强制写出缓冲的输出字节
| DFileFuture * DFile::flushAsync | ( | int | ioPriority, |
| QObject * | parent = nullptr |
||
| ) |
以异步的方式刷新文件输出流并强制输出
| [in] | ioPriority | 优先级控制 |
| [in] | parent | 父对象,默认为nullptr |
| bool DFile::isOpen | ( | ) | const |
返回文件是否打开
| true | 文件已打开 |
| false | 文件没有打开 |
| DError DFile::lastError | ( | ) | const |
获取当前文件操作的错误码
| DExpected< bool > DFile::open | ( | OpenFlags | mode | ) |
以指定模式来打开目标文件
| [in] | mode | 文件打开的模式(只写、只读、读写、追加等) |
| DFileFuture * DFile::openAsync | ( | OpenFlags | mode, |
| int | ioPriority, | ||
| QObject * | parent = nullptr |
||
| ) |
以异步的方式打开文件
| [in] | mode | 打开文件的模式(只写、只读、读写、追加等) |
| [in] | ioPriority | 暂未使用到的参数 |
| [in] | parent | 父对象,默认为nullptr |
| DExpected< Permissions > DFile::permissions | ( | ) | const |
获取文件的权限状态
| DFileFuture * DFile::permissionsAsync | ( | int | ioPriority, |
| QObject * | parent = nullptr |
||
| ) |
以异步的方式获取文件的权限属性
| [in] | ioPriority | 优先级控制 |
| [in] | parent | 父对象,默认为nullptr |
| DExpected< ssize_t > DFile::pos | ( | ) | const |
获取文件当前位置的偏移量
| DExpected< size_t > DFile::read | ( | QByteArray * | data, |
| size_t | maxSize | ||
| ) |
从文件中读取数据
| [out] | data | 用以存放读取到的数据 |
| [in] | maxSize | 从文件中读取数据的最大长度 |
| DExpected< QByteArray > DFile::readAll | ( | ) |
将文件中数据全部读出
| DFileFuture * DFile::readAllAsync | ( | int | ioPriority, |
| QObject * | parent = nullptr |
||
| ) |
以异步的方式读取文件数据
| [in] | ioPriority | 优先级控制 |
| [in] | parent | 父对象,默认为nullptr |
| DFileFuture * DFile::readAsync | ( | size_t | maxSize, |
| int | ioPriority, | ||
| QObject * | parent = nullptr |
||
| ) |
以异步的方式读取文件数据
| [in] | maxSize | 要读取数据的最大长度 |
| [in] | ioPriority | 优先级控制 |
| [in] | parent | 父对象,默认为nullptr |
| DExpected< bool > DFile::seek | ( | ssize_t | pos, |
| SeekType | type = SeekType::Begin |
||
| ) | const |
设置文件当前的位置
| [in] | pos | 要设置的偏移量 |
| [in] | type | 设置偏移量的类型(从开始位置、当前位置、末尾位置) |
| DExpected< bool > DFile::setAttribute | ( | AttributeID | id, |
| const QVariant & | value | ||
| ) |
设置文件属性
| [in] | id | 要设置的属性的id值 |
| [in] | value | 要设置的属性 |
| true | 操作成功 |
| DError对象 | 包含错误信息 |
| DExpected< bool > Dtk::IO::DFile::setAttribute | ( | const QByteArray & | key, |
| const QVariant & | value, | ||
| const AttributeType | type, | ||
| const FileQueryInfoFlags | flag = FileQueryInfoFlags::TypeNoFollowSymlinks |
||
| ) |
设置文件属性
| [in] | key | 要设置的属性的键值 |
| [in] | value | 要设置的属性 |
| [in] | type | 设置属性的类型(字符、字节、布尔值等) |
| [in] | flag | 查询文件信息时是否查询链接文件 |
| true | 操作成功 |
| DError对象 | 包含错误信息 |
| DExpected< bool > DFile::setPermissions | ( | Permissions | permission | ) |
设置文件的权限状态
| true | 操作成功 |
| DError对象 | 包含错误信息 |
| DFileFuture * DFile::setPermissionsAsync | ( | Permissions | permission, |
| int | ioPriority, | ||
| QObject * | parent = nullptr |
||
| ) |
以异步的方式设置文件的权限属性
| [in] | permission | 要设置的权限属性 |
| [in] | ioPriority | 优先级控制 |
| [in] | parent | 父对象,默认为nullptr |
| DExpected< size_t > DFile::size | ( | ) | const |
获取文件的大小
| DFileFuture * DFile::sizeAsync | ( | int | ioPriority, |
| QObject * | parent = nullptr |
||
| ) |
以异步的方式获取文件的大小
| [in] | ioPriority | 优先级控制 |
| [in] | parent | 父对象,默认为nullptr |
| DExpected< QUrl > DFile::url | ( | ) | const |
返回构造当前文件的url参数
| DExpected< size_t > DFile::write | ( | const QByteArray & | data | ) |
向文件中写入数据
| [in] | data | 要写入文件的数据 |
| DExpected< size_t > DFile::write | ( | const QByteArray & | data, |
| size_t | len | ||
| ) |
向文件中写入指定长度的数据
| [in] | data | 要写入文件的数据 |
| [in] | len | 写入数据的长度 |
| DFileFuture * Dtk::IO::DFile::writeAsync | ( | const QByteArray & | data, |
| int | ioPriority, | ||
| QObject * | parent = nullptr |
||
| ) |
以异步的方式写入文件数据
| [in] | data | 要写入的数据 |
| [in] | ioPriority | 优先级控制 |
| [in] | parent | 父对象,默认为nullptr |
| DFileFuture * Dtk::IO::DFile::writeAsync | ( | const QByteArray & | data, |
| size_t | len, | ||
| int | ioPriority, | ||
| QObject * | parent = nullptr |
||
| ) |
以异步的方式写入文件数据
| [in] | data | 要写入的数据 |
| [in] | len | 写入数据的长度 |
| [in] | ioPriority | 优先级控制 |
| [in] | parent | 父对象,默认为nullptr |