diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2020-02-07 14:03:43 +0100 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2020-03-24 16:20:03 +0100 |
commit | 737fe89691a3d8dfa779862c9daaa002e00f3dca (patch) | |
tree | df7498f54d2a5d57ff5de93bd8630fe2b3ecaa3a /src/corelib/io/qdir.cpp | |
parent | c4ef0b92d5fb2c621e880347bd48d01b6f31eb24 (diff) |
Q{File,FileInfo,Dir}: add std::filesystem::path overloads
Add some overloads where (I thought) it makes sense for QDir and QFile
to accept std::filesystem::path objects. Currently my thinking is to
not add overloads for static functions where std::filesystem can already
do the same job, e.g. create directory or file.
Template and enable_if is needed due to both QString and
std::filesystem::path being able to be constructed from string literals.
The common shared code is currently in QFile because QDir had an
implicit include of QFile, made explicit in this patch, and QFileInfo
has an include to QFile as well.
The QT_HAS_STD_FILESYSTEM macro is visible in user-code which I
currently take advantage of in the tests, and users could too.
Change-Id: I8d05d3c34c6c17e20972a6a2053862b8891d6c3c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qdir.cpp')
-rw-r--r-- | src/corelib/io/qdir.cpp | 65 |
1 files changed, 63 insertions, 2 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 5ce3fbcca8..20af40f973 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -585,8 +585,8 @@ QDir::QDir(const QString &path) : d_ptr(new QDirPrivate(path)) also sorts the names using \a sort. The default \a nameFilter is an empty string, which excludes - nothing; the default \a filters is \l AllEntries, which also means - exclude nothing. The default \a sort is \l Name | \l IgnoreCase, + nothing; the default \a filters is \l AllEntries, which also + excludes nothing. The default \a sort is \l Name | \l IgnoreCase, i.e. sort by name case-insensitively. If \a path is an empty string, QDir uses "." (the current @@ -2551,4 +2551,65 @@ QDebug operator<<(QDebug debug, const QDir &dir) } #endif // QT_NO_DEBUG_STREAM +/*! + \fn QDir::QDir(const std::filesystem::path &path) + \since 6.0 + Constructs a QDir pointing to the given directory \a path. If path + is empty the program's working directory, ("."), is used. + + \sa currentPath() +*/ +/*! + \fn QDir::QDir(const std::filesystem::path &path, + const QString &nameFilter, + SortFlags sort, + Filters filters) + \since 6.0 + + Constructs a QDir with path \a path, that filters its entries by + name using \a nameFilter and by attributes using \a filters. It + also sorts the names using \a sort. + + The default \a nameFilter is an empty string, which excludes + nothing; the default \a filters is \l AllEntries, which also + excludes nothing. The default \a sort is \l Name | \l IgnoreCase, + i.e. sort by name case-insensitively. + + If \a path is empty, QDir uses "." (the current + directory). If \a nameFilter is an empty string, QDir uses the + name filter "*" (all files). + + Note that \a path need not exist. + + \sa exists(), setPath(), setNameFilters(), setFilter(), setSorting() +*/ +/*! + \fn void QDir::setPath(const std::filesystem::path &path) + \since 6.0 + \overload +*/ +/*! + \fn void QDir::addSearchPath(const QString &prefix, const std::filesystem::path &path) + \since 6.0 + \overload +*/ +/*! + \fn std::filesystem::path QDir::filesystemPath() const + \since 6.0 + Returns path() as \c{std::filesystem::path}. + \sa path() +*/ +/*! + \fn std::filesystem::path QDir::filesystemAbsolutePath() const + \since 6.0 + Returns absolutePath() as \c{std::filesystem::path}. + \sa absolutePath() +*/ +/*! + \fn std::filesystem::path QDir::filesystemCanonicalPath() const + \since 6.0 + Returns canonicalPath() as \c{std::filesystem::path}. + \sa canonicalPath() +*/ + QT_END_NAMESPACE |