ddcifile.h 是关于dci文件相关操作的一个类,实现了 DCI 文件的逻辑。其只是对数据的打包 dci文件的结构路径如下:
更多...
#include <ddcifile.h>
|
enum | FileType { UnknowFile
, File = 1
, Directory = 2
, Symlink = 3
} |
| dci文件类型 更多...
|
|
|
| DDciFile (const QString &fileName) |
|
| DDciFile (const QByteArray &data) |
|
bool | isValid () const |
| 判断读取的dci文件是否有效 更多...
|
|
QString | lastErrorString () const |
| 获取上一个报错信息,为人类可读字符串,可以通过此报错信息来获取错误内容,一般情况下是因为文件不存在或者文件名过长(>62个字符)导致。
|
|
bool | writeToFile (const QString &fileName) const |
| 写入文件,在做完对于dci文件的操作之后调用此接口,为保存的作用 更多...
|
|
bool | writeToDevice (QIODevice *device) const |
| 写入到设备,设备指的是qt中的io设备,可以在qt文档中找到相关信息 更多...
|
|
QByteArray | toData () const |
| 返回dci文件的原始数据,以QByteArray形式返回 更多...
|
|
QStringList | list (const QString &dir, bool onlyFileName=false) const |
| 列出文件列表 更多...
|
|
int | childrenCount (const QString &dir) const |
| 子文件计数
|
|
bool | exists (const QString &filePath) const |
| 判断文件是否存在 更多...
|
|
FileType | type (const QString &filePath) const |
| 判断文件类型 更多...
|
|
QByteArray | dataRef (const QString &filePath) const |
| 获取dci内部文件的数据,以一种引用(软连接)的方式获取,不会产生数据的的复制 更多...
|
|
QString | name (const QString &filePath) const |
| 获取dci内文件的文件名 更多...
|
|
QString | symlinkTarget (const QString &filePath, bool originData=false) const |
| 获取软链目标 更多...
|
|
bool | mkdir (const QString &filePath) |
| 创建目录(注意:此目录指的是在dci文件内部的目录,而不是指的是传统目录) 更多...
|
|
bool | writeFile (const QString &filePath, const QByteArray &data, bool override=false) |
| 写入文件 更多...
|
|
bool | remove (const QString &filePath) |
| 移除文件 更多...
|
|
bool | rename (const QString &filePath, const QString &newFilePath, bool override=false) |
| 重命名文件 更多...
|
|
bool | copy (const QString &from, const QString &to) |
|
bool | link (const QString &source, const QString &to) |
| 链接文件 更多...
|
|
|
static void | registerFileEngine () |
|
static constexpr int | metadataSizeV1 () |
| MAGIC_SIZE + VERSION_SIZE + FILE_COUNT_SIZE: 4+1+3 = 8
|
|
ddcifile.h 是关于dci文件相关操作的一个类,实现了 DCI 文件的逻辑。其只是对数据的打包 dci文件的结构路径如下:
◆ FileType
dci文件类型
值 | 序号 | 含义 |
UnknowFile | 0 | 未知文件 |
File | 1 | 文件 |
Directory | 2 | 目录 |
Symlink | 3 | 软连接 |
◆ dataRef()
QByteArray Dtk::Core::DDciFile::dataRef |
( |
const QString & |
filePath | ) |
const |
获取dci内部文件的数据,以一种引用(软连接)的方式获取,不会产生数据的的复制
- 参数
-
- 返回值
-
◆ exists()
bool Dtk::Core::DDciFile::exists |
( |
const QString & |
filePath | ) |
const |
◆ isValid()
bool Dtk::Core::DDciFile::isValid |
( |
| ) |
const |
判断读取的dci文件是否有效
当指定的dci文件未成功加载时,此函数会返回false,一般会出现在文件格式错误(不是一个dci格式的文件),或者是dci文件数据被篡改而无法识别的情况
- 注解
- 本类中所有涉及文件操作的函数均会首先执行此方法,故如无必要,无需手动确保文件是否有效
◆ link()
bool Dtk::Core::DDciFile::link |
( |
const QString & |
source, |
|
|
const QString & |
to |
|
) |
| |
◆ list()
QStringList Dtk::Core::DDciFile::list |
( |
const QString & |
dir, |
|
|
bool |
onlyFileName = false |
|
) |
| const |
列出文件列表
- 参数
-
[in] | dir | 文件夹地址 |
[in] | onlyFileName | 是否只显示文件名 默认为false |
◆ mkdir()
bool Dtk::Core::DDciFile::mkdir |
( |
const QString & |
filePath | ) |
|
创建目录(注意:此目录指的是在dci文件内部的目录,而不是指的是传统目录)
- 参数
-
- 返回
- 操作是否成功
◆ name()
QString Dtk::Core::DDciFile::name |
( |
const QString & |
filePath | ) |
const |
◆ remove()
bool Dtk::Core::DDciFile::remove |
( |
const QString & |
filePath | ) |
|
◆ rename()
bool Dtk::Core::DDciFile::rename |
( |
const QString & |
filePath, |
|
|
const QString & |
newFilePath, |
|
|
bool |
override = false |
|
) |
| |
重命名文件
- 参数
-
[in] | filePath | DCI图标结构路径 |
[in] | newFilePath | 新文件的路径 |
[in] | override | 当文件已经存在时,是否覆盖此文件,默认状态下不执行覆盖,会在lasterror中记录"The target file is existed"错误信息。 如果传入为true,则会执行覆盖操作,** 此操作不可逆 **。 |
- 返回
- 操作是否成功
◆ symlinkTarget()
QString Dtk::Core::DDciFile::symlinkTarget |
( |
const QString & |
filePath, |
|
|
bool |
originData = false |
|
) |
| const |
获取软链目标
- 参数
-
[in] | filePath | DCI图标结构路径 |
[in] | originData | |
- 返回值
-
- 注解
- 链接的目标只能是“不存在的路径”、“文件”、“链接”,不可是目录
◆ toData()
QByteArray Dtk::Core::DDciFile::toData |
( |
| ) |
const |
◆ type()
FileType Dtk::Core::DDciFile::type |
( |
const QString & |
filePath | ) |
const |
◆ writeFile()
bool Dtk::Core::DDciFile::writeFile |
( |
const QString & |
filePath, |
|
|
const QByteArray & |
data, |
|
|
bool |
override = false |
|
) |
| |
写入文件
- 参数
-
[in] | filePath | DCI图标结构路径 |
[in] | data | 数据内容 |
[in] | override | 当文件已经存在时,是否覆盖此文件,默认状态下不执行覆盖,会在lasterror中记录"The target file is existed"错误信息。 如果传入为true,则会执行覆盖操作,** 此操作不可逆 **。 |
- 返回
- 操作是否成功
- 参见
- QByteArray DDciFile::toData()
◆ writeToDevice()
bool Dtk::Core::DDciFile::writeToDevice |
( |
QIODevice * |
device | ) |
const |
写入到设备,设备指的是qt中的io设备,可以在qt文档中找到相关信息
- 参数
-
- 参见
- QIODevice
◆ writeToFile()
bool Dtk::Core::DDciFile::writeToFile |
( |
const QString & |
fileName | ) |
const |
写入文件,在做完对于dci文件的操作之后调用此接口,为保存的作用
- 参数
-
该类的文档由以下文件生成:
- include/dci/ddcifile.h
- docs/dci/ddcifile.zh_CN.dox