Operations on tree items
| 2198 | |
| 2199 | // Operations on tree items |
| 2200 | UINT8 FfsEngine::create(const QModelIndex & index, const UINT8 type, const QByteArray & header, const QByteArray & body, const UINT8 mode, const UINT8 action, const UINT8 algorithm) |
| 2201 | { |
| 2202 | QByteArray created; |
| 2203 | UINT8 result; |
| 2204 | QModelIndex fileIndex; |
| 2205 | UINT32 defaultDictionarySize = DEFAULT_LZMA_DICTIONARY_SIZE; |
| 2206 | |
| 2207 | if (!index.isValid() || !index.parent().isValid()) |
| 2208 | return ERR_INVALID_PARAMETER; |
| 2209 | |
| 2210 | QModelIndex parent; |
| 2211 | if (mode == CREATE_MODE_BEFORE || mode == CREATE_MODE_AFTER) |
| 2212 | parent = index.parent(); |
| 2213 | else |
| 2214 | parent = index; |
| 2215 | |
| 2216 | // Create item |
| 2217 | if (type == Types::Region) { |
| 2218 | UINT8 type = model->subtype(index); |
| 2219 | switch (type) { |
| 2220 | case Subtypes::BiosRegion: |
| 2221 | result = parseBiosRegion(body, fileIndex, index, mode); |
| 2222 | break; |
| 2223 | case Subtypes::MeRegion: |
| 2224 | result = parseMeRegion(body, fileIndex, index, mode); |
| 2225 | break; |
| 2226 | case Subtypes::GbeRegion: |
| 2227 | result = parseGbeRegion(body, fileIndex, index, mode); |
| 2228 | break; |
| 2229 | case Subtypes::PdrRegion: |
| 2230 | result = parsePdrRegion(body, fileIndex, index, mode); |
| 2231 | break; |
| 2232 | default: |
| 2233 | return ERR_NOT_IMPLEMENTED; |
| 2234 | } |
| 2235 | |
| 2236 | if (result && result != ERR_VOLUMES_NOT_FOUND && result != ERR_INVALID_VOLUME) |
| 2237 | return result; |
| 2238 | |
| 2239 | // Set action |
| 2240 | model->setAction(fileIndex, action); |
| 2241 | } |
| 2242 | else if (type == Types::Padding) { |
| 2243 | // Get info |
| 2244 | QString name = tr("Padding"); |
| 2245 | QString info = tr("Full size: %1h (%2)") |
| 2246 | .hexarg(body.size()).arg(body.size()); |
| 2247 | |
| 2248 | // Add tree item |
| 2249 | QModelIndex fileIndex = model->addItem(Types::Padding, getPaddingType(body), COMPRESSION_ALGORITHM_NONE, name, "", info, QByteArray(), body, index, mode); |
| 2250 | |
| 2251 | // Set action |
| 2252 | model->setAction(fileIndex, action); |
| 2253 | } |
| 2254 | else if (type == Types::Volume) { |
| 2255 | QByteArray volume; |
| 2256 | if (header.isEmpty()) // Whole volume |
| 2257 | volume.append(body); |
nothing calls this directly
no test coverage detected