| 2524 | } |
| 2525 | |
| 2526 | UINT8 FfsEngine::insert(const QModelIndex & index, const QByteArray & object, const UINT8 mode) |
| 2527 | { |
| 2528 | if (!index.isValid() || !index.parent().isValid()) |
| 2529 | return ERR_INVALID_PARAMETER; |
| 2530 | |
| 2531 | QModelIndex parent; |
| 2532 | if (mode == CREATE_MODE_BEFORE || mode == CREATE_MODE_AFTER) |
| 2533 | parent = index.parent(); |
| 2534 | else |
| 2535 | parent = index; |
| 2536 | |
| 2537 | // Determine type of item to insert |
| 2538 | UINT8 type; |
| 2539 | UINT32 headerSize; |
| 2540 | if (model->type(parent) == Types::Volume) { |
| 2541 | type = Types::File; |
| 2542 | headerSize = sizeof(EFI_FFS_FILE_HEADER); |
| 2543 | } |
| 2544 | else if (model->type(parent) == Types::File) { |
| 2545 | type = Types::Section; |
| 2546 | const EFI_COMMON_SECTION_HEADER* commonHeader = (const EFI_COMMON_SECTION_HEADER*)object.constData(); |
| 2547 | headerSize = sizeOfSectionHeader(commonHeader); |
| 2548 | } |
| 2549 | else if (model->type(parent) == Types::Section) { |
| 2550 | type = Types::Section; |
| 2551 | const EFI_COMMON_SECTION_HEADER* commonHeader = (const EFI_COMMON_SECTION_HEADER*)object.constData(); |
| 2552 | headerSize = sizeOfSectionHeader(commonHeader); |
| 2553 | } |
| 2554 | else |
| 2555 | return ERR_NOT_IMPLEMENTED; |
| 2556 | |
| 2557 | if ((UINT32)object.size() < headerSize) |
| 2558 | return ERR_BUFFER_TOO_SMALL; |
| 2559 | |
| 2560 | return create(index, type, object.left(headerSize), object.right(object.size() - headerSize), mode, Actions::Insert); |
| 2561 | } |
| 2562 | |
| 2563 | UINT8 FfsEngine::replace(const QModelIndex & index, const QByteArray & object, const UINT8 mode) |
| 2564 | { |
nothing calls this directly
no test coverage detected