QDir documentation issue and missing feature

Report any problems with CopperSpice
Post Reply
seasoned_geek
Posts: 246
Joined: Thu Jun 11 2020 12:18 pm

QDir documentation issue and missing feature

Post by seasoned_geek »

https://www.copperspice.com/docs/cs_api/class_qdir.html#aa97a802699b83d42a60cc0a66e5faf58

filePath()
Returns the path name of a file in the directory. Does not check if the file actually exists in the directory; but see exists(). If the QDir is relative the returned path name will also be relative. Redundant multiple separators or "." and ".." directories in fileName are not removed (see cleanPath()).
Doesn't specifically say if the path is canonical or absolute. One has to infer from this

https://www.copperspice.com/docs/cs_api/class_qdir.html#ae25e9ecdcba02599aa1fdaa5e8599be0

absoluteFilePath()
Returns the absolute path name of a file in the directory. Does not check if the file actually exists in the directory; but see exists(). Redundant multiple separators or "." and ".." directories in fileName are not removed (see cleanPath()).
and this

https://www.copperspice.com/docs/cs_api/class_qdir.html#a77406c9757ae161332c2dc1640f0be64

canonicalPath()
Returns the canonical path, i.e. a path without symbolic links or redundant "." or ".." elements.

On systems that do not have symbolic links this function will always return the same string that absolutePath() returns. If the canonical path does not exist (normally due to dangling symbolic links) canonicalPath() returns an empty string.
Per the documentation, QDir does not appear to provide a canonicalFilePath( QString fileName) method, but it should, if for no other reason, consistency.

While I'm looking at it, there exists a toNativeSeparators( QString path) and a fromNativeSeparators( QString path) but no toCanonicalSeparators( QString path)


Yes, Qt 5.15.whatever doesn't have the ability to have QDir() generate a full canonical path name for a file and it has long been an issue. There is too much code around the world thumping in a "/" + fileName when the class should be able to do it just like it does for absolute.
Post Reply