Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
None
-
6.4
-
None
Description
When working with QFileInfo, a trailing separator in a path seems to affect `canonicalPath` and `absolutePath` differently.
For example, consider some path `/home/luca/`, with a trailing separator.
The following call will result in the string `/home`:
QFileInfo("/home/luca/").canonicalPath()
While the following call will result in the string `/home/luca`:
QFileInfo("/home/luca/").absolutePath()
Standing by the documentation, `canonicalPath`:
Returns the file's path canonical path (excluding the file name), i.e. an absolute path without symbolic links or redundant "." or ".." elements.
And `absolutePath`:
Returns a file's path absolute path. This doesn't include the file name.[...]In contrast to canonicalPath() symbolic links or redundant "." or ".." elements are not necessarily removed
I would generally expect those two methods to behave equally unless symbolic links or relative path elements such as ".." are present.
Furthermore, considering the documentation for `path`:
[...]Note that, if this QFileInfo object is given a path ending in a slash, the name of the file is considered empty and this function will return the entire path.
I would expect the behavior that `canonicalPath` shows might be a bug as it is inconsistent with how other method in the same API treat trailing separators, while the one that `absolutePath` shows is the intended one.
Attachments
Issue Links
- resulted from
-
QTBUG-19995 [REG] QDir::absolutePath() and QFileInfo::absolute(File)Path() do not remove redundant "." and ".."
-
- Closed
-
Gerrit Reviews
For Gerrit Dashboard: QTBUG-100682 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
395215,1 | QFileInfo: make canonical and absolute paths agree on paths ending in / | dev | qt/qtbase | Status: NEW | 0 | 0 |