diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-01-16 01:22:45 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-01-16 01:22:45 +0100 |
commit | 7075e291998612a3c0a530bb37a515dd07739e28 (patch) | |
tree | 4e1992498d82ee3f6f92fd6d42754c92928dd581 /src/corelib/io/qfilesystemengine_unix.cpp | |
parent | 1161a8a62907796ea45b1877bec31e66aeef77f6 (diff) | |
parent | 3d9a40038f01bc2a3df0027a9be04e7fa3ce3850 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
src/widgets/styles/qstyleanimation.cpp
Change-Id: Iae570895be6544de80f9c1ec309d1a08c59daff8
Diffstat (limited to 'src/corelib/io/qfilesystemengine_unix.cpp')
-rw-r--r-- | src/corelib/io/qfilesystemengine_unix.cpp | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 5870cdf7de..fa0e07b045 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -46,6 +46,8 @@ #include <QtCore/qvarlengtharray.h> #include <stdlib.h> // for realpath() +#include <sys/types.h> +#include <sys/stat.h> #include <unistd.h> #include <stdio.h> #include <errno.h> @@ -174,9 +176,16 @@ QFileSystemEntry QFileSystemEngine::canonicalName(const QFileSystemEntry &entry, #else char *ret = 0; # if defined(Q_OS_MAC) && !defined(Q_OS_IOS) - // Mac OS X 10.5.x doesn't support the realpath(X,0) extension we use here. + // When using -mmacosx-version-min=10.4, we get the legacy realpath implementation, + // which does not work properly with the realpath(X,0) form. See QTBUG-28282. if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) { - ret = realpath(entry.nativeFilePath().constData(), (char*)0); + ret = (char*)malloc(PATH_MAX + 1); + if (ret && realpath(entry.nativeFilePath().constData(), (char*)ret) == 0) { + const int savedErrno = errno; // errno is checked below, and free() might change it + free(ret); + errno = savedErrno; + ret = 0; + } } else { // on 10.5 we can use FSRef to resolve the file path. QString path = QDir::cleanPath(entry.filePath()); @@ -252,6 +261,20 @@ QFileSystemEntry QFileSystemEngine::absoluteName(const QFileSystemEntry &entry) } //static +QByteArray QFileSystemEngine::id(const QFileSystemEntry &entry) +{ + struct stat statResult; + if (stat(entry.nativeFilePath().constData(), &statResult)) { + qErrnoWarning("stat() failed for '%s'", entry.nativeFilePath().constData()); + return QByteArray(); + } + QByteArray result = QByteArray::number(quint64(statResult.st_dev), 16); + result += ':'; + result += QByteArray::number(quint64(statResult.st_ino), 16); + return result; +} + +//static QString QFileSystemEngine::resolveUserName(uint userId) { #if !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS) && !defined(Q_OS_OPENBSD) |