VirtualBox

Changeset 9880 in vbox


Ignore:
Timestamp:
Jun 23, 2008 2:44:31 PM (17 years ago)
Author:
vboxsync
Message:

External contribution: Gi youl Kim

Mac OS X deals with filename using unicode, especially
NFD(Normalization Form D - Canonical Decomposition). Here is link
about the topic.

http://unicode.org/reports/tr15/

Mac OS X understands NFD and NFC(Normalization Form C - Canonical
Decomposition, followed by Canonical Composition), but uses NFD as
filename. Windows XP understands NFC but not NFD.

So, when you tries to access the files in the Mac OS X (host) via
Shared Folder from Windows XP (guest), and if the filename is Korean,
Japanese or any language which has form in NFC & NFC, The filename
does not appear correctly. Windows Vista understands NFD, so it won't
be matter with Vista (guest).

To resolve this problem, you should normalize the filename to NFC(from
Mac OS X to Windows XP) or NFD(from Windows XP to Mac OS X).

Location:
trunk/src/VBox/HostServices/SharedFolders
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedFolders/Makefile.kmk

    r8760 r9880  
    3838        $(VBOX_PATH_SDK)
    3939
     40       
     41VBoxSharedFolders_LDFLAGS.darwin = \
     42        -framework Carbon
     43
    4044VBoxSharedFolders_SOURCES = \
    4145        service.cpp \
  • trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp

    r9816 r9880  
    3333#include <iprt/string.h>
    3434#include <iprt/uni.h>
     35#ifdef RT_OS_DARWIN
     36#include <Carbon/Carbon.h>
     37#endif
    3538
    3639#undef LogFlow
     
    232235    else
    233236    {
     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
    234267        /* Client sends us UCS2, so convert it to UTF8. */
    235268        Log(("Root %ls path %.*ls\n", pwszRoot, pPath->u16Length/sizeof(pPath->String.ucs2[0]), pPath->String.ucs2));
     
    256289            {
    257290                AssertFailed();
     291#ifdef RT_OS_DARWIN
     292                RTMemFree(pPath);
     293                pPath = pPathParameter;
     294#endif
    258295                return rc;
    259296            }
     
    299336                {
    300337                    AssertFailed();
     338#ifdef RT_OS_DARWIN
     339                        RTMemFree(pPath);
     340                        pPath = pPathParameter;
     341#endif
    301342                    return rc;
    302343                }
     
    313354            *dst = 0;
    314355        }
     356#ifdef RT_OS_DARWIN
     357        RTMemFree(pPath);
     358        pPath = pPathParameter;
     359#endif
    315360    }
    316361
     
    13411386            AssertRC(rc2);
    13421387
     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
    13431410            pSFDEntry->name.u16Length = RTUtf16Len (pSFDEntry->name.String.ucs2) * 2;
    13441411            pSFDEntry->name.u16Size = pSFDEntry->name.u16Length + 2;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette