summaryrefslogtreecommitdiffstats
path: root/src/corelib/io
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-03-07 14:20:48 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-03-07 19:13:14 +0000
commit0348ee90a8b250c32b18c15d320f6a42a1ec1bb5 (patch)
tree3b7048220874fc7eb7bff62d1ce31c70df76f9e2 /src/corelib/io
parent9fb73a01dd860a8a8e80945d5591a081256b14e0 (diff)
Make QDir::tempPath() canonical
To have a stable base for creating temporary files it's useful to have the temporary path be not just cleaned, but also the canonical path, so that any symlinks are resolved. This is e.g. the case on macOS, where /tmp is symlinked to /private/tmp. Fixes tests that compare paths, e.g: FAIL! : tst_QDir::current(startup) Compared values are not the same Actual (newCurrent.absolutePath()): "/private/var/folders/51/hhvngbjd36vbn1ncklb73g2h0000gn/T/tst_qdir-FACBOE" Expected (currentDir) : "/var/folders/51/hhvngbjd36vbn1ncklb73g2h0000gn/T/tst_qdir-FACBOE" [ChangeLog][QtCore] QDir::tempPath() now reports the canonical path of the temporary directory, with any symlinks removed. Change-Id: I20df9076c9869227f32740b196fd7ffb8b1b9ced Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io')
-rw-r--r--src/corelib/io/qdir.cpp4
-rw-r--r--src/corelib/io/qfilesystemengine_unix.cpp2
2 files changed, 3 insertions, 3 deletions
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 520f98b18f..d043b3aea5 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -2001,7 +2001,7 @@ QString QDir::homePath()
Returns the system's temporary directory.
- The directory is constructed using the absolute path of the temporary directory,
+ The directory is constructed using the absolute canonical path of the temporary directory,
ensuring that its path() will be the same as its absolutePath().
See tempPath() for details.
@@ -2010,7 +2010,7 @@ QString QDir::homePath()
*/
/*!
- Returns the absolute path of the system's temporary directory.
+ Returns the absolute canonical path of the system's temporary directory.
On Unix/Linux systems this is the path in the \c TMPDIR environment
variable or \c{/tmp} if \c TMPDIR is not defined. On Windows this is
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
index b974af80dc..2a42ad42f9 100644
--- a/src/corelib/io/qfilesystemengine_unix.cpp
+++ b/src/corelib/io/qfilesystemengine_unix.cpp
@@ -1523,7 +1523,7 @@ QString QFileSystemEngine::tempPath()
temp = QLatin1String(_PATH_TMP);
}
}
- return QDir::cleanPath(temp);
+ return QDir(QDir::cleanPath(temp)).canonicalPath();
#endif
}