Changeset 78048 in vbox for trunk/src/VBox/Runtime/generic
- Timestamp:
- Apr 9, 2019 1:21:09 AM (6 years ago)
- Location:
- trunk/src/VBox/Runtime/generic
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/generic/RTPathAbs-generic.cpp
r76553 r78048 40 40 #include "internal/fs.h" 41 41 42 #if 1 42 43 43 44 static char *rtPathSkipRootSpec(char *pszCur) … … 145 146 146 147 147 RTDECL(int) RTPathAbs(const char *pszPath, char *pszAbsPath, size_t c chAbsPath)148 RTDECL(int) RTPathAbs(const char *pszPath, char *pszAbsPath, size_t cbAbsPath) 148 149 { 149 150 int rc; … … 163 164 if (cchPath >= RTPATH_MAX) 164 165 { 165 LogFlow(("RTPathAbs(%p:{%s}, %p, %d): returns %Rrc\n", pszPath, pszPath, pszAbsPath, c chAbsPath, VERR_FILENAME_TOO_LONG));166 LogFlow(("RTPathAbs(%p:{%s}, %p, %d): returns %Rrc\n", pszPath, pszPath, pszAbsPath, cbAbsPath, VERR_FILENAME_TOO_LONG)); 166 167 return VERR_FILENAME_TOO_LONG; 167 168 } … … 179 180 || (cchTmpPath == 2 && szTmpPath[1] == RTPATH_SLASH)) 180 181 { 181 rc = RTPathGetCurrent(pszAbsPath, c chAbsPath);182 rc = RTPathGetCurrent(pszAbsPath, cbAbsPath); 182 183 if (RT_SUCCESS(rc)) 183 184 { … … 191 192 && (uintptr_t)&pszAbsPath[cch - 1] > (uintptr_t)pszTop && pszAbsPath[cch - 1] != RTPATH_SLASH) 192 193 { 193 if (cch + 1 < c chAbsPath)194 if (cch + 1 < cbAbsPath) 194 195 { 195 196 pszAbsPath[cch++] = RTPATH_SLASH; … … 274 275 if (RT_FAILURE(rc)) 275 276 { 276 LogFlow(("RTPathAbs(%p:{%s}, %p, %d): returns %Rrc\n", pszPath, pszPath, pszAbsPath, c chAbsPath, rc));277 LogFlow(("RTPathAbs(%p:{%s}, %p, %d): returns %Rrc\n", pszPath, pszPath, pszAbsPath, cbAbsPath, rc)); 277 278 return rc; 278 279 } … … 360 361 * Copy the result to the user buffer. 361 362 */ 362 if (cchTmpPath < c chAbsPath)363 if (cchTmpPath < cbAbsPath) 363 364 { 364 365 memcpy(pszAbsPath, szTmpPath, cchTmpPath + 1); … … 369 370 370 371 LogFlow(("RTPathAbs(%p:{%s}, %p:{%s}, %d): returns %Rrc\n", pszPath, pszPath, pszAbsPath, 371 RT_SUCCESS(rc) ? pszAbsPath : "<failed>", c chAbsPath, rc));372 RT_SUCCESS(rc) ? pszAbsPath : "<failed>", cbAbsPath, rc)); 372 373 return rc; 373 374 } 374 375 376 #else 377 378 RTDECL(int) RTPathAbs(const char *pszPath, char *pszAbsPath, size_t cbAbsPath) 379 { 380 return RTPathAbsExEx(NULL, pszPath, RTPATH_STR_F_STYLE_HOST, pszAbsPath, &cbAbsPath); 381 } 382 383 #endif 384 -
trunk/src/VBox/Runtime/generic/RTPathGetCurrentDrive-generic.cpp
r76553 r78048 35 35 #include <iprt/ctype.h> 36 36 #include <iprt/err.h> 37 #include <iprt/mem.h> 37 38 #include <iprt/string.h> 38 39 #include "internal/path.h" … … 45 46 * Query the current directroy and extract the wanted information from it. 46 47 */ 47 int rc = RTPathGetCurrent(pszPath, cbPath); 48 char *pszPathFree = NULL; 49 char *pszCwd = pszPath; 50 int rc = RTPathGetCurrent(pszCwd, cbPath); 51 if (RT_SUCCESS(rc)) 52 { /* likely */ } 53 else if (rc != VERR_BUFFER_OVERFLOW) 54 return rc; 55 else 56 { 57 pszPathFree = pszCwd = (char *)RTMemTmpAlloc(RTPATH_BIG_MAX); 58 AssertReturn(pszPathFree, VERR_NO_TMP_MEMORY); 59 rc = RTPathGetCurrent(pszCwd, RTPATH_BIG_MAX); 60 } 48 61 if (RT_SUCCESS(rc)) 49 62 { … … 51 64 * Drive letter? Chop off at root slash. 52 65 */ 53 if (pszPath[0] && RTPATH_IS_VOLSEP(pszPath[1])) 54 { 55 pszPath[2] = '\0'; 56 return rc; 57 } 58 66 if (pszCwd[0] && RTPATH_IS_VOLSEP(pszCwd[1])) 67 pszCwd[2] = '\0'; 59 68 /* 60 69 * UNC? Chop off after share. 61 70 */ 62 if ( RTPATH_IS_SLASH(pszPath[0])63 && RTPATH_IS_SLASH(pszPath[1])64 && !RTPATH_IS_SLASH(pszPath[2])65 && pszPath[2])71 else if ( RTPATH_IS_SLASH(pszCwd[0]) 72 && RTPATH_IS_SLASH(pszCwd[1]) 73 && !RTPATH_IS_SLASH(pszCwd[2]) 74 && pszCwd[2]) 66 75 { 67 76 /* Work thru the server name. */ 68 77 size_t off = 3; 69 while (!RTPATH_IS_SLASH(psz Path[off]) && pszPath[off])78 while (!RTPATH_IS_SLASH(pszCwd[off]) && pszCwd[off]) 70 79 off++; 71 80 size_t offServerSlash = off; 72 81 73 82 /* Is there a share name? */ 74 if (RTPATH_IS_SLASH(psz Path[off]))83 if (RTPATH_IS_SLASH(pszCwd[off])) 75 84 { 76 while (RTPATH_IS_SLASH(psz Path[off]))85 while (RTPATH_IS_SLASH(pszCwd[off])) 77 86 off++; 78 if (psz Path[off])87 if (pszCwd[off]) 79 88 { 80 89 /* Work thru the share name. */ 81 while (!RTPATH_IS_SLASH(psz Path[off]) && pszPath[off])90 while (!RTPATH_IS_SLASH(pszCwd[off]) && pszCwd[off]) 82 91 off++; 83 92 } … … 86 95 off = offServerSlash; 87 96 } 97 pszCwd[off] = '\0'; 88 98 } 89 return VERR_INTERNAL_ERROR_4; 99 else 100 rc = VERR_INTERNAL_ERROR_4; 101 } 102 if (pszPathFree) 103 { 104 if (RT_SUCCESS(rc)) 105 rc = RTStrCopy(pszPath, cbPath, pszCwd); 106 RTMemTmpFree(pszPathFree); 90 107 } 91 108 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.