diff options
Diffstat (limited to 'rbutil/rbutilqt/base/bootloaderinstallbase.cpp')
-rw-r--r-- | rbutil/rbutilqt/base/bootloaderinstallbase.cpp | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/base/bootloaderinstallbase.cpp b/rbutil/rbutilqt/base/bootloaderinstallbase.cpp index 750e33bef8..7941f24309 100644 --- a/rbutil/rbutilqt/base/bootloaderinstallbase.cpp +++ b/rbutil/rbutilqt/base/bootloaderinstallbase.cpp | |||
@@ -31,6 +31,7 @@ | |||
31 | #include "bootloaderinstallmpio.h" | 31 | #include "bootloaderinstallmpio.h" |
32 | #include "bootloaderinstallimx.h" | 32 | #include "bootloaderinstallimx.h" |
33 | #include "utils.h" | 33 | #include "utils.h" |
34 | #include "ziputil.h" | ||
34 | 35 | ||
35 | #if defined(Q_OS_MACX) | 36 | #if defined(Q_OS_MACX) |
36 | #include <sys/param.h> | 37 | #include <sys/param.h> |
@@ -320,3 +321,43 @@ void BootloaderInstallBase::setBlFile(QStringList sl) | |||
320 | } | 321 | } |
321 | } | 322 | } |
322 | 323 | ||
324 | bool BootloaderInstallBase::setOfFile(QString of, QStringList blfile) | ||
325 | { | ||
326 | bool found = false; | ||
327 | ZipUtil z(this); | ||
328 | // check if the file set is in zip format | ||
329 | if(z.open(of)) { | ||
330 | emit logItem(tr("Zip file format detected"), LOGINFO); | ||
331 | QStringList contents = z.files(); | ||
332 | qDebug() << "[BootloaderInstallBase] archive contains:" << contents; | ||
333 | for(int i = 0; i < blfile.size(); ++i) { | ||
334 | // strip any path, we don't know the structure in the zip | ||
335 | QString f = QFileInfo(blfile.at(i)).fileName(); | ||
336 | qDebug() << "[BootloaderInstallBase] searching archive for" << f; | ||
337 | int index = contents.indexOf(f); // FIXME: support files in folders | ||
338 | if(index >= 0) { | ||
339 | found = true; | ||
340 | emit logItem(tr("Extracting firmware %1 from archive") | ||
341 | .arg(f), LOGINFO); | ||
342 | // store in class temporary file | ||
343 | m_tempof.open(); | ||
344 | m_offile = m_tempof.fileName(); | ||
345 | m_tempof.close(); | ||
346 | if(!z.extractArchive(m_offile, contents.at(index))) { | ||
347 | emit logItem(tr("Error extracting firmware from archive"), LOGERROR); | ||
348 | found = false; | ||
349 | break; | ||
350 | } | ||
351 | } | ||
352 | } | ||
353 | if(!found) { | ||
354 | emit logItem(tr("Could not find firmware in archive"), LOGERROR); | ||
355 | } | ||
356 | |||
357 | } | ||
358 | else { | ||
359 | m_offile = of; | ||
360 | found = true; | ||
361 | } | ||
362 | return found; | ||
363 | } | ||