summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorSérgio Martins <sergio.martins@kdab.com>2015-05-15 20:03:18 +0100
committerSérgio Martins <sergio.martins@kdab.com>2015-05-27 08:07:09 +0000
commit35175b8fa5f8be93b147f57a247b8e52f28ee8cb (patch)
tree8f2d6409c195eeb37bef527ddaf4800d233c2bff /src/corelib
parent16b95b65a6fea501dade6e3f5f1ad48f7dfaa173 (diff)
Introduce QDir::listSeparator()
Qt should help abstract such platform differences. This ifdef is proliferating in user code (seen a few times in KDE) and even in Qt code (qstandardpaths.cpp). [ChangeLog][QtCore][QDir] Added listSeparator(). Change-Id: Icad082a51c8efd5d63f7af9bbaedbe4bc15b8937 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: Marc Mutz <marc.mutz@kdab.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qdir.cpp12
-rw-r--r--src/corelib/io/qdir.h11
2 files changed, 22 insertions, 1 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 9b1ec3917a..8b3dd5d82f 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -1826,6 +1826,8 @@ QFileInfoList QDir::drives()
underlying operating system. If you want to display paths to the
user using their operating system's separator use
toNativeSeparators().
+
+ \sa listSeparator()
*/
QChar QDir::separator()
{
@@ -1837,6 +1839,16 @@ QChar QDir::separator()
}
/*!
+ \fn QDir::listSeparator()
+ \since 5.6
+
+ Returns the native path list separator: ':' under Unix
+ and ';' under Windows.
+
+ \sa separator()
+*/
+
+/*!
Sets the application's current working directory to \a path.
Returns \c true if the directory was successfully changed; otherwise
returns \c false.
diff --git a/src/corelib/io/qdir.h b/src/corelib/io/qdir.h
index e622011f98..b6946eba65 100644
--- a/src/corelib/io/qdir.h
+++ b/src/corelib/io/qdir.h
@@ -177,7 +177,16 @@ public:
static QFileInfoList drives();
- static QChar separator();
+ Q_DECL_CONSTEXPR static inline QChar listSeparator() Q_DECL_NOTHROW
+ {
+#if defined(Q_OS_WIN)
+ return QLatin1Char(';');
+#else
+ return QLatin1Char(':');
+#endif
+ }
+
+ static QChar separator(); // ### Qt6: Make it inline
static bool setCurrent(const QString &path);
static inline QDir current() { return QDir(currentPath()); }