forked from len0rd/rockbox
Implement reading the volume label on OS X.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30151 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
5eb2f60afb
commit
60468fe6ac
1 changed files with 42 additions and 1 deletions
|
@ -53,7 +53,11 @@
|
||||||
#include <setupapi.h>
|
#include <setupapi.h>
|
||||||
#include <winioctl.h>
|
#include <winioctl.h>
|
||||||
#endif
|
#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
|
// recursive function to delete a dir with files
|
||||||
bool Utils::recursiveRmdir( const QString &dirName )
|
bool Utils::recursiveRmdir( const QString &dirName )
|
||||||
|
@ -135,6 +139,43 @@ QString Utils::filesystemName(QString path)
|
||||||
name = QString::fromWCharArray(volname);
|
name = QString::fromWCharArray(volname);
|
||||||
}
|
}
|
||||||
#endif
|
#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;
|
qDebug() << "[Utils] Volume name of" << path << "is" << name;
|
||||||
return name;
|
return name;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue