Implement a function to resolve a given path case-insensitively. This is needed by file-based bootloader installs on case-sensitive systems. Bootloader installation not updated yet.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16921 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
0a73b16a93
commit
92717eb9ed
2 changed files with 34 additions and 0 deletions
|
@ -30,6 +30,7 @@
|
|||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#endif
|
||||
#include <QDebug>
|
||||
|
||||
// recursive function to delete a dir with files
|
||||
bool recRmdir( const QString &dirName )
|
||||
|
@ -54,6 +55,38 @@ bool recRmdir( const QString &dirName )
|
|||
}
|
||||
|
||||
|
||||
//! @brief resolves the given path, ignoring case.
|
||||
//! @param path absolute path to resolve.
|
||||
//! @return returns exact casing of path, empty string if path not found.
|
||||
QString resolvePathCase(QString path)
|
||||
{
|
||||
QStringList elems;
|
||||
QString realpath = "/";
|
||||
elems = path.split("/", QString::SkipEmptyParts);
|
||||
|
||||
for(int i = 0; i < elems.size(); i++) {
|
||||
QStringList direlems = QDir(realpath).entryList(QDir::AllEntries);
|
||||
if(direlems.contains(elems.at(i), Qt::CaseInsensitive)) {
|
||||
// need to filter using QRegExp as QStringList::filter(QString)
|
||||
// matches any substring
|
||||
QString expr = QString("^" + elems.at(i) + "$");
|
||||
QRegExp rx = QRegExp(expr, Qt::CaseInsensitive);
|
||||
QStringList a = direlems.filter(rx);
|
||||
|
||||
if(a.size() != 1)
|
||||
return QString("");
|
||||
if(!realpath.endsWith("/"))
|
||||
realpath += "/";
|
||||
realpath += a.at(0);
|
||||
}
|
||||
else
|
||||
return QString("");
|
||||
}
|
||||
qDebug() << __func__ << path << "->" << realpath;
|
||||
return realpath;
|
||||
}
|
||||
|
||||
|
||||
//! @brief get system proxy value.
|
||||
QUrl systemProxy(void)
|
||||
{
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include <QUrl>
|
||||
|
||||
bool recRmdir( const QString &dirName );
|
||||
QString resolvePathCase(QString path);
|
||||
|
||||
QUrl systemProxy(void);
|
||||
|
||||
|
|
Loading…
Reference in a new issue