Changeset 9880 in vbox
- Timestamp:
- Jun 23, 2008 2:44:31 PM (17 years ago)
- Location:
- trunk/src/VBox/HostServices/SharedFolders
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostServices/SharedFolders/Makefile.kmk
r8760 r9880 38 38 $(VBOX_PATH_SDK) 39 39 40 41 VBoxSharedFolders_LDFLAGS.darwin = \ 42 -framework Carbon 43 40 44 VBoxSharedFolders_SOURCES = \ 41 45 service.cpp \ -
trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp
r9816 r9880 33 33 #include <iprt/string.h> 34 34 #include <iprt/uni.h> 35 #ifdef RT_OS_DARWIN 36 #include <Carbon/Carbon.h> 37 #endif 35 38 36 39 #undef LogFlow … … 232 235 else 233 236 { 237 #ifdef RT_OS_DARWIN 238 SHFLSTRING *pPathParameter = pPath; 239 size_t cbPathLength; 240 CFMutableStringRef inStr = ::CFStringCreateMutable(NULL, 0); 241 uint16_t ucs2Length; 242 CFRange rangeCharacters; 243 244 // Is 8 times length enough for decomposed in worst case...? 245 cbPathLength = sizeof(SHFLSTRING) + pPathParameter->u16Length * 8 + 2; 246 pPath = (SHFLSTRING *)RTMemAllocZ (cbPathLength); 247 if (!pPath) 248 { 249 rc = VERR_NO_MEMORY; 250 Log(("RTMemAllocZ %x failed!!\n", cbPathLength)); 251 return rc; 252 } 253 254 ::CFStringAppendCharacters(inStr, (UniChar*)pPathParameter->String.ucs2, pPathParameter->u16Length / sizeof(pPathParameter->String.ucs2[0])); 255 ::CFStringNormalize(inStr, kCFStringNormalizationFormD); 256 ucs2Length = ::CFStringGetLength(inStr); 257 258 rangeCharacters.location = 0; 259 rangeCharacters.length = ucs2Length; 260 ::CFStringGetCharacters(inStr, rangeCharacters, pPath->String.ucs2); 261 pPath->String.ucs2[ucs2Length] = 0x0000; // NULL terminated 262 pPath->u16Length = ucs2Length * sizeof(pPath->String.ucs2[0]); 263 pPath->u16Size = pPath->u16Length + sizeof(pPath->String.ucs2[0]); 264 265 CFRelease(inStr); 266 #endif 234 267 /* Client sends us UCS2, so convert it to UTF8. */ 235 268 Log(("Root %ls path %.*ls\n", pwszRoot, pPath->u16Length/sizeof(pPath->String.ucs2[0]), pPath->String.ucs2)); … … 256 289 { 257 290 AssertFailed(); 291 #ifdef RT_OS_DARWIN 292 RTMemFree(pPath); 293 pPath = pPathParameter; 294 #endif 258 295 return rc; 259 296 } … … 299 336 { 300 337 AssertFailed(); 338 #ifdef RT_OS_DARWIN 339 RTMemFree(pPath); 340 pPath = pPathParameter; 341 #endif 301 342 return rc; 302 343 } … … 313 354 *dst = 0; 314 355 } 356 #ifdef RT_OS_DARWIN 357 RTMemFree(pPath); 358 pPath = pPathParameter; 359 #endif 315 360 } 316 361 … … 1341 1386 AssertRC(rc2); 1342 1387 1388 #ifdef RT_OS_DARWIN 1389 { 1390 // Convert to 1391 // Normalization Form C (composed Unicode). We need this because 1392 // Mac OS X file system uses NFD (Normalization Form D :decomposed Unicode) 1393 // while most other OS', server-side programs usually expect NFC. 1394 uint16_t ucs2Length; 1395 CFRange rangeCharacters; 1396 CFMutableStringRef inStr = ::CFStringCreateMutable(NULL, 0); 1397 1398 ::CFStringAppendCharacters(inStr, (UniChar *)pwszString, RTUtf16Len (pwszString)); 1399 ::CFStringNormalize(inStr, kCFStringNormalizationFormC); 1400 ucs2Length = ::CFStringGetLength(inStr); 1401 1402 rangeCharacters.location = 0; 1403 rangeCharacters.length = ucs2Length; 1404 ::CFStringGetCharacters(inStr, rangeCharacters, pwszString); 1405 pwszString[ucs2Length] = 0x0000; // NULL terminated 1406 1407 CFRelease(inStr); 1408 } 1409 #endif 1343 1410 pSFDEntry->name.u16Length = RTUtf16Len (pSFDEntry->name.String.ucs2) * 2; 1344 1411 pSFDEntry->name.u16Size = pSFDEntry->name.u16Length + 2;
Note:
See TracChangeset
for help on using the changeset viewer.