rbutil: Move bootloader file check to base class.

Avoid constructing the bootloader file path in the caller. Pass filename
list and mountpoint separately so it can directly fall back to the
mountpoint.

Change some functions to use references instead of creating temporary
objects.

Change-Id: I09c9d755553a32de3d02a42a8ce1fcb94f831b2a
This commit is contained in:
Dominik Riebeling 2022-04-16 14:13:59 +02:00
parent 1af92e5ff8
commit 8c55ce62b9
4 changed files with 24 additions and 36 deletions

View file

@ -203,21 +203,28 @@ void BootloaderInstallBase::checkRemount()
//! @brief set list of possible bootloader files and pick the existing one.
//! @param sl list of possible bootloader files.
void BootloaderInstallBase::setBlFile(QStringList sl)
void BootloaderInstallBase::setBlFile(const QString& mountpoint, const QStringList& sl)
{
// figue which of the possible bootloader filenames is correct.
for(int a = 0; a < sl.size(); a++) {
if(!Utils::resolvePathCase(sl.at(a)).isEmpty()) {
m_blfile = sl.at(a);
}
if(sl.size() == 0) {
m_blfile = mountpoint;
}
if(m_blfile.isEmpty() && sl.size() > 0) {
m_blfile = sl.at(0);
else {
for(int a = 0; a < sl.size(); a++) {
QString filename = mountpoint + sl.at(a);
if(!Utils::resolvePathCase(filename).isEmpty()) {
m_blfile = filename;
break;
}
}
// figue which of the possible bootloader filenames is correct.
if(m_blfile.isEmpty() && sl.size() > 0) {
m_blfile = mountpoint + sl.at(0);
}
}
}
bool BootloaderInstallBase::setOfFile(QString of, QStringList blfile)
bool BootloaderInstallBase::setOfFile(QString& of, const QStringList& blfile)
{
bool found = false;
ArchiveUtil *util = nullptr;