diff options
-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 @@ | |||
53 | #include <setupapi.h> | 53 | #include <setupapi.h> |
54 | #include <winioctl.h> | 54 | #include <winioctl.h> |
55 | #endif | 55 | #endif |
56 | 56 | #if defined(Q_OS_MACX) | |
57 | #include <CoreFoundation/CoreFoundation.h> | ||
58 | #include <CoreServices/CoreServices.h> | ||
59 | #include <IOKit/IOKitLib.h> | ||
60 | #endif | ||
57 | 61 | ||
58 | // recursive function to delete a dir with files | 62 | // recursive function to delete a dir with files |
59 | bool Utils::recursiveRmdir( const QString &dirName ) | 63 | bool Utils::recursiveRmdir( const QString &dirName ) |
@@ -135,6 +139,43 @@ QString Utils::filesystemName(QString path) | |||
135 | name = QString::fromWCharArray(volname); | 139 | name = QString::fromWCharArray(volname); |
136 | } | 140 | } |
137 | #endif | 141 | #endif |
142 | #if defined(Q_OS_MACX) | ||
143 | // BSD label does not include folder. | ||
144 | QString bsd = Utils::resolveDevicename(path).remove("/dev/"); | ||
145 | if(bsd.isEmpty()) { | ||
146 | return name; | ||
147 | } | ||
148 | OSStatus result; | ||
149 | ItemCount index = 1; | ||
150 | |||
151 | do { | ||
152 | FSVolumeRefNum volrefnum; | ||
153 | HFSUniStr255 volname; | ||
154 | |||
155 | result = FSGetVolumeInfo(kFSInvalidVolumeRefNum, index, &volrefnum, | ||
156 | kFSVolInfoFSInfo, NULL, &volname, NULL); | ||
157 | |||
158 | if(result == noErr) { | ||
159 | GetVolParmsInfoBuffer volparms; | ||
160 | HParamBlockRec hpb; | ||
161 | hpb.ioParam.ioNamePtr = NULL; | ||
162 | hpb.ioParam.ioVRefNum = volrefnum; | ||
163 | hpb.ioParam.ioBuffer = (Ptr)&volparms; | ||
164 | hpb.ioParam.ioReqCount = sizeof(volparms); | ||
165 | |||
166 | if(PBHGetVolParmsSync(&hpb) == noErr) { | ||
167 | if(volparms.vMServerAdr == 0) { | ||
168 | if(bsd == (char*)volparms.vMDeviceID) { | ||
169 | name = QString::fromUtf16((const ushort*)volname.unicode, | ||
170 | (int)volname.length); | ||
171 | break; | ||
172 | } | ||
173 | } | ||
174 | } | ||
175 | } | ||
176 | index++; | ||
177 | } while(result == noErr); | ||
178 | #endif | ||
138 | 179 | ||
139 | qDebug() << "[Utils] Volume name of" << path << "is" << name; | 180 | qDebug() << "[Utils] Volume name of" << path << "is" << name; |
140 | return name; | 181 | return name; |