mirror of
https://github.com/LongSoft/UEFITool.git
synced 2025-05-12 22:26:13 -04:00
LessQt, part 1
- added wrappers over Qt classes for seamless replacement if Qt is not available - added bstrlib as submodule - only UEFIExtract works with this changes for now, others will followa bit later
This commit is contained in:
parent
71ce2a07b2
commit
bf8632c063
32 changed files with 2891 additions and 2774 deletions
|
@ -22,48 +22,48 @@ FfsDumper::~FfsDumper()
|
|||
{
|
||||
}
|
||||
|
||||
STATUS FfsDumper::dump(const QModelIndex & root, const QString & path, const bool dumpAll, const QString & guid)
|
||||
USTATUS FfsDumper::dump(const UModelIndex & root, const UString & path, const bool dumpAll, const UString & guid)
|
||||
{
|
||||
dumped = false;
|
||||
UINT8 result = recursiveDump(root, path, dumpAll, guid);
|
||||
if (result)
|
||||
return result;
|
||||
else if (!dumped)
|
||||
return ERR_ITEM_NOT_FOUND;
|
||||
return ERR_SUCCESS;
|
||||
return U_ITEM_NOT_FOUND;
|
||||
return U_SUCCESS;
|
||||
}
|
||||
|
||||
STATUS FfsDumper::recursiveDump(const QModelIndex & index, const QString & path, const bool dumpAll, const QString & guid)
|
||||
USTATUS FfsDumper::recursiveDump(const UModelIndex & index, const UString & path, const bool dumpAll, const UString & guid)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return ERR_INVALID_PARAMETER;
|
||||
return U_INVALID_PARAMETER;
|
||||
|
||||
QDir dir;
|
||||
if (guid.isEmpty() ||
|
||||
guidToQString(*(const EFI_GUID*)model->header(index).constData()) == guid ||
|
||||
guidToQString(*(const EFI_GUID*)model->header(model->findParentOfType(index, Types::File)).constData()) == guid) {
|
||||
guidToUString(*(const EFI_GUID*)model->header(index).constData()) == guid ||
|
||||
guidToUString(*(const EFI_GUID*)model->header(model->findParentOfType(index, Types::File)).constData()) == guid) {
|
||||
|
||||
if (dir.cd(path))
|
||||
return ERR_DIR_ALREADY_EXIST;
|
||||
return U_DIR_ALREADY_EXIST;
|
||||
|
||||
if (!dir.mkpath(path))
|
||||
return ERR_DIR_CREATE;
|
||||
return U_DIR_CREATE;
|
||||
|
||||
QFile file;
|
||||
if (dumpAll || model->rowCount(index) == 0) { // Dump if leaf item or dumpAll is true
|
||||
if (!model->header(index).isEmpty()) {
|
||||
file.setFileName(QObject::tr("%1/header.bin").arg(path));
|
||||
file.setFileName(path + UString("/header.bin"));
|
||||
if (!file.open(QFile::WriteOnly))
|
||||
return ERR_FILE_OPEN;
|
||||
return U_FILE_OPEN;
|
||||
|
||||
file.write(model->header(index));
|
||||
file.close();
|
||||
}
|
||||
|
||||
if (!model->body(index).isEmpty()) {
|
||||
file.setFileName(QObject::tr("%1/body.bin").arg(path));
|
||||
file.setFileName(path + UString("/body.bin"));
|
||||
if (!file.open(QFile::WriteOnly))
|
||||
return ERR_FILE_OPEN;
|
||||
return U_FILE_OPEN;
|
||||
|
||||
file.write(model->body(index));
|
||||
file.close();
|
||||
|
@ -71,14 +71,13 @@ STATUS FfsDumper::recursiveDump(const QModelIndex & index, const QString & path,
|
|||
}
|
||||
|
||||
// Always dump info
|
||||
QString info = QObject::tr("Type: %1\nSubtype: %2\n%3%4\n")
|
||||
.arg(itemTypeToQString(model->type(index)))
|
||||
.arg(itemSubtypeToQString(model->type(index), model->subtype(index)))
|
||||
.arg(model->text(index).isEmpty() ? QObject::tr("") : QObject::tr("Text: %1\n").arg(model->text(index)))
|
||||
.arg(model->info(index));
|
||||
file.setFileName(QObject::tr("%1/info.txt").arg(path));
|
||||
UString info = UString("Type: ") + itemTypeToUString(model->type(index)) + UString("\n")
|
||||
+ UString("Subtype: ") + itemSubtypeToUString(model->type(index), model->subtype(index)) + UString("\n")
|
||||
+ (model->text(index).isEmpty() ? UString("") : UString("Text: ") + model->text(index) + UString("\n"))
|
||||
+ model->info(index) + UString("\n");
|
||||
file.setFileName(path + UString("/info.txt"));
|
||||
if (!file.open(QFile::Text | QFile::WriteOnly))
|
||||
return ERR_FILE_OPEN;
|
||||
return U_FILE_OPEN;
|
||||
|
||||
file.write(info.toLatin1());
|
||||
file.close();
|
||||
|
@ -87,16 +86,16 @@ STATUS FfsDumper::recursiveDump(const QModelIndex & index, const QString & path,
|
|||
|
||||
UINT8 result;
|
||||
for (int i = 0; i < model->rowCount(index); i++) {
|
||||
QModelIndex childIndex = index.child(i, 0);
|
||||
UModelIndex childIndex = index.child(i, 0);
|
||||
bool useText = FALSE;
|
||||
if (model->type(childIndex) != Types::Volume)
|
||||
useText = !model->text(childIndex).isEmpty();
|
||||
|
||||
QString childPath = QString("%1/%2 %3").arg(path).arg(i).arg(useText ? model->text(childIndex) : model->name(childIndex));
|
||||
UString childPath = path + usprintf("/%u ", i) + (useText ? model->text(childIndex) : model->name(childIndex));
|
||||
result = recursiveDump(childIndex, childPath, dumpAll, guid);
|
||||
if (result)
|
||||
return result;
|
||||
}
|
||||
|
||||
return ERR_SUCCESS;
|
||||
return U_SUCCESS;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue