diff options
author | Simon Hausmann <simon.hausmann@qt.io> | 2017-03-01 12:41:48 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@qt.io> | 2017-05-02 10:27:15 +0000 |
commit | c12b96daf2195c475c086f8f9be833aa0e28b26c (patch) | |
tree | d5a85c3935d63f7663fc0e55c804e932e2063b40 /qmake/library | |
parent | 7eae7e8103c79c9e098fc112bb8157971117678d (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')
-rw-r--r-- | qmake/library/ioutils.cpp | 35 | ||||
-rw-r--r-- | qmake/library/ioutils.h | 3 |
2 files changed, 38 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 diff --git a/qmake/library/ioutils.h b/qmake/library/ioutils.h index 905974b7cb..ad379404f3 100644 --- a/qmake/library/ioutils.h +++ b/qmake/library/ioutils.h @@ -65,6 +65,9 @@ public: #if defined(PROEVALUATOR_FULL) static bool touchFile(const QString &targetFileName, const QString &referenceFileName, QString *errorString); #endif +#ifdef Q_OS_UNIX + static bool readLinkTarget(const QString &symlinkPath, QString *target); +#endif }; } // namespace ProFileEvaluatorInternal |