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>
This commit is contained in:
parent
16b95b65a6
commit
35175b8fa5
@ -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()
|
||||
{
|
||||
@ -1836,6 +1838,16 @@ QChar QDir::separator()
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
\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
|
||||
|
@ -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()); }
|
||||
|
Loading…
Reference in New Issue
Block a user