diff options
author | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-12-09 09:43:14 (GMT) |
---|---|---|
committer | Denis Dzyubenko <denis.dzyubenko@nokia.com> | 2009-12-09 13:31:48 (GMT) |
commit | 4184664b3886ff03acc193b3302229e76fae3ad9 (patch) | |
tree | a3aa572a5565111c4305028bab74f6ed56f81bef /src/corelib/io | |
parent | 6135da7c97830ea46ca807b7cf5944dc74fdb960 (diff) | |
download | Qt-4184664b3886ff03acc193b3302229e76fae3ad9.zip Qt-4184664b3886ff03acc193b3302229e76fae3ad9.tar.gz Qt-4184664b3886ff03acc193b3302229e76fae3ad9.tar.bz2 |
Implemented getting a canonical file name on Mac OS X 10.5
Using FSRef to get a canonical file path on OS X 10.5 which doesn't support
realpath(X,0) extension.
Reviewed-by: Prasanth
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/qfsfileengine.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp index f874052..b4611f1 100644 --- a/src/corelib/io/qfsfileengine.cpp +++ b/src/corelib/io/qfsfileengine.cpp @@ -56,6 +56,9 @@ #endif #include <stdio.h> #include <stdlib.h> +#if defined(Q_OS_MAC) +# include <private/qcore_mac_p.h> +#endif QT_BEGIN_NAMESPACE @@ -147,8 +150,20 @@ QString QFSFileEnginePrivate::canonicalized(const QString &path) char *ret = 0; #if defined(Q_OS_MAC) // Mac OS X 10.5.x doesn't support the realpath(X,0) extension we use here. - if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) + if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_6) { ret = realpath(path.toLocal8Bit().constData(), (char*)0); + } else { + // on 10.5 we can use FSRef to resolve the file path. + FSRef fsref; + if (FSPathMakeRef((const UInt8 *)QDir::cleanPath(path).toUtf8().data(), &fsref, 0) == noErr) { + CFURLRef urlref = CFURLCreateFromFSRef(NULL, &fsref); + CFStringRef canonicalPath = CFURLCopyFileSystemPath(urlref, kCFURLPOSIXPathStyle); + QString ret = QCFString::toQString(canonicalPath); + CFRelease(canonicalPath); + CFRelease(urlref); + return ret; + } + } #else ret = realpath(path.toLocal8Bit().constData(), (char*)0); #endif |