diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2011-07-17 18:58:05 +0000 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2011-07-17 18:58:05 +0000 |
commit | 60468fe6ac3d33ccca5500260587cb5f4fb3d30d (patch) | |
tree | c36d2bad6efc9d734cf753aee882a5c5b41dff9b | |
parent | 5eb2f60afb38617633da4b7d6130e30960918a27 (diff) | |
download | rockbox-60468fe6ac3d33ccca5500260587cb5f4fb3d30d.tar.gz rockbox-60468fe6ac3d33ccca5500260587cb5f4fb3d30d.zip |
Implement reading the volume label on OS X.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30151 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r-- | rbutil/rbutilqt/base/utils.cpp | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/rbutil/rbutilqt/base/utils.cpp b/rbutil/rbutilqt/base/utils.cpp index 721aecc044..1fdf627378 100644 --- a/rbutil/rbutilqt/base/utils.cpp +++ b/rbutil/rbutilqt/base/utils.cpp @@ -53,7 +53,11 @@ #include <setupapi.h> #include <winioctl.h> #endif - +#if defined(Q_OS_MACX) +#include <CoreFoundation/CoreFoundation.h> +#include <CoreServices/CoreServices.h> +#include <IOKit/IOKitLib.h> +#endif // recursive function to delete a dir with files bool Utils::recursiveRmdir( const QString &dirName ) @@ -135,6 +139,43 @@ QString Utils::filesystemName(QString path) name = QString::fromWCharArray(volname); } #endif +#if defined(Q_OS_MACX) + // BSD label does not include folder. + QString bsd = Utils::resolveDevicename(path).remove("/dev/"); + if(bsd.isEmpty()) { + return name; + } + OSStatus result; + ItemCount index = 1; + + do { + FSVolumeRefNum volrefnum; + HFSUniStr255 volname; + + result = FSGetVolumeInfo(kFSInvalidVolumeRefNum, index, &volrefnum, + kFSVolInfoFSInfo, NULL, &volname, NULL); + + if(result == noErr) { + GetVolParmsInfoBuffer volparms; + HParamBlockRec hpb; + hpb.ioParam.ioNamePtr = NULL; + hpb.ioParam.ioVRefNum = volrefnum; + hpb.ioParam.ioBuffer = (Ptr)&volparms; + hpb.ioParam.ioReqCount = sizeof(volparms); + + if(PBHGetVolParmsSync(&hpb) == noErr) { + if(volparms.vMServerAdr == 0) { + if(bsd == (char*)volparms.vMDeviceID) { + name = QString::fromUtf16((const ushort*)volname.unicode, + (int)volname.length); + break; + } + } + } + } + index++; + } while(result == noErr); +#endif qDebug() << "[Utils] Volume name of" << path << "is" << name; return name; |