Index: /trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp
===================================================================
--- /trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp	(revision 39593)
+++ /trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp	(revision 39594)
@@ -5,5 +5,5 @@
 
 /*
- * Copyright (C) 2006-2007 Oracle Corporation
+ * Copyright (C) 2006-2011 Oracle Corporation
  *
  * This file is part of VirtualBox Open Source Edition (OSE), as
@@ -51,5 +51,5 @@
  */
 
-void vbsfStripLastComponent (char *pszFullPath, uint32_t cbFullPathRoot)
+void vbsfStripLastComponent(char *pszFullPath, uint32_t cbFullPathRoot)
 {
     RTUNICP cp;
@@ -81,5 +81,5 @@
         }
 
-        s = RTStrNextCp (s);
+        s = RTStrNextCp(s);
     }
 
@@ -139,5 +139,5 @@
     strcat(pDirEntry->szName, szWildCard);
 
-    rc = RTDirOpenFiltered (&hSearch, pDirEntry->szName, RTDIRFILTER_WINNT);
+    rc = RTDirOpenFiltered(&hSearch, pDirEntry->szName, RTDIRFILTER_WINNT);
     *(pszStartComponent-1) = RTPATH_DELIMITER;
     if (RT_FAILURE(rc))
@@ -248,7 +248,7 @@
 }
 
-static int vbsfBuildFullPath (SHFLCLIENTDATA *pClient, SHFLROOT root, PSHFLSTRING pPath,
-                              uint32_t cbPath, char **ppszFullPath, uint32_t *pcbFullPathRoot,
-                              bool fWildCard = false, bool fPreserveLastComponent = false)
+static int vbsfBuildFullPath(SHFLCLIENTDATA *pClient, SHFLROOT root, PSHFLSTRING pPath,
+                             uint32_t cbPath, char **ppszFullPath, uint32_t *pcbFullPathRoot,
+                             bool fWildCard = false, bool fPreserveLastComponent = false)
 {
     int rc = VINF_SUCCESS;
@@ -258,5 +258,5 @@
     /* Query UCS2 root prefix for the path, cbRoot is the length in bytes including trailing (RTUTF16)0. */
     uint32_t cbRoot = 0;
-    PCRTUTF16 pwszRoot = vbsfMappingsQueryHostRoot (root, &cbRoot);
+    PCRTUTF16 pwszRoot = vbsfMappingsQueryHostRoot(root, &cbRoot);
 
     if (!pwszRoot || cbRoot == 0)
@@ -273,17 +273,17 @@
         rc = vbsfPathCheck((const char *)&pPath->String.utf8[0], pPath->u16Length);
 
-        if (RT_SUCCESS (rc))
-        {
-            rc = RTUtf16ToUtf8 (pwszRoot, &utf8Root);
-        }
-
-        if (RT_SUCCESS (rc))
+        if (RT_SUCCESS(rc))
+        {
+            rc = RTUtf16ToUtf8(pwszRoot, &utf8Root);
+        }
+
+        if (RT_SUCCESS(rc))
         {
             size_t cbUtf8Root, cbUtf8FullPath;
             char *utf8FullPath;
 
-            cbUtf8Root = strlen (utf8Root);
+            cbUtf8Root = strlen(utf8Root);
             cbUtf8FullPath = cbUtf8Root + 1 + pPath->u16Length + 1;
-            utf8FullPath = (char *) RTMemAllocZ (cbUtf8FullPath);
+            utf8FullPath = (char *) RTMemAllocZ(cbUtf8FullPath);
 
             if (!utf8FullPath)
@@ -295,8 +295,8 @@
             else
             {
-                memcpy (utf8FullPath, utf8Root, cbUtf8Root);
-                memcpy (utf8FullPath + cbUtf8Root + 1,
-                        &pPath->String.utf8[0],
-                        pPath->u16Length);
+                memcpy(utf8FullPath, utf8Root, cbUtf8Root);
+                memcpy(utf8FullPath + cbUtf8Root + 1,
+                       &pPath->String.utf8[0],
+                       pPath->u16Length);
 
                 utf8FullPath[cbUtf8Root] = '/';
@@ -308,9 +308,9 @@
             }
 
-            RTStrFree (utf8Root);
+            RTStrFree(utf8Root);
         }
         else
         {
-            Log (("vbsfBuildFullPath: RTUtf16ToUtf8 failed with %Rrc\n", rc));
+            Log(("vbsfBuildFullPath: RTUtf16ToUtf8 failed with %Rrc\n", rc));
         }
     }
