void BootloaderInstallMi4::installStage2(void) { emit logItem(tr("Installing Rockbox bootloader"), LOGINFO); QCoreApplication::processEvents(); // move old bootloader out of the way QString fwfile(resolvePathCase(m_blfile)); QFile oldbl(fwfile); QString moved = QFileInfo(resolvePathCase(m_blfile)).absolutePath() + "/OF.mi4"; if(!QFileInfo(moved).exists()) { qDebug() << "[BootloaderInstallMi4] renaming" << fwfile << "to" << moved; oldbl.rename(moved); } else { qDebug() << "[BootloaderInstallMi4] OF.mi4 already present, not renaming again."; oldbl.remove(); } // place new bootloader m_tempfile.open(); qDebug() << "[BootloaderInstallMi4] renaming" << m_tempfile.fileName() << "to" << fwfile; m_tempfile.close(); m_tempfile.rename(fwfile); emit logItem(tr("Bootloader successful installed"), LOGOK); logInstall(LogAdd); emit done(false); }
void BootloaderInstallFile::installStage2(void) { emit logItem(tr("Installing Rockbox bootloader"), LOGINFO); QCoreApplication::processEvents(); // if an old bootloader is present (Gigabeat) move it out of the way. QString fwfile(Utils::resolvePathCase(m_blfile)); if(!fwfile.isEmpty()) { QString moved = Utils::resolvePathCase(m_blfile) + ".ORIG"; qDebug() << "[BootloaderInstallFile] renaming" << fwfile << "to" << moved; QFile::rename(fwfile, moved); } // if no old file found resolve path without basename QFileInfo fi(m_blfile); QString absPath = Utils::resolvePathCase(fi.absolutePath()); // if it's not possible to locate the base path try to create it if(absPath.isEmpty()) { QStringList pathElements = m_blfile.split("/"); // remove filename from list and save last path element pathElements.removeLast(); QString lastElement = pathElements.last(); // remove last path element for base pathElements.removeLast(); QString basePath = pathElements.join("/"); // check for base and bail out if not found. Otherwise create folder. absPath = Utils::resolvePathCase(basePath); QDir d(absPath); d.mkpath(lastElement); absPath = Utils::resolvePathCase(fi.absolutePath()); if(absPath.isEmpty()) { emit logItem(tr("Error accessing output folder"), LOGERROR); emit done(true); return; } } fwfile = absPath + "/" + fi.fileName(); // place (new) bootloader m_tempfile.open(); qDebug() << "[BootloaderInstallFile] renaming" << m_tempfile.fileName() << "to" << fwfile; m_tempfile.close(); m_tempfile.copy(fwfile); emit logItem(tr("Bootloader successful installed"), LOGOK); logInstall(LogAdd); emit done(false); }
void BootloaderInstallMi4::installStage2(void) { emit logItem(tr("Installing Rockbox bootloader"), LOGINFO); QCoreApplication::processEvents(); // move old bootloader out of the way QString fwfile(Utils::resolvePathCase(m_blfile)); QFile oldbl(fwfile); QString moved = QFileInfo(Utils::resolvePathCase(m_blfile)).absolutePath() + "/OF.mi4"; if(!QFileInfo(moved).exists()) { LOG_INFO() << "renaming" << fwfile << "to" << moved; oldbl.rename(moved); } else { LOG_INFO() << "OF.mi4 already present, not renaming again."; oldbl.remove(); } // place new bootloader m_tempfile.open(); LOG_INFO() << "renaming" << m_tempfile.fileName() << "to" << fwfile; m_tempfile.close(); if(!Utils::resolvePathCase(fwfile).isEmpty()) { emit logItem(tr("A firmware file is already present on player"), LOGERROR); emit done(true); return; } if(m_tempfile.copy(fwfile)) { emit logItem(tr("Bootloader successful installed"), LOGOK); } else { emit logItem(tr("Copying modified firmware file failed"), LOGERROR); emit done(true); return; } emit logItem(tr("Bootloader successful installed"), LOGOK); logInstall(LogAdd); emit done(false); }