diff options
author | Jake Petroules <jake.petroules@theqtcompany.com> | 2015-07-13 20:16:44 -0700 |
---|---|---|
committer | Jake Petroules <jake.petroules@theqtcompany.com> | 2015-09-22 00:09:20 +0000 |
commit | 46a372e1a115fb05b746339c790a7f3e5d6d01fc (patch) | |
tree | ac26264e5d38a3c6e3c4389c38db7351f1a9731c /src/corelib/io/qstorageinfo_mac.cpp | |
parent | 827d0c023222c58443bd825c6287949a2cc07de7 (diff) |
Modernize and unify filesystem code on Apple platforms.
Replace deprecated File Manager APIs with modern equivalents.
Change some Q_OS_MACX to Q_OS_DARWIN in file system related code.
All of these apply to iOS as well as OS X, and were ifdef'ed for OS X
only primarily due to legacy reasons - carryovers from Qt 4 or Carbon
APIs which have since been refactored into using CoreFoundation.
This also makes the code consistent with the documentation.
Change-Id: I414e9bdfffff731413ddf16171b1317027d87caf
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@theqtcompany.com>
Diffstat (limited to 'src/corelib/io/qstorageinfo_mac.cpp')
-rw-r--r-- | src/corelib/io/qstorageinfo_mac.cpp | 40 |
1 files changed, 16 insertions, 24 deletions
diff --git a/src/corelib/io/qstorageinfo_mac.cpp b/src/corelib/io/qstorageinfo_mac.cpp index 1ef9983918..64ca6d7175 100644 --- a/src/corelib/io/qstorageinfo_mac.cpp +++ b/src/corelib/io/qstorageinfo_mac.cpp @@ -147,32 +147,24 @@ void QStorageInfoPrivate::retrieveUrlProperties(bool initRootPath) void QStorageInfoPrivate::retrieveLabel() { -#if !defined(Q_OS_IOS) - // deprecated since 10.8 - FSRef ref; - FSPathMakeRef(reinterpret_cast<const UInt8*>(QFile::encodeName(rootPath).constData()), - &ref, - Q_NULLPTR); - - // deprecated since 10.8 - FSCatalogInfo catalogInfo; - OSErr error; - error = FSGetCatalogInfo(&ref, kFSCatInfoVolume, &catalogInfo, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR); - if (error != noErr) + QCFString path = CFStringCreateWithFileSystemRepresentation(0, + QFile::encodeName(rootPath).constData()); + if (!path) return; - // deprecated (use CFURLCopyResourcePropertiesForKeys for 10.7 and higher) - HFSUniStr255 volumeName; - error = FSGetVolumeInfo(catalogInfo.volume, - 0, - Q_NULLPTR, - kFSVolInfoFSInfo, - Q_NULLPTR, - &volumeName, - Q_NULLPTR); - if (error == noErr) - name = QCFString(FSCreateStringFromHFSUniStr(Q_NULLPTR, &volumeName)); -#endif + QCFType<CFURLRef> url = CFURLCreateWithFileSystemPath(0, path, kCFURLPOSIXPathStyle, true); + if (!url) + return; + + QCFType<CFURLRef> volumeUrl; + if (!CFURLCopyResourcePropertyForKey(url, kCFURLVolumeURLKey, &volumeUrl, NULL)) + return; + + QCFString volumeName; + if (!CFURLCopyResourcePropertyForKey(url, kCFURLNameKey, &volumeName, NULL)) + return; + + name = volumeName; } QList<QStorageInfo> QStorageInfoPrivate::mountedVolumes() |