@@ -329,5 +329,5 @@
         // Is 8 times length enough for decomposed in worst case...?
         cbPathLength = sizeof(SHFLSTRING) + pPathParameter->u16Length * 8 + 2;
-        pPath = (SHFLSTRING *)RTMemAllocZ (cbPathLength);
+        pPath = (SHFLSTRING *)RTMemAllocZ(cbPathLength);
         if (!pPath)
         {
@@ -358,7 +358,7 @@
          * in worst case.
          */
-        uint32_t cbFullPath = (cbRoot/sizeof (RTUTF16) + ShflStringLength (pPath)) * 4;
-
-        pszFullPath = (char *)RTMemAllocZ (cbFullPath);
+        uint32_t cbFullPath = (cbRoot/sizeof(RTUTF16) + ShflStringLength(pPath)) * 4;
+
+        pszFullPath = (char *)RTMemAllocZ(cbFullPath);
 
         if (!pszFullPath)
@@ -370,5 +370,5 @@
             uint32_t cb = cbFullPath;
 
-            rc = RTUtf16ToUtf8Ex (pwszRoot, RTSTR_MAX, &pszFullPath, cb, NULL);
+            rc = RTUtf16ToUtf8Ex(pwszRoot, RTSTR_MAX, &pszFullPath, cb, NULL);
             if (RT_FAILURE(rc))
             {
@@ -417,5 +417,5 @@
                     src++;  /* we already appended a delimiter to the first part */
 
-                rc = RTUtf16ToUtf8Ex (src, RTSTR_MAX, &dst, cb, NULL);
+                rc = RTUtf16ToUtf8Ex(src, RTSTR_MAX, &dst, cb, NULL);
                 if (RT_FAILURE(rc))
                 {
@@ -428,5 +428,5 @@
                 }
 
-                uint32_t l = (uint32_t)strlen (dst);
+                uint32_t l = (uint32_t)strlen(dst);
 
                 /* Verify that the path is under the root directory. */
@@ -457,8 +457,8 @@
     }
 
-    if (RT_SUCCESS (rc))
+    if (RT_SUCCESS(rc))
     {
         /* When the host file system is case sensitive and the guest expects a case insensitive fs, then problems can occur */
-        if (     vbsfIsHostMappingCaseSensitive (root)
+        if (     vbsfIsHostMappingCaseSensitive(root)
             &&  !vbsfIsGuestMappingCaseSensitive(root))
         {
@@ -600,7 +600,7 @@
 }
 
-static void vbsfFreeFullPath (char *pszFullPath)
-{
-    RTMemFree (pszFullPath);
+static void vbsfFreeFullPath(char *pszFullPath)
+{
+    RTMemFree(pszFullPath);
 }
 
@@ -845,5 +845,5 @@
  * @retval pParms->Info          On success the parameters of the file opened or created
  */
-static int vbsfOpenFile (SHFLCLIENTDATA *pClient, const char *pszPath, SHFLCREATEPARMS *pParms)
+static int vbsfOpenFile(SHFLCLIENTDATA *pClient, const char *pszPath, SHFLCREATEPARMS *pParms)
 {
     LogFlow(("vbsfOpenFile: pszPath = %s, pParms = %p\n", pszPath, pParms));
@@ -871,5 +871,5 @@
         rc = RTFileOpen(&pHandle->file.Handle, pszPath, fOpen);
     }
-    if (RT_FAILURE (rc))
+    if (RT_FAILURE(rc))
     {
         switch (rc)
@@ -968,5 +968,5 @@
 
         /* Get file information */
-        rc = RTFileQueryInfo (pHandle->file.Handle, &info, RTFSOBJATTRADD_NOTHING);
+        rc = RTFileQueryInfo(pHandle->file.Handle, &info, RTFSOBJATTRADD_NOTHING);
         if (RT_SUCCESS(rc))
         {
@@ -1045,5 +1045,5 @@
             pParms->Result = SHFL_FILE_CREATED;
             rc = RTDirCreate(pszPath, fMode);
-            if (RT_FAILURE (rc))
+            if (RT_FAILURE(rc))
             {
                 switch (rc)
@@ -1064,10 +1064,10 @@
         {
             /* Open the directory now */
-            rc = RTDirOpen (&pHandle->dir.Handle, pszPath);
+            rc = RTDirOpen(&pHandle->dir.Handle, pszPath);
             if (RT_SUCCESS(rc))
             {
                 RTFSOBJINFO info;
 
-                rc = RTDirQueryInfo (pHandle->dir.Handle, &info, RTFSOBJATTRADD_NOTHING);
+                rc = RTDirQueryInfo(pHandle->dir.Handle, &info, RTFSOBJATTRADD_NOTHING);
                 if (RT_SUCCESS(rc))
                 {
@@ -1116,5 +1116,5 @@
 }
 
-static int vbsfCloseDir (SHFLFILEHANDLE *pHandle)
+static int vbsfCloseDir(SHFLFILEHANDLE *pHandle)
 {
     int rc = VINF_SUCCESS;
@@ -1123,5 +1123,5 @@
              pHandle->dir.Handle, pHandle->dir.SearchHandle));
 
-    RTDirClose (pHandle->dir.Handle);
+    RTDirClose(pHandle->dir.Handle);
 
     if (pHandle->dir.SearchHandle)
@@ -1140,5 +1140,5 @@
 
 
-static int vbsfCloseFile (SHFLFILEHANDLE *pHandle)
+static int vbsfCloseFile(SHFLFILEHANDLE *pHandle)
 {
     int rc = VINF_SUCCESS;
@@ -1147,5 +1147,5 @@
              pHandle->file.Handle));
 
-    rc = RTFileClose (pHandle->file.Handle);
+    rc = RTFileClose(pHandle->file.Handle);
 
     LogFlow(("vbsfCloseFile: rc = %d\n", rc));
@@ -1237,5 +1237,5 @@
  *       pParms->Result return value and whether pParms->Handle is valid.
  */
-int vbsfCreate (SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pPath, uint32_t cbPath, SHFLCREATEPARMS *pParms)
+int vbsfCreate(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pPath, uint32_t cbPath, SHFLCREATEPARMS *pParms)
 {
     int rc = VINF_SUCCESS;
@@ -1254,7 +1254,7 @@
     uint32_t cbFullPathRoot = 0;
 
-    rc = vbsfBuildFullPath (pClient, root, pPath, cbPath, &pszFullPath, &cbFullPathRoot);
-
-    if (RT_SUCCESS (rc))
+    rc = vbsfBuildFullPath(pClient, root, pPath, cbPath, &pszFullPath, &cbFullPathRoot);
+
+    if (RT_SUCCESS(rc))
     {
         /* Reset return value in case client forgot to do so.
@@ -1295,5 +1295,5 @@
                 if (BIT_FLAG(pParms->CreateFlags, SHFL_CF_OPEN_TARGET_DIRECTORY))
                 {
-                    vbsfStripLastComponent (pszFullPath, cbFullPathRoot);
+                    vbsfStripLastComponent(pszFullPath, cbFullPathRoot);
                     pParms->CreateFlags &= ~SHFL_CF_ACT_MASK_IF_EXISTS;
                     pParms->CreateFlags &= ~SHFL_CF_ACT_MASK_IF_NEW;
@@ -1319,5 +1319,5 @@
                 /* is the guest allowed to write to this share? */
                 bool fWritable;
-                rc = vbsfMappingsQueryWritable (pClient, root, &fWritable);
+                rc = vbsfMappingsQueryWritable(pClient, root, &fWritable);
                 if (RT_FAILURE(rc) || !fWritable)
                     rc = VERR_WRITE_PROTECT;
@@ -1332,5 +1332,5 @@
                 else
                 {
-                    rc = vbsfOpenFile (pClient, pszFullPath, pParms);
+                    rc = vbsfOpenFile(pClient, pszFullPath, pParms);
                 }
             }
@@ -1360,5 +1360,5 @@
 }
 #endif
-int vbsfClose (SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLHANDLE Handle)
+int vbsfClose(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLHANDLE Handle)
 {
     int rc = VINF_SUCCESS;
@@ -1447,5 +1447,5 @@
 }
 #endif
-int vbsfWrite (SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLHANDLE Handle, uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer)
+int vbsfWrite(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLHANDLE Handle, uint64_t offset, uint32_t *pcbBuffer, uint8_t *pBuffer)
 {
     SHFLFILEHANDLE *pHandle = vbsfQueryFileHandle(pClient, Handle);
@@ -1464,5 +1464,5 @@
      * XXX Actually this check was still done in vbsfCreate() -- RTFILE_O_WRITE cannot be set if vbsfMappingsQueryWritable() failed. */
     bool fWritable;
-    rc = vbsfMappingsQueryWritable (pClient, root, &fWritable);
+    rc = vbsfMappingsQueryWritable(pClient, root, &fWritable);
     if (RT_FAILURE(rc) || !fWritable)
         return VERR_WRITE_PROTECT;
@@ -1574,14 +1574,14 @@
             Assert(pHandle->dir.pLastValidEntry == 0);
 
-            rc = vbsfBuildFullPath (pClient, root, pPath, pPath->u16Size, &pszFullPath, NULL, true);
-
-            if (RT_SUCCESS (rc))
-            {
-                rc = RTDirOpenFiltered (&pHandle->dir.SearchHandle, pszFullPath, RTDIRFILTER_WINNT);
+            rc = vbsfBuildFullPath(pClient, root, pPath, pPath->u16Size, &pszFullPath, NULL, true);
+
+            if (RT_SUCCESS(rc))
+            {
+                rc = RTDirOpenFiltered(&pHandle->dir.SearchHandle, pszFullPath, RTDIRFILTER_WINNT);
 
                 /* free the path string */
                 vbsfFreeFullPath(pszFullPath);
 
-                if (RT_FAILURE (rc))
+                if (RT_FAILURE(rc))
                     goto end;
             }
@@ -1625,5 +1625,5 @@
         }
 
-        cbNeeded = RT_OFFSETOF (SHFLDIRINFO, name.String);
+        cbNeeded = RT_OFFSETOF(SHFLDIRINFO, name.String);
         if (fUtf8)
             cbNeeded += pDirEntry->cbName + 1;
@@ -1658,5 +1658,5 @@
             dst = &pSFDEntry->name.String.utf8[0];
 
-            memcpy (dst, src, pDirEntry->cbName + 1);
+            memcpy(dst, src, pDirEntry->cbName + 1);
 
             pSFDEntry->name.u16Size = pDirEntry->cbName + 1;
@@ -1683,5 +1683,5 @@
                 CFMutableStringRef inStr = ::CFStringCreateMutable(NULL, 0);
 
-                ::CFStringAppendCharacters(inStr, (UniChar *)pwszString, RTUtf16Len (pwszString));
+                ::CFStringAppendCharacters(inStr, (UniChar *)pwszString, RTUtf16Len(pwszString));
                 ::CFStringNormalize(inStr, kCFStringNormalizationFormC);
                 ucs2Length = ::CFStringGetLength(inStr);
@@ -1695,5 +1695,5 @@
             }
 #endif
-            pSFDEntry->name.u16Length = (uint32_t)RTUtf16Len (pSFDEntry->name.String.ucs2) * 2;
+            pSFDEntry->name.u16Length = (uint32_t)RTUtf16Len(pSFDEntry->name.String.ucs2) * 2;
             pSFDEntry->name.u16Size = pSFDEntry->name.u16Length + 2;
 
@@ -1702,5 +1702,5 @@
 
             // adjust cbNeeded (it was overestimated before)
-            cbNeeded = RT_OFFSETOF (SHFLDIRINFO, name.String) + pSFDEntry->name.u16Size;
+            cbNeeded = RT_OFFSETOF(SHFLDIRINFO, name.String) + pSFDEntry->name.u16Size;
         }
 
@@ -1757,7 +1757,7 @@
     uint32_t cbFullPathRoot = 0;
 
-    rc = vbsfBuildFullPath (pClient, root, pPath, cbPath, &pszFullPath, &cbFullPathRoot);
-
-    if (RT_SUCCESS (rc))
+    rc = vbsfBuildFullPath(pClient, root, pPath, cbPath, &pszFullPath, &cbFullPathRoot);
+
+    if (RT_SUCCESS(rc))
     {
         rc = RTSymlinkRead(pszFullPath, (char *) pBuffer, cbBuffer);
@@ -1977,7 +1977,7 @@
 
     ShflStringInitBuffer(&dummy, sizeof(dummy));
-    rc = vbsfBuildFullPath (pClient, root, &dummy, 0, &pszFullPath, NULL);
-
-    if (RT_SUCCESS (rc))
+    rc = vbsfBuildFullPath(pClient, root, &dummy, 0, &pszFullPath, NULL);
+
+    if (RT_SUCCESS(rc))
     {
         rc = RTFsQuerySizes(pszFullPath, &pSFDEntry->ullTotalAllocationBytes, &pSFDEntry->ullAvailableAllocationBytes, &pSFDEntry->ulBytesPerAllocationUnit, &pSFDEntry->ulBytesPerSector);
@@ -2055,5 +2055,5 @@
     /* is the guest allowed to write to this share? */
     bool fWritable;
-    int rc = vbsfMappingsQueryWritable (pClient, root, &fWritable);
+    int rc = vbsfMappingsQueryWritable(pClient, root, &fWritable);
     if (RT_FAILURE(rc) || !fWritable)
         return VERR_WRITE_PROTECT;
@@ -2196,14 +2196,14 @@
     char *pszFullPath = NULL;
 
-    rc = vbsfBuildFullPath (pClient, root, pPath, cbPath, &pszFullPath, NULL);
-    if (RT_SUCCESS (rc))
+    rc = vbsfBuildFullPath(pClient, root, pPath, cbPath, &pszFullPath, NULL);
+    if (RT_SUCCESS(rc))
     {
         /* is the guest allowed to write to this share? */
         bool fWritable;
-        rc = vbsfMappingsQueryWritable (pClient, root, &fWritable);
+        rc = vbsfMappingsQueryWritable(pClient, root, &fWritable);
         if (RT_FAILURE(rc) || !fWritable)
             rc = VERR_WRITE_PROTECT;
 
-        if (RT_SUCCESS (rc))
+        if (RT_SUCCESS(rc))
         {
             if (flags & SHFL_REMOVE_SYMLINK)
@@ -2255,9 +2255,9 @@
     char *pszFullPathDest = NULL;
 
-    rc = vbsfBuildFullPath (pClient, root, pSrc, pSrc->u16Size, &pszFullPathSrc, NULL);
+    rc = vbsfBuildFullPath(pClient, root, pSrc, pSrc->u16Size, &pszFullPathSrc, NULL);
     if (rc != VINF_SUCCESS)
         return rc;
 
-    rc = vbsfBuildFullPath (pClient, root, pDest, pDest->u16Size, &pszFullPathDest, NULL, false, true);
+    rc = vbsfBuildFullPath(pClient, root, pDest, pDest->u16Size, &pszFullPathDest, NULL, false, true);
     if (RT_SUCCESS (rc))
     {
@@ -2266,9 +2266,9 @@
         /* is the guest allowed to write to this share? */
         bool fWritable;
-        rc = vbsfMappingsQueryWritable (pClient, root, &fWritable);
+        rc = vbsfMappingsQueryWritable(pClient, root, &fWritable);
         if (RT_FAILURE(rc) || !fWritable)
             rc = VERR_WRITE_PROTECT;
 
-        if (RT_SUCCESS (rc))
+        if (RT_SUCCESS(rc))
         {
             if (flags & SHFL_RENAME_FILE)
@@ -2315,10 +2315,10 @@
         return VERR_NOT_IMPLEMENTED;
 
-    rc = vbsfBuildFullPath (pClient, root, pNewPath, pNewPath->u16Size, &pszFullNewPath, NULL);
+    rc = vbsfBuildFullPath(pClient, root, pNewPath, pNewPath->u16Size, &pszFullNewPath, NULL);
     if (rc != VINF_SUCCESS)
         return rc;
 
     rc = RTSymlinkCreate(pszFullNewPath, (const char *)pOldPath->String.utf8, RTSYMLINKTYPE_UNKNOWN);
-    if (RT_SUCCESS (rc))
+    if (RT_SUCCESS(rc))
     {
         RTFSOBJINFO info;
@@ -2339,5 +2339,5 @@
 int vbsfDisconnect(SHFLCLIENTDATA *pClient)
 {
-    for (int i=0;i<SHFLHANDLE_MAX;i++)
+    for (int i=0; i<SHFLHANDLE_MAX; i++)
     {
         SHFLHANDLE Handle = (SHFLHANDLE)i;
