MCPcopy Create free account
hub / github.com/LongSoft/UEFITool / reconstructRegion

Method reconstructRegion

ffsengine.cpp:3237–3294  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3235}
3236
3237UINT8 FfsEngine::reconstructRegion(const QModelIndex& index, QByteArray& reconstructed, bool includeHeader)
3238{
3239 if (!index.isValid())
3240 return ERR_SUCCESS;
3241
3242 UINT8 result;
3243
3244 // No action
3245 if (model->action(index) == Actions::NoAction || model->action(index) == Actions::DoNotRebuild) {
3246 reconstructed = model->header(index).append(model->body(index));
3247 return ERR_SUCCESS;
3248 }
3249 else if (model->action(index) == Actions::Remove) {
3250 reconstructed.clear();
3251 return ERR_SUCCESS;
3252 }
3253 else if (model->action(index) == Actions::Rebuild ||
3254 model->action(index) == Actions::Replace) {
3255 if (model->rowCount(index)) {
3256 reconstructed.clear();
3257 // Reconstruct children
3258 for (int i = 0; i < model->rowCount(index); i++) {
3259 QByteArray child;
3260 result = reconstruct(index.child(i, 0), child);
3261 if (result)
3262 return result;
3263 reconstructed.append(child);
3264 }
3265 }
3266 // Use stored item body
3267 else
3268 reconstructed = model->body(index);
3269
3270 // Check size of reconstructed region, it must be same
3271 if (reconstructed.size() > model->body(index).size()) {
3272 msg(tr("reconstructRegion: reconstructed region size %1h (%2) is bigger then original %3h (%4)")
3273 .hexarg(reconstructed.size()).arg(reconstructed.size())
3274 .hexarg(model->body(index).size()).arg(model->body(index).size()),
3275 index);
3276 return ERR_INVALID_PARAMETER;
3277 }
3278 else if (reconstructed.size() < model->body(index).size()) {
3279 msg(tr("reconstructRegion: reconstructed region size %1h (%2) is smaller then original %3h (%4)")
3280 .hexarg(reconstructed.size()).arg(reconstructed.size())
3281 .hexarg(model->body(index).size()).arg(model->body(index).size()),
3282 index);
3283 return ERR_INVALID_PARAMETER;
3284 }
3285
3286 // Reconstruction successful
3287 if (includeHeader)
3288 reconstructed = model->header(index).append(reconstructed);
3289 return ERR_SUCCESS;
3290 }
3291
3292 // All other actions are not supported
3293 return ERR_NOT_IMPLEMENTED;
3294}

Callers

nothing calls this directly

Calls 5

rowCountMethod · 0.80
childMethod · 0.80
actionMethod · 0.45
headerMethod · 0.45
bodyMethod · 0.45

Tested by

no test coverage detected