diff options
author | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-05-04 14:03:10 +0200 |
---|---|---|
committer | Oswald Buddenhagen <oswald.buddenhagen@qt.io> | 2017-05-04 14:03:11 +0200 |
commit | 464a43d43c2bb2440d4ad745bc134e0dac10872c (patch) | |
tree | b1c27b1d1c11f9c43bd2e62e1fd955bc6f89029f /qmake/library/ioutils.cpp | |
parent | 0208cac94fbd79fc563c903e2b973d79f9644b82 (diff) | |
parent | 877ef0594d94f48bf063446b1f8a4b5e1941a8cd (diff) |
Merge 5.9 into 5.9.0v5.9.0-beta4
Change-Id: Id3fc911f024cba292a5c426b36aa94ff9f3c0ef7
Diffstat (limited to 'qmake/library/ioutils.cpp')
-rw-r--r-- | qmake/library/ioutils.cpp | 35 |
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 |