| 202 | } |
| 203 | |
| 204 | UINT8 UEFIPatch::patchFile(const QModelIndex & index, const QByteArray & fileGuid, const UINT8 sectionType, const QVector<PatchData> & patches) |
| 205 | { |
| 206 | |
| 207 | if (!model || !index.isValid()) |
| 208 | return ERR_INVALID_PARAMETER; |
| 209 | if (model->type(index) == Types::Section && model->subtype(index) == sectionType) { |
| 210 | QModelIndex fileIndex = model->findParentOfType(index, Types::File); |
| 211 | if (model->type(fileIndex) == Types::File && |
| 212 | model->header(fileIndex).left(sizeof(EFI_GUID)) == fileGuid) |
| 213 | { |
| 214 | return ffsEngine->patch(index, patches); |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | if (model->rowCount(index) > 0) { |
| 219 | for (int i = 0; i < model->rowCount(index); i++) { |
| 220 | UINT8 result = patchFile(index.child(i, 0), fileGuid, sectionType, patches); |
| 221 | if (!result) |
| 222 | break; |
| 223 | else if (result != ERR_NOTHING_TO_PATCH) |
| 224 | return result; |
| 225 | } |
| 226 | } |
| 227 | |
| 228 | return ERR_NOTHING_TO_PATCH; |
| 229 | } |