From 4184664b3886ff03acc193b3302229e76fae3ad9 Mon Sep 17 00:00:00 2001 From: Denis Dzyubenko Date: Wed, 9 Dec 2009 10:43:14 +0100 Subject: 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 --- src/corelib/io/qfsfileengine.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) 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 #include +#if defined(Q_OS_MAC) +# include +#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 -- cgit v0.12