| 4722 | } |
| 4723 | |
| 4724 | UINT8 FfsEngine::recursiveDump(const QModelIndex & index, const QString & path, const QString & guid) |
| 4725 | { |
| 4726 | if (!index.isValid()) |
| 4727 | return ERR_INVALID_PARAMETER; |
| 4728 | |
| 4729 | QDir dir; |
| 4730 | if (guid.isEmpty() || |
| 4731 | guidToQString(*(const EFI_GUID*)model->header(index).constData()) == guid || |
| 4732 | guidToQString(*(const EFI_GUID*)model->header(model->findParentOfType(index, Types::File)).constData()) == guid) { |
| 4733 | |
| 4734 | if (dir.cd(path)) |
| 4735 | return ERR_DIR_ALREADY_EXIST; |
| 4736 | |
| 4737 | if (!dir.mkpath(path)) |
| 4738 | return ERR_DIR_CREATE; |
| 4739 | |
| 4740 | QFile file; |
| 4741 | if (!model->header(index).isEmpty()) { |
| 4742 | file.setFileName(tr("%1/header.bin").arg(path)); |
| 4743 | if (!file.open(QFile::WriteOnly)) |
| 4744 | return ERR_FILE_OPEN; |
| 4745 | file.write(model->header(index)); |
| 4746 | file.close(); |
| 4747 | } |
| 4748 | |
| 4749 | if (!model->body(index).isEmpty()) { |
| 4750 | file.setFileName(tr("%1/body.bin").arg(path)); |
| 4751 | if (!file.open(QFile::WriteOnly)) |
| 4752 | return ERR_FILE_OPEN; |
| 4753 | file.write(model->body(index)); |
| 4754 | file.close(); |
| 4755 | } |
| 4756 | |
| 4757 | QString info = tr("Type: %1\nSubtype: %2\n%3%4") |
| 4758 | .arg(itemTypeToQString(model->type(index))) |
| 4759 | .arg(itemSubtypeToQString(model->type(index), model->subtype(index))) |
| 4760 | .arg(model->text(index).isEmpty() ? "" : tr("Text: %1\n").arg(model->text(index))) |
| 4761 | .arg(model->info(index)); |
| 4762 | file.setFileName(tr("%1/info.txt").arg(path)); |
| 4763 | if (!file.open(QFile::Text | QFile::WriteOnly)) |
| 4764 | return ERR_FILE_OPEN; |
| 4765 | file.write(info.toLatin1()); |
| 4766 | file.close(); |
| 4767 | dumped = true; |
| 4768 | } |
| 4769 | |
| 4770 | UINT8 result; |
| 4771 | for (int i = 0; i < model->rowCount(index); i++) { |
| 4772 | QModelIndex childIndex = index.child(i, 0); |
| 4773 | QString childPath = QString("%1/%2 %3").arg(path).arg(i).arg(model->text(childIndex).isEmpty() ? model->name(childIndex) : model->text(childIndex)); |
| 4774 | result = recursiveDump(childIndex, childPath, guid); |
| 4775 | if (result) |
| 4776 | return result; |
| 4777 | } |
| 4778 | |
| 4779 | return ERR_SUCCESS; |
| 4780 | } |
| 4781 |
nothing calls this directly
no test coverage detected