mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-11-13 15:12:30 -05:00
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
This commit is contained in:
parent
66c3086ae5
commit
b45cc0a13a
5 changed files with 84 additions and 16 deletions
|
|
@ -31,6 +31,7 @@
|
|||
#include "bootloaderinstallmpio.h"
|
||||
#include "bootloaderinstallimx.h"
|
||||
#include "utils.h"
|
||||
#include "ziputil.h"
|
||||
|
||||
#if defined(Q_OS_MACX)
|
||||
#include <sys/param.h>
|
||||
|
|
@ -320,3 +321,43 @@ void BootloaderInstallBase::setBlFile(QStringList sl)
|
|||
}
|
||||
}
|
||||
|
||||
bool BootloaderInstallBase::setOfFile(QString of, QStringList blfile)
|
||||
{
|
||||
bool found = false;
|
||||
ZipUtil z(this);
|
||||
// check if the file set is in zip format
|
||||
if(z.open(of)) {
|
||||
emit logItem(tr("Zip file format detected"), LOGINFO);
|
||||
QStringList contents = z.files();
|
||||
qDebug() << "[BootloaderInstallBase] archive contains:" << contents;
|
||||
for(int i = 0; i < blfile.size(); ++i) {
|
||||
// strip any path, we don't know the structure in the zip
|
||||
QString f = QFileInfo(blfile.at(i)).fileName();
|
||||
qDebug() << "[BootloaderInstallBase] searching archive for" << f;
|
||||
int index = contents.indexOf(f); // FIXME: support files in folders
|
||||
if(index >= 0) {
|
||||
found = true;
|
||||
emit logItem(tr("Extracting firmware %1 from archive")
|
||||
.arg(f), LOGINFO);
|
||||
// store in class temporary file
|
||||
m_tempof.open();
|
||||
m_offile = m_tempof.fileName();
|
||||
m_tempof.close();
|
||||
if(!z.extractArchive(m_offile, contents.at(index))) {
|
||||
emit logItem(tr("Error extracting firmware from archive"), LOGERROR);
|
||||
found = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!found) {
|
||||
emit logItem(tr("Could not find firmware in archive"), LOGERROR);
|
||||
}
|
||||
|
||||
}
|
||||
else {
|
||||
m_offile = of;
|
||||
found = true;
|
||||
}
|
||||
return found;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue