diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2012-01-15 23:20:17 +0100 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2012-01-15 23:32:15 +0100 |
commit | b45cc0a13a20e88546cd7a536f09979edf8353a1 (patch) | |
tree | 1189e5a6381c7f4a8ac770bafbb9a21f49d5e930 /rbutil/rbutilqt/base/bootloaderinstallbase.cpp | |
parent | 66c3086ae54c71413117f3de3dcfb5f0fe8b541d (diff) | |
download | rockbox-b45cc0a13a20e88546cd7a536f09979edf8353a1.tar.gz rockbox-b45cc0a13a20e88546cd7a536f09979edf8353a1.zip |
Support reading OF files from zip.
Several devices require the original firmware to be able installing the
bootloader. Most vendors distribute the firmware file in zip format. Extend
reading the original firmware file to support reading the file from the zip
directly instead of requiring the user to separately extract it.
Change-Id: Ic4e89053456d8f7d6adc294f6657aceddbc354ba
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 | } | ||