summaryrefslogtreecommitdiffstats
path: root/qmake/library/ioutils.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@qt.io>2017-03-01 12:41:48 +0100
committerSimon Hausmann <simon.hausmann@qt.io>2017-05-02 10:27:15 +0000
commitc12b96daf2195c475c086f8f9be833aa0e28b26c (patch)
treed5a85c3935d63f7663fc0e55c804e932e2063b40 /qmake/library/ioutils.cpp
parent7eae7e8103c79c9e098fc112bb8157971117678d (diff)
Preserve last modification timestamps of installed directories
Similar to the two parent commits, this patchs preserves the time stamps of files we install as a result of recursive directory copying. Change-Id: Id5931a467196d5cd67acfa0deffc2488af8a3669 Task-number: QTBUG-59004 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
Diffstat (limited to 'qmake/library/ioutils.cpp')
-rw-r--r--qmake/library/ioutils.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/qmake/library/ioutils.cpp b/qmake/library/ioutils.cpp
index 39264952c6..684bcb9a37 100644
--- a/qmake/library/ioutils.cpp
+++ b/qmake/library/ioutils.cpp
@@ -253,4 +253,39 @@ bool IoUtils::touchFile(const QString &targetFileName, const QString &referenceF
}
#endif
+#ifdef Q_OS_UNIX
+bool IoUtils::readLinkTarget(const QString &symlinkPath, QString *target)
+{
+ const QByteArray localSymlinkPath = QFile::encodeName(symlinkPath);
+# if defined(__GLIBC__) && !defined(PATH_MAX)
+# define PATH_CHUNK_SIZE 256
+ char *s = 0;
+ int len = -1;
+ int size = PATH_CHUNK_SIZE;
+
+ forever {
+ s = (char *)::realloc(s, size);
+ len = ::readlink(localSymlinkPath.constData(), s, size);
+ if (len < 0) {
+ ::free(s);
+ break;
+ }
+ if (len < size)
+ break;
+ size *= 2;
+ }
+# else
+ char s[PATH_MAX+1];
+ int len = readlink(localSymlinkPath.constData(), s, PATH_MAX);
+# endif
+ if (len <= 0)
+ return false;
+ *target = QFile::decodeName(QByteArray(s, len));
+# if defined(__GLIBC__) && !defined(PATH_MAX)
+ ::free(s);
+# endif
+ return true;
+}
+#endif
+
QT_END_NAMESPACE