From ccc43a00486f49b51a76c5a58fe0c7db07ec272d Mon Sep 17 00:00:00 2001 From: Hamatoma Date: Sun, 20 Dec 2015 08:50:33 +0100 Subject: [PATCH] ReFind: native path --- appl/refind/filefinder.cpp | 4 +++- appl/refind/mainwindow.cpp | 4 ++-- base/ReFileUtils.hpp | 26 ++++++++++++++++++++++++++ 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/appl/refind/filefinder.cpp b/appl/refind/filefinder.cpp index 330d0ec..2869c34 100644 --- a/appl/refind/filefinder.cpp +++ b/appl/refind/filefinder.cpp @@ -193,7 +193,9 @@ void FileFinder::search(){ } clock_t start = clock(); m_table->setSortingEnabled(false); - fillTable(ReQStringUtils::chomp(m_baseDir, OS_SEPARATOR), 0); + QString path = ReFileUtils::nativePath(m_baseDir); + path = ReQStringUtils::chomp(path, OS_SEPARATOR); + fillTable(path, 0); m_statistics.m_runtimeSeconds = (double) (clock() - start) / CLOCKS_PER_SEC; if (m_announcer != NULL){ diff --git a/appl/refind/mainwindow.cpp b/appl/refind/mainwindow.cpp index 1785a97..b911aa5 100644 --- a/appl/refind/mainwindow.cpp +++ b/appl/refind/mainwindow.cpp @@ -864,7 +864,7 @@ void MainWindow::selectDirectory(){ QString dir = QFileDialog::getExistingDirectory(this, tr("Select Directory"), ui->comboBoxDirectory->currentText(), QFileDialog::ShowDirsOnly); if (!dir.isEmpty()) - ui->comboBoxDirectory->setCurrentText(dir); + ui->comboBoxDirectory->setCurrentText(ReFileUtils::nativePath(dir)); } /** @@ -907,7 +907,7 @@ QDir dir(path); if (dir.exists()){ dir.cdUp(); if (dir.exists()){ - path = dir.absolutePath(); + path = ReFileUtils::nativePath(dir.absolutePath()); ui->comboBoxDirectory->setEditText(path); setInHistory(ui->comboBoxDirectory, path); } diff --git a/base/ReFileUtils.hpp b/base/ReFileUtils.hpp index dec87d8..44251da 100644 --- a/base/ReFileUtils.hpp +++ b/base/ReFileUtils.hpp @@ -36,6 +36,32 @@ public: static QByteArray extensionOf(const char* filename); static bool isAbsolutPath(const QString& path); static bool isAbsolutPath(const char* path); + /** Returns a path with native separators. + * QT under windows can operator with 2 separators: '\\' and '/'. + * '\\' is the native separator. + * @param path the path to inspect + * @return the path with native separators. + */ + inline static QString nativePath(QString path){ +#if defined __linux__ + return path; +#elif defined WIN32 + return path.replace(OS_2nd_SEPARATOR, OS_SEPARATOR); +#endif + } + /** Returns a path with native separators. + * QT under windows can operator with 2 separators: '\\' and '/'. + * '\\' is the native separator. + * @param path the path to inspect + * @return the path with native separators. + */ + inline static QByteArray nativePath(QByteArray path){ +#if defined __linux__ + return path; +#elif defined WIN32 + return path.replace(OS_2nd_SEPARATOR, OS_SEPARATOR); +#endif + } static QString nodeOf(const QString& filename); static QByteArray nodeOf(const char* filename); static QString parentOf(const QString& filename); -- 2.39.5