summaryrefslogtreecommitdiffstats
path: root/depends/util/src
diff options
context:
space:
mode:
Diffstat (limited to 'depends/util/src')
-rw-r--r--depends/util/src/cmdutils.cpp15
-rw-r--r--depends/util/src/pathutils.cpp24
2 files changed, 25 insertions, 14 deletions
diff --git a/depends/util/src/cmdutils.cpp b/depends/util/src/cmdutils.cpp
index 80ba719d..b9cab717 100644
--- a/depends/util/src/cmdutils.cpp
+++ b/depends/util/src/cmdutils.cpp
@@ -463,21 +463,8 @@ void Parser::getPrefix(QString &opt, QString &flag)
// ParsingError
ParsingError::ParsingError(const QString &what)
+:std::runtime_error(what.toStdString())
{
- m_what = what;
-}
-ParsingError::ParsingError(const ParsingError &e)
-{
- m_what = e.m_what;
-}
-
-const char *ParsingError::what() const throw()
-{
- return m_what.toLocal8Bit().constData();
-}
-QString ParsingError::qwhat() const
-{
- return m_what;
}
}
diff --git a/depends/util/src/pathutils.cpp b/depends/util/src/pathutils.cpp
index 4c24fa5d..590ac89d 100644
--- a/depends/util/src/pathutils.cpp
+++ b/depends/util/src/pathutils.cpp
@@ -39,6 +39,30 @@ QString AbsolutePath(QString path)
return QFileInfo(path).absolutePath();
}
+/**
+ * Normalize path
+ *
+ * Any paths inside the current directory will be normalized to relative paths (to current)
+ * Other paths will be made absolute
+ */
+QString NormalizePath(QString path)
+{
+ QDir a = QDir::currentPath();
+ QString currentAbsolute = a.absolutePath();
+
+ QDir b(path);
+ QString newAbsolute = b.absolutePath();
+
+ if (newAbsolute.startsWith(currentAbsolute))
+ {
+ return a.relativeFilePath(newAbsolute);
+ }
+ else
+ {
+ return newAbsolute;
+ }
+}
+
QString badFilenameChars = "\"\\/?<>:*|!";
QString RemoveInvalidFilenameChars(QString string, QChar replaceWith)