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

Method insert

uefitool.cpp:250–303  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

248}
249
250void UEFITool::insert(const UINT8 mode)
251{
252 QModelIndex index = ui->structureTreeView->selectionModel()->currentIndex();
253 if (!index.isValid())
254 return;
255
256 TreeModel* model = ffsEngine->treeModel();
257 UINT8 type;
258
259 if (mode == CREATE_MODE_BEFORE || mode == CREATE_MODE_AFTER)
260 type = model->type(index.parent());
261 else
262 type = model->type(index);
263
264 QString path;
265 switch (type) {
266 case Types::Volume:
267 path = QFileDialog::getOpenFileName(this, tr("Select FFS file to insert"), currentDir, "FFS files (*.ffs *.bin);;All files (*)");
268 break;
269 case Types::File:
270 case Types::Section:
271 path = QFileDialog::getOpenFileName(this, tr("Select section file to insert"), currentDir, "Section files (*.sct *.bin);;All files (*)");
272 break;
273 default:
274 return;
275 }
276
277 if (path.trimmed().isEmpty())
278 return;
279
280 QFileInfo fileInfo = QFileInfo(path);
281 if (!fileInfo.exists()) {
282 ui->statusBar->showMessage(tr("Please select existing file"));
283 return;
284 }
285
286 QFile inputFile;
287 inputFile.setFileName(path);
288
289 if (!inputFile.open(QFile::ReadOnly)) {
290 QMessageBox::critical(this, tr("Insertion failed"), tr("Can't open output file for reading"), QMessageBox::Ok);
291 return;
292 }
293
294 QByteArray buffer = inputFile.readAll();
295 inputFile.close();
296
297 UINT8 result = ffsEngine->insert(index, buffer, mode);
298 if (result) {
299 QMessageBox::critical(this, tr("Insertion failed"), errorMessage(result), QMessageBox::Ok);
300 return;
301 }
302 ui->actionSaveImageFile->setEnabled(true);
303}
304
305void UEFITool::insertInto()
306{

Callers 2

insertChildBeforeMethod · 0.45
insertChildAfterMethod · 0.45

Calls 4

errorMessageFunction · 0.85
treeModelMethod · 0.80
typeMethod · 0.45
parentMethod · 0.45

Tested by

no test coverage detected