diff options
Diffstat (limited to 'rbutil/rbutilqt/base/bootloaderinstallbase.cpp')
-rw-r--r-- | rbutil/rbutilqt/base/bootloaderinstallbase.cpp | 37 |
1 files changed, 31 insertions, 6 deletions
diff --git a/rbutil/rbutilqt/base/bootloaderinstallbase.cpp b/rbutil/rbutilqt/base/bootloaderinstallbase.cpp index 6cfb2cd1c6..1a47f967b0 100644 --- a/rbutil/rbutilqt/base/bootloaderinstallbase.cpp +++ b/rbutil/rbutilqt/base/bootloaderinstallbase.cpp | |||
@@ -22,6 +22,7 @@ | |||
22 | #include "bootloaderinstallbase.h" | 22 | #include "bootloaderinstallbase.h" |
23 | #include "utils.h" | 23 | #include "utils.h" |
24 | #include "ziputil.h" | 24 | #include "ziputil.h" |
25 | #include "mspackutil.h" | ||
25 | 26 | ||
26 | #if defined(Q_OS_MACX) | 27 | #if defined(Q_OS_MACX) |
27 | #include <sys/param.h> | 28 | #include <sys/param.h> |
@@ -215,11 +216,34 @@ void BootloaderInstallBase::setBlFile(QStringList sl) | |||
215 | bool BootloaderInstallBase::setOfFile(QString of, QStringList blfile) | 216 | bool BootloaderInstallBase::setOfFile(QString of, QStringList blfile) |
216 | { | 217 | { |
217 | bool found = false; | 218 | bool found = false; |
218 | ZipUtil z(this); | 219 | ArchiveUtil *util = 0; |
219 | // check if the file set is in zip format | 220 | |
220 | if(z.open(of)) { | 221 | // try ZIP first |
222 | ZipUtil *zu = new ZipUtil(this); | ||
223 | if(zu->open(of)) | ||
224 | { | ||
221 | emit logItem(tr("Zip file format detected"), LOGINFO); | 225 | emit logItem(tr("Zip file format detected"), LOGINFO); |
222 | QStringList contents = z.files(); | 226 | util = zu; |
227 | } | ||
228 | else | ||
229 | delete zu; | ||
230 | |||
231 | // if ZIP failed, try CAB | ||
232 | if(util == 0) | ||
233 | { | ||
234 | MsPackUtil *msu = new MsPackUtil(this); | ||
235 | if(msu->open(of)) | ||
236 | { | ||
237 | emit logItem(tr("CAB file format detected"), LOGINFO); | ||
238 | util = msu; | ||
239 | } | ||
240 | else | ||
241 | delete msu; | ||
242 | } | ||
243 | |||
244 | // check if the file set is in zip format | ||
245 | if(util) { | ||
246 | QStringList contents = util->files(); | ||
223 | qDebug() << "[BootloaderInstallBase] archive contains:" << contents; | 247 | qDebug() << "[BootloaderInstallBase] archive contains:" << contents; |
224 | for(int i = 0; i < blfile.size(); ++i) { | 248 | for(int i = 0; i < blfile.size(); ++i) { |
225 | // strip any path, we don't know the structure in the zip | 249 | // strip any path, we don't know the structure in the zip |
@@ -237,7 +261,7 @@ bool BootloaderInstallBase::setOfFile(QString of, QStringList blfile) | |||
237 | m_tempof.open(); | 261 | m_tempof.open(); |
238 | m_offile = m_tempof.fileName(); | 262 | m_offile = m_tempof.fileName(); |
239 | m_tempof.close(); | 263 | m_tempof.close(); |
240 | if(!z.extractArchive(m_offile, contents.at(j))) { | 264 | if(!util->extractArchive(m_offile, contents.at(j))) { |
241 | emit logItem(tr("Error extracting firmware from archive"), LOGERROR); | 265 | emit logItem(tr("Error extracting firmware from archive"), LOGERROR); |
242 | found = false; | 266 | found = false; |
243 | break; | 267 | break; |
@@ -249,12 +273,13 @@ bool BootloaderInstallBase::setOfFile(QString of, QStringList blfile) | |||
249 | if(!found) { | 273 | if(!found) { |
250 | emit logItem(tr("Could not find firmware in archive"), LOGERROR); | 274 | emit logItem(tr("Could not find firmware in archive"), LOGERROR); |
251 | } | 275 | } |
252 | 276 | delete util; | |
253 | } | 277 | } |
254 | else { | 278 | else { |
255 | m_offile = of; | 279 | m_offile = of; |
256 | found = true; | 280 | found = true; |
257 | } | 281 | } |
282 | |||
258 | return found; | 283 | return found; |
259 | } | 284 | } |
260 | 285 | ||