diff options
author | hjk <[email protected]> | 2021-07-14 07:41:23 +0200 |
---|---|---|
committer | hjk <[email protected]> | 2021-07-14 08:16:57 +0000 |
commit | e8521e6fe11f59d0fc816d8b7fa6780dc6469af6 (patch) | |
tree | 348e5104bcbb4fb0c9d2269f8dc49e549dc2f20a /src/libs/utils/fileutils.cpp | |
parent | 55082986e11b3ef7ee57befd171448fbd65d5c8b (diff) |
Utils: Add/fix FilePath::isFile and FilePath::isDir
In general, the more specific isReadableFile etc are preferred, but for
porting a 1:1 match to QFileInfo functionality is helpful.
Change-Id: I5b575ca9a5053f13f63c0fbe0e3dcc222494280f
Reviewed-by: David Schulz <[email protected]>
Diffstat (limited to 'src/libs/utils/fileutils.cpp')
-rw-r--r-- | src/libs/utils/fileutils.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/libs/utils/fileutils.cpp b/src/libs/utils/fileutils.cpp index 95e935272c3..ca397b0c0d4 100644 --- a/src/libs/utils/fileutils.cpp +++ b/src/libs/utils/fileutils.cpp @@ -939,6 +939,26 @@ bool FilePath::isReadableDir() const return fi.exists() && fi.isReadable() && fi.isDir(); } +bool FilePath::isFile() const +{ + if (needsDevice()) { + QTC_ASSERT(s_deviceHooks.isFile, return false); + return s_deviceHooks.isFile(*this); + } + const QFileInfo fi{m_data}; + return fi.exists() && fi.isFile(); +} + +bool FilePath::isDir() const +{ + if (needsDevice()) { + QTC_ASSERT(s_deviceHooks.isDir, return false); + return s_deviceHooks.isDir(*this); + } + const QFileInfo fi{m_data}; + return fi.exists() && fi.isDir(); +} + bool FilePath::createDir() const { if (needsDevice()) { @@ -1244,12 +1264,6 @@ bool FilePath::endsWith(const QString &s) const return m_data.endsWith(s, caseSensitivity()); } -bool FilePath::isDir() const -{ - QTC_CHECK(m_scheme.isEmpty()); // FIXME: Not implemented yet. - return QFileInfo(m_data).isDir(); -} - /// \returns the relativeChildPath of FilePath to parent if FilePath is a child of parent /// \note returns a empty FilePath if FilePath is not a child of parent /// That is, this never returns a path starting with "../" |