summaryrefslogtreecommitdiff
path: root/rbutil/rbutilqt/utils.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'rbutil/rbutilqt/utils.cpp')
-rw-r--r--rbutil/rbutilqt/utils.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/rbutil/rbutilqt/utils.cpp b/rbutil/rbutilqt/utils.cpp
index caeb30a4b5..d77a1ac125 100644
--- a/rbutil/rbutilqt/utils.cpp
+++ b/rbutil/rbutilqt/utils.cpp
@@ -30,6 +30,7 @@
30#include <windows.h> 30#include <windows.h>
31#include <tchar.h> 31#include <tchar.h>
32#endif 32#endif
33#include <QDebug>
33 34
34// recursive function to delete a dir with files 35// recursive function to delete a dir with files
35bool recRmdir( const QString &dirName ) 36bool recRmdir( const QString &dirName )
@@ -54,6 +55,38 @@ bool recRmdir( const QString &dirName )
54} 55}
55 56
56 57
58//! @brief resolves the given path, ignoring case.
59//! @param path absolute path to resolve.
60//! @return returns exact casing of path, empty string if path not found.
61QString resolvePathCase(QString path)
62{
63 QStringList elems;
64 QString realpath = "/";
65 elems = path.split("/", QString::SkipEmptyParts);
66
67 for(int i = 0; i < elems.size(); i++) {
68 QStringList direlems = QDir(realpath).entryList(QDir::AllEntries);
69 if(direlems.contains(elems.at(i), Qt::CaseInsensitive)) {
70 // need to filter using QRegExp as QStringList::filter(QString)
71 // matches any substring
72 QString expr = QString("^" + elems.at(i) + "$");
73 QRegExp rx = QRegExp(expr, Qt::CaseInsensitive);
74 QStringList a = direlems.filter(rx);
75
76 if(a.size() != 1)
77 return QString("");
78 if(!realpath.endsWith("/"))
79 realpath += "/";
80 realpath += a.at(0);
81 }
82 else
83 return QString("");
84 }
85 qDebug() << __func__ << path << "->" << realpath;
86 return realpath;
87}
88
89
57//! @brief get system proxy value. 90//! @brief get system proxy value.
58QUrl systemProxy(void) 91QUrl systemProxy(void)
59{ 92{