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

Method create

ffsengine.cpp:2200–2476  ·  view source on GitHub ↗

Operations on tree items

Source from the content-addressed store, hash-verified

2198
2199// Operations on tree items
2200UINT8 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);

Callers

nothing calls this directly

Calls 13

uint32ToUint24Function · 0.85
calculateSum8Function · 0.85
calculateChecksum8Function · 0.85
uint24ToUint32Function · 0.85
addItemMethod · 0.80
findParentOfTypeMethod · 0.80
parentMethod · 0.45
subtypeMethod · 0.45
setActionMethod · 0.45
bodyMethod · 0.45
headerMethod · 0.45
typeMethod · 0.45

Tested by

no test coverage detected