Changeset 28915 in vbox for trunk/src/VBox/Runtime/r3
- Timestamp:
- Apr 29, 2010 6:12:35 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 60863
- Location:
- trunk/src/VBox/Runtime/r3
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/darwin/pathhost-darwin.cpp
r28880 r28915 41 41 42 42 43 int rtPathToNative(c har **ppszNativePath, const char *pszPath)43 int rtPathToNative(const char **ppszNativePath, const char *pszPath, const char *pszBasePath) 44 44 { 45 45 /** @todo We should decompose the string here, but the file system will do 46 46 * that for us if we don't, so why bother. */ 47 47 *ppszNativePath = (char *)pszPath; 48 NOREF(pszBasePath); /* We don't query the FS for codeset preferences. */ 48 49 return VINF_SUCCESS; 49 50 } 50 51 51 52 52 int rtPathToNativeEx(char **ppszNativePath, const char *pszPath, const char *pszBasePath)53 void rtPathFreeNative(char const *pszNativePath, const char *pszPath) 53 54 { 54 NOREF(pszBasePath); 55 return rtPathToNative(ppszNativePath, pszPath); 56 } 57 58 59 void rtPathFreeNative(char *pszNativePath, const char *pszPath) 60 { 61 Assert((const char *)pszNativePath == pszPath || !pszNativePath); 55 Assert(pszNativePath == pszPath || !pszNativePath); 62 56 NOREF(pszNativePath); 63 57 NOREF(pszPath); … … 65 59 66 60 67 int rtPathFromNative(char **ppszPath, const char *pszNativePath)61 int rtPathFromNative(char const **ppszPath, const char *pszNativePath, const char *pszBasePath) 68 62 { 69 63 /** @todo We must compose the codepoints in the string here. We get file names 70 64 * in normalization form D so we'll end up with normalization form C 71 65 * whatever approach we take. */ 72 return RTStrDupEx(ppszPath, pszNativePath); 66 int rc = RTStrValidateEncodingEx(pszNativePath, RTSTR_MAX, 0 /*fFlags*/); 67 if (RT_SUCCESS(rc)) 68 *ppszPath = pszNativePath; 69 NOREF(pszBasePath); /* We don't query the FS for codeset preferences. */ 70 return rc; 73 71 } 74 72 75 73 76 int rtPathFromNativeEx(char **ppszPath, const char *pszNativePath, const char *pszBasePath)74 void rtPathFreeIprt(const char *pszPath, const char *pszNativePath) 77 75 { 78 NOREF(pszBasePath);79 return rtPathFromNative(ppszPath,pszNativePath);76 Assert(pszPath == pszNativePath || !pszPath); 77 NOREF(pszPath); NOREF(pszNativePath); 80 78 } 81 79 80 81 int rtPathFromNativeCopy(char *pszPath, size_t cbPath, const char *pszNativePath, const char *pszBasePath) 82 { 83 /** @todo We must compose the codepoints in the string here. We get file names 84 * in normalization form D so we'll end up with normalization form C 85 * whatever approach we take. */ 86 int rc = RTStrValidateEncodingEx(pszNativePath, RTSTR_MAX, 0 /*fFlags*/); 87 if (RT_SUCCESS(rc)) 88 rc = RTStrCopyEx(pszPath, cbPath, pszNativePath, RTSTR_MAX); 89 NOREF(pszBasePath); /* We don't query the FS for codeset preferences. */ 90 return rc; 91 } 92 -
trunk/src/VBox/Runtime/r3/darwin/rtProcInitExePath-darwin.cpp
r28800 r28915 49 49 AssertReturn(pszImageName, VERR_INTERNAL_ERROR); 50 50 51 char *pszTmp; 52 int rc = rtPathFromNative(&pszTmp, pszImageName); 51 int rc = rtPathFromNativeCopy(pszPath, cchPath, pszImageName, NULL); 53 52 AssertMsgRCReturn(rc, ("rc=%Rrc pszLink=\"%s\"\nhex: %.*Rhsx\n", rc, pszPath, strlen(pszImageName), pszPath), rc); 54 55 size_t cch = strlen(pszTmp);56 AssertReturn(cch <= cchPath, VERR_BUFFER_OVERFLOW);57 58 memcpy(pszPath, pszTmp, cch + 1);59 RTStrFree(pszTmp);60 53 61 54 return VINF_SUCCESS; -
trunk/src/VBox/Runtime/r3/dir.cpp
r28800 r28915 648 648 * Hand it over to the native part. 649 649 */ 650 rc = rt OpenDirNative(pDir, szRealPath);650 rc = rtDirNativeOpen(pDir, szRealPath); 651 651 if (RT_SUCCESS(rc)) 652 652 *ppDir = pDir; -
trunk/src/VBox/Runtime/r3/freebsd/rtProcInitExePath-freebsd.cpp
r28800 r28915 56 56 if (sysctl(aiName, RT_ELEMENTS(aiName), pszPath, &cchExePath, NULL, 0) == 0) 57 57 { 58 59 char *pszTmp = NULL; 60 int rc = rtPathFromNative(&pszTmp, pszPath); 58 const char *pszTmp; 59 int rc = rtPathFromNative(&pszTmp, pszPath, NULL); 61 60 AssertMsgRCReturn(rc, ("rc=%Rrc pszPath=\"%s\"\nhex: %.*Rhsx\n", rc, pszPath, cchExePath, pszPath), rc); 62 63 size_t cch = strlen(pszTmp); 64 AssertReturn(cch <= cchPath, VERR_BUFFER_OVERFLOW); 65 66 memcpy(pszPath, pszTmp, cch + 1); 67 RTStrFree(pszTmp); 68 69 return VINF_SUCCESS; 61 if (pszTmp != pszPath) 62 { 63 rc = RTStrCopy(pszPath, cchPath, pszTmp); 64 rtPathFreeIprt(pszTmp, pszPath); 65 } 66 return rc; 70 67 } 71 68 … … 84 81 pszPath[cchLink] = '\0'; 85 82 86 char *pszTmp = NULL;83 char const *pszTmp; 87 84 int rc = rtPathFromNative(&pszTmp, pszPath); 88 85 AssertMsgRCReturn(rc, ("rc=%Rrc pszLink=\"%s\"\nhex: %.*Rhsx\n", rc, pszPath, cchLink, pszPath), rc); 89 90 size_t cch = strlen(pszTmp); 91 AssertReturn(cch <= cchPath, VERR_BUFFER_OVERFLOW); 92 93 memcpy(pszPath, pszTmp, cch + 1); 94 RTStrFree(pszTmp); 95 96 return VINF_SUCCESS; 86 if (pszTmp != pszPath) 87 { 88 rc = RTStrCopy(pszPath, cchPath, pszTmp); 89 rtPathFreeIprt(pszTmp); 90 } 91 return rc; 97 92 } 98 93 … … 111 106 if (*pszImageName == '/') /* this may not always be absolute, despite the docs. :-( */ 112 107 { 113 char *pszTmp = NULL;114 int rc = rtPathFromNative(&pszTmp, pszImageName );108 char const *pszTmp; 109 int rc = rtPathFromNative(&pszTmp, pszImageName, NULL); 115 110 AssertMsgRCReturn(rc, ("rc=%Rrc pszImageName=\"%s\"\n", rc, pszImageName), rc); 116 117 size_t cch = strlen(pszTmp); 118 AssertReturn(cch <= cchPath, VERR_BUFFER_OVERFLOW); 119 120 memcpy(pszPath, pszTmp, cch + 1); 121 RTStrFree(pszTmp); 122 123 return VINF_SUCCESS; 111 if (pszTmp != pszPath) 112 { 113 rc = RTStrCopy(pszPath, cchPath, pszTmp); 114 rtPathFreeIprt(pszTmp, pszPath); 115 } 116 return rc; 124 117 } 125 118 /** @todo Try search the PATH for the file name or append the current -
trunk/src/VBox/Runtime/r3/linux/rtProcInitExePath-linux.cpp
r28800 r28915 50 50 pszPath[cchLink] = '\0'; 51 51 52 char *pszTmp = NULL;53 int rc = rtPathFromNative(&pszTmp, pszPath );52 char const *pszTmp; 53 int rc = rtPathFromNative(&pszTmp, pszPath, NULL); 54 54 AssertMsgRCReturn(rc, ("rc=%Rrc pszLink=\"%s\"\nhex: %.*Rhsx\n", rc, pszPath, cchLink, pszPath), rc); 55 56 size_t cch = strlen(pszTmp); 57 AssertReturn(cch <= cchPath, VERR_BUFFER_OVERFLOW); 58 59 memcpy(pszPath, pszTmp, cch + 1); 60 RTStrFree(pszTmp); 61 62 return VINF_SUCCESS; 55 if (pszTmp != pszPath) 56 { 57 rc = RTStrCopy(pszPath, cchPath, pszTmp); 58 rtPathFreeIprt(pszTmp, pszPath); 59 } 60 return rc; 63 61 } 64 62 -
trunk/src/VBox/Runtime/r3/os2/rtProcInitExePath-os2.cpp
r28800 r28915 48 48 _execname(pszPath, cchPath); 49 49 50 char *pszTmp;51 int rc = rtPathFromNative(&pszTmp, pszPath );50 char const *pszTmp; 51 int rc = rtPathFromNative(&pszTmp, pszPath, NULL); 52 52 AssertMsgRCReturn(rc, ("rc=%Rrc pszLink=\"%s\"\nhex: %.*Rhsx\n", rc, pszPath, cchPath, pszPath), rc); 53 54 size_t cch = strlen(pszTmp); 55 AssertReturn(cch <= cchPath, VERR_BUFFER_OVERFLOW); 56 57 memcpy(pszPath, pszTmp, cch + 1); 58 RTStrFree(pszTmp); 59 60 return VINF_SUCCESS; 53 if (pszTmp != pszPath) 54 { 55 rc = RTStrCopy(pszPath, cchPath, pszTmp); 56 rtPathFreeIprt(pszTmp, pszPath); 57 } 58 return rc; 61 59 } 62 60 -
trunk/src/VBox/Runtime/r3/path.cpp
r28800 r28915 71 71 { 72 72 #if !defined(RT_OS_WINDOWS) && defined(RTPATH_APP_PRIVATE) 73 char *pszUtf8Path; 74 int rc; 75 rc = rtPathFromNative(&pszUtf8Path, RTPATH_APP_PRIVATE); 76 if (RT_SUCCESS(rc)) 77 { 78 size_t cchPathPrivateNoArch = strlen(pszUtf8Path); 79 if (cchPathPrivateNoArch < cchPath) 80 memcpy(pszPath, pszUtf8Path, cchPathPrivateNoArch + 1); 81 else 82 rc = VERR_BUFFER_OVERFLOW; 83 RTStrFree(pszUtf8Path); 84 } 85 return rc; 73 return RTStrCopyEx(pszPath, cchPath, RTPATH_APP_PRIVATE, RTSTR_MAX); 86 74 #else 87 75 return RTPathExecDir(pszPath, cchPath); … … 105 93 { 106 94 #if !defined(RT_OS_WINDOWS) && defined(RTPATH_APP_PRIVATE_ARCH) 107 char *pszUtf8Path; 108 int rc; 109 rc = rtPathFromNative(&pszUtf8Path, RTPATH_APP_PRIVATE_ARCH); 110 if (RT_SUCCESS(rc)) 111 { 112 size_t cchPathPrivateArch = strlen(pszUtf8Path); 113 if (cchPathPrivateArch < cchPath) 114 memcpy(pszPath, pszUtf8Path, cchPathPrivateArch + 1); 115 else 116 rc = VERR_BUFFER_OVERFLOW; 117 RTStrFree(pszUtf8Path); 118 } 119 return rc; 95 return RTStrCopyEx(pszPath, cchPath, RTPATH_APP_PRIVATE_ARCH, RTSTR_MAX); 120 96 #else 121 97 return RTPathExecDir(pszPath, cchPath); … … 140 116 { 141 117 #if !defined(RT_OS_WINDOWS) && defined(RTPATH_SHARED_LIBS) 142 char *pszUtf8Path; 143 int rc; 144 rc = rtPathFromNative(&pszUtf8Path, RTPATH_SHARED_LIBS); 145 if (RT_SUCCESS(rc)) 146 { 147 size_t cchPathSharedLibs = strlen(pszUtf8Path); 148 if (cchPathSharedLibs < cchPath) 149 memcpy(pszPath, pszUtf8Path, cchPathSharedLibs + 1); 150 else 151 rc = VERR_BUFFER_OVERFLOW; 152 RTStrFree(pszUtf8Path); 153 } 154 return rc; 118 return RTStrCopyEx(pszPath, cchPath, RTPATH_SHARED_LIBS, RTSTR_MAX); 155 119 #else 156 120 return RTPathExecDir(pszPath, cchPath); … … 173 137 { 174 138 #if !defined(RT_OS_WINDOWS) && defined(RTPATH_APP_DOCS) 175 char *pszUtf8Path; 176 int rc; 177 rc = rtPathFromNative(&pszUtf8Path, RTPATH_APP_DOCS); 178 if (RT_SUCCESS(rc)) 179 { 180 size_t cchPathAppDocs = strlen(pszUtf8Path); 181 if (cchPathAppDocs < cchPath) 182 memcpy(pszPath, pszUtf8Path, cchPathAppDocs + 1); 183 else 184 rc = VERR_BUFFER_OVERFLOW; 185 RTStrFree(pszUtf8Path); 186 } 187 return rc; 139 return RTStrCopyEx(pszPath, cchPath, RTPATH_APP_DOCS, RTSTR_MAX); 188 140 #else 189 141 return RTPathExecDir(pszPath, cchPath); -
trunk/src/VBox/Runtime/r3/posix/dir-posix.cpp
r28877 r28915 62 62 { 63 63 bool fRc = false; 64 char *pszNativePath;65 int rc = rtPathToNative(&pszNativePath, pszPath );64 char const *pszNativePath; 65 int rc = rtPathToNative(&pszNativePath, pszPath, NULL); 66 66 if (RT_SUCCESS(rc)) 67 67 { … … 84 84 if (rtFsModeIsValidPermissions(fMode)) 85 85 { 86 char *pszNativePath;87 rc = rtPathToNative(&pszNativePath, pszPath );86 char const *pszNativePath; 87 rc = rtPathToNative(&pszNativePath, pszPath, NULL); 88 88 if (RT_SUCCESS(rc)) 89 89 { … … 124 124 RTDECL(int) RTDirRemove(const char *pszPath) 125 125 { 126 char *pszNativePath;127 int rc = rtPathToNative(&pszNativePath, pszPath );126 char const *pszNativePath; 127 int rc = rtPathToNative(&pszNativePath, pszPath, NULL); 128 128 if (RT_SUCCESS(rc)) 129 129 { … … 174 174 175 175 176 int rt OpenDirNative(PRTDIR pDir, char *pszPathBuf)176 int rtDirNativeOpen(PRTDIR pDir, char *pszPathBuf) 177 177 { 178 178 /* 179 179 * Convert to a native path and try opendir. 180 180 */ 181 char *pszNativePath;182 int rc = rtPathToNative(&pszNativePath, pDir->pszPath );181 char const *pszNativePath; 182 int rc = rtPathToNative(&pszNativePath, pDir->pszPath, NULL); 183 183 if (RT_SUCCESS(rc)) 184 184 { … … 267 267 if (!pDir->pszName) 268 268 { 269 int rc = rtPathFromNative Ex(&pDir->pszName, pDir->Data.d_name, pDir->pszPath);269 int rc = rtPathFromNative(&pDir->pszName, pDir->Data.d_name, pDir->pszPath); 270 270 if (RT_FAILURE(rc)) 271 271 { … … 278 278 || pDir->pfnFilter(pDir, pDir->pszName)) 279 279 break; 280 RTStrFree(pDir->pszName);280 rtPathFreeIprt(pDir->pszName, pDir->Data.d_name); 281 281 pDir->pszName = NULL; 282 282 #else … … 377 377 pDir->fDataUnread = false; 378 378 #ifndef RT_DONT_CONVERT_FILENAMES 379 RTStrFree(pDir->pszName);379 rtPathFreeIprt(pDir->pszName, pDir->Data.d_name); 380 380 pDir->pszName = NULL; 381 381 #endif … … 502 502 pDir->fDataUnread = false; 503 503 #ifndef RT_DONT_CONVERT_FILENAMES 504 RTStrFree(pDir->pszName);504 rtPathFreeIprt(pDir->pszName, pDir->Data.d_name); 505 505 pDir->pszName = NULL; 506 506 #endif -
trunk/src/VBox/Runtime/r3/posix/fileio-posix.cpp
r28877 r28915 92 92 { 93 93 bool fRc = false; 94 char *pszNativePath;95 int rc = rtPathToNative(&pszNativePath, pszPath );94 char const *pszNativePath; 95 int rc = rtPathToNative(&pszNativePath, pszPath, NULL); 96 96 if (RT_SUCCESS(rc)) 97 97 { … … 205 205 int iErr = errno; 206 206 #else 207 char *pszNativeFilename;208 rc = rtPathToNative(&pszNativeFilename, pszFilename );207 char const *pszNativeFilename; 208 rc = rtPathToNative(&pszNativeFilename, pszFilename, NULL); 209 209 if (RT_FAILURE(rc)) 210 210 return (rc); … … 372 372 RTR3DECL(int) RTFileDelete(const char *pszFilename) 373 373 { 374 char *pszNativeFilename;375 int rc = rtPathToNative(&pszNativeFilename, pszFilename );374 char const *pszNativeFilename; 375 int rc = rtPathToNative(&pszNativeFilename, pszFilename, NULL); 376 376 if (RT_SUCCESS(rc)) 377 377 { -
trunk/src/VBox/Runtime/r3/posix/fs-posix.cpp
r28877 r28915 56 56 * Convert the path and query the information. 57 57 */ 58 char *pszNativeFsPath;59 int rc = rtPathToNative(&pszNativeFsPath, pszFsPath );58 char const *pszNativeFsPath; 59 int rc = rtPathToNative(&pszNativeFsPath, pszFsPath, NULL); 60 60 if (RT_SUCCESS(rc)) 61 61 { … … 103 103 * We're simply return the device id. 104 104 */ 105 char *pszNativeFsPath;106 int rc = rtPathToNative(&pszNativeFsPath, pszFsPath );105 char const *pszNativeFsPath; 106 int rc = rtPathToNative(&pszNativeFsPath, pszFsPath, NULL); 107 107 if (RT_SUCCESS(rc)) 108 108 { … … 134 134 * Convert the path and query the information. 135 135 */ 136 char *pszNativeFsPath;137 int rc = rtPathToNative(&pszNativeFsPath, pszFsPath );136 char const *pszNativeFsPath; 137 int rc = rtPathToNative(&pszNativeFsPath, pszFsPath, NULL); 138 138 if (RT_SUCCESS(rc)) 139 139 { -
trunk/src/VBox/Runtime/r3/posix/path-posix.cpp
r28911 r28915 62 62 * Convert input. 63 63 */ 64 char *pszNativePath;65 int rc = rtPathToNative(&pszNativePath, pszPath );64 char const *pszNativePath; 65 int rc = rtPathToNative(&pszNativePath, pszPath, NULL); 66 66 if (RT_SUCCESS(rc)) 67 67 { … … 73 73 const char *psz = realpath(pszNativePath, szTmpPath); 74 74 if (psz) 75 { 76 /* 77 * Convert result and copy it to the return buffer. 78 */ 79 char *pszUtf8RealPath; 80 rc = rtPathFromNative(&pszUtf8RealPath, szTmpPath); 81 if (RT_SUCCESS(rc)) 82 { 83 size_t cch = strlen(pszUtf8RealPath) + 1; 84 if (cch <= cchRealPath) 85 memcpy(pszRealPath, pszUtf8RealPath, cch); 86 else 87 rc = VERR_BUFFER_OVERFLOW; 88 RTStrFree(pszUtf8RealPath); 89 } 90 } 75 rc = rtPathFromNativeCopy(pszRealPath, cchRealPath, szTmpPath, NULL); 91 76 else 92 77 rc = RTErrConvertFromErrno(errno); … … 360 345 * Convert it to UTF-8 and copy it to the return buffer. 361 346 */ 362 char *pszUtf8Path; 363 rc = rtPathFromNative(&pszUtf8Path, pPasswd->pw_dir); 364 if (RT_SUCCESS(rc)) 365 { 366 size_t cchHome = strlen(pszUtf8Path); 367 if (cchHome < cchPath) 368 memcpy(pszPath, pszUtf8Path, cchHome + 1); 369 else 370 rc = VERR_BUFFER_OVERFLOW; 371 RTStrFree(pszUtf8Path); 372 } 373 return rc; 347 return rtPathFromNativeCopy(pszPath, cchPath, pPasswd->pw_dir, NULL); 374 348 } 375 349 #endif … … 389 363 * Get HOME env. var it and validate it's existance. 390 364 */ 391 int rc= VERR_PATH_NOT_FOUND;392 const char *pszHome = RTEnvGet("HOME"); 365 int rc = VERR_PATH_NOT_FOUND; 366 const char *pszHome = RTEnvGet("HOME"); /** @todo Codeset confusion in RTEnv. */ 393 367 if (pszHome) 394 368 … … 397 371 if ( !stat(pszHome, &st) 398 372 && S_ISDIR(st.st_mode)) 399 { 400 /* 401 * Convert it to UTF-8 and copy it to the return buffer. 402 */ 403 char *pszUtf8Path; 404 rc = rtPathFromNative(&pszUtf8Path, pszHome); 405 if (RT_SUCCESS(rc)) 406 { 407 size_t cchHome = strlen(pszUtf8Path); 408 if (cchHome < cchPath) 409 memcpy(pszPath, pszUtf8Path, cchHome + 1); 410 else 411 rc = VERR_BUFFER_OVERFLOW; 412 RTStrFree(pszUtf8Path); 413 } 414 } 373 rc = rtPathFromNativeCopy(pszPath, cchPath, pszHome, NULL); 415 374 } 416 375 return rc; … … 480 439 * Convert the filename. 481 440 */ 482 char *pszNativePath;483 int rc = rtPathToNative(&pszNativePath, pszPath );441 char const *pszNativePath; 442 int rc = rtPathToNative(&pszNativePath, pszPath, NULL); 484 443 if (RT_SUCCESS(rc)) 485 444 { … … 545 504 * Convert the paths. 546 505 */ 547 char *pszNativePath;548 int rc = rtPathToNative(&pszNativePath, pszPath );506 char const *pszNativePath; 507 int rc = rtPathToNative(&pszNativePath, pszPath, NULL); 549 508 if (RT_SUCCESS(rc)) 550 509 { … … 663 622 * Convert the paths. 664 623 */ 665 char *pszNativeSrc;666 int rc = rtPathToNative(&pszNativeSrc, pszSrc );624 char const *pszNativeSrc; 625 int rc = rtPathToNative(&pszNativeSrc, pszSrc, NULL); 667 626 if (RT_SUCCESS(rc)) 668 627 { 669 char *pszNativeDst;670 rc = rtPathToNative(&pszNativeDst, pszDst );628 char const *pszNativeDst; 629 rc = rtPathToNative(&pszNativeDst, pszDst, NULL); 671 630 if (RT_SUCCESS(rc)) 672 631 { … … 836 795 * Convert the path and check if it exists using stat(). 837 796 */ 838 char *pszNativePath;839 int rc = rtPathToNative(&pszNativePath, pszPath );797 char const *pszNativePath; 798 int rc = rtPathToNative(&pszNativePath, pszPath, NULL); 840 799 if (RT_SUCCESS(rc)) 841 800 { … … 860 819 char szNativeCurDir[RTPATH_MAX]; 861 820 if (getcwd(szNativeCurDir, sizeof(szNativeCurDir)) != NULL) 862 { 863 char *pszCurDir; 864 rc = rtPathFromNative(&pszCurDir, szNativeCurDir); 865 if (RT_SUCCESS(rc)) 866 { 867 size_t cchCurDir = strlen(pszCurDir); 868 if (cchCurDir < cchPath) 869 { 870 memcpy(pszPath, pszCurDir, cchCurDir + 1); 871 RTStrFree(pszCurDir); 872 return VINF_SUCCESS; 873 } 874 875 rc = VERR_BUFFER_OVERFLOW; 876 RTStrFree(pszCurDir); 877 } 878 } 821 rc = rtPathFromNativeCopy(pszPath, cchPath, szNativeCurDir, NULL); 879 822 else 880 823 rc = RTErrConvertFromErrno(errno); … … 894 837 * Change the directory. 895 838 */ 896 char *pszNativePath;897 int rc = rtPathToNative(&pszNativePath, pszPath );839 char const *pszNativePath; 840 int rc = rtPathToNative(&pszNativePath, pszPath, NULL); 898 841 if (RT_SUCCESS(rc)) 899 842 { -
trunk/src/VBox/Runtime/r3/posix/pathhost-posix.cpp
r28912 r28915 177 177 178 178 179 int rtPathToNative(char **ppszNativePath, const char *pszPath)179 int rtPathToNative(char const **ppszNativePath, const char *pszPath, const char *pszBasePath) 180 180 { 181 181 *ppszNativePath = NULL; … … 185 185 { 186 186 if (g_fPassthruUtf8 || !*pszPath) 187 *ppszNativePath = (char *)pszPath;187 *ppszNativePath = pszPath; 188 188 else 189 189 rc = rtStrConvert(pszPath, strlen(pszPath), "UTF-8", 190 ppszNativePath, 0, g_szFsCodeset,190 (char **)ppszNativePath, 0, g_szFsCodeset, 191 191 2, g_enmUtf8ToFsIdx); 192 192 } 193 NOREF(pszBasePath); /* We don't query the FS for codeset preferences. */ 193 194 return rc; 194 195 } 195 196 196 197 197 int rtPathToNativeEx(char **ppszNativePath, const char *pszPath, const char *pszBasePath) 198 { 199 /* We don't query the FS for codeset preferences yet, so nothing special to do here. */ 200 NOREF(pszBasePath); 201 return rtPathToNative(ppszNativePath, pszPath); 202 } 203 204 205 void rtPathFreeNative(char *pszNativePath, const char *pszPath) 198 void rtPathFreeNative(char const *pszNativePath, const char *pszPath) 206 199 { 207 200 if ( pszNativePath != pszPath 208 201 && pszNativePath) 209 RTStrFree( pszNativePath);210 } 211 212 213 int rtPathFromNative(c har **ppszPath, const char *pszNativePath)202 RTStrFree((char *)pszNativePath); 203 } 204 205 206 int rtPathFromNative(const char **ppszPath, const char *pszNativePath, const char *pszBasePath) 214 207 { 215 208 *ppszPath = NULL; … … 235 228 else 236 229 rc = rtStrConvert(pszNativePath, strlen(pszNativePath), g_szFsCodeset, 237 ppszPath, 0, "UTF-8",230 (char **)ppszPath, 0, "UTF-8", 238 231 2, g_enmFsToUtf8Idx); 239 232 } 233 NOREF(pszBasePath); /* We don't query the FS for codeset preferences. */ 240 234 return rc; 241 235 } 242 236 243 237 244 int rtPathFromNativeEx(char **ppszPath, const char *pszNativePath, const char *pszBasePath) 245 { 246 /* We don't query the FS for codeset preferences yet, so nothing special to do here. */ 247 NOREF(pszBasePath); 248 return rtPathFromNative(ppszPath, pszNativePath); 249 } 250 238 void rtPathFreeIprt(const char *pszPath, const char *pszNativePath) 239 { 240 if ( pszPath != pszNativePath 241 && !pszPath) 242 RTStrFree((char *)pszPath); 243 } 244 245 246 int rtPathFromNativeCopy(char *pszPath, size_t cbPath, const char *pszNativePath, const char *pszBasePath) 247 { 248 int rc = RTOnce(&g_OnceInitPathConv, rtPathConvInitOnce, NULL, NULL); 249 if (RT_SUCCESS(rc)) 250 { 251 if (g_fPassthruUtf8 || !*pszNativePath) 252 rc = RTStrCopyEx(pszPath, cbPath, pszNativePath, RTSTR_MAX); 253 else if (cbPath) 254 rc = rtStrConvert(pszNativePath, strlen(pszNativePath), g_szFsCodeset, 255 &pszPath, cbPath, "UTF-8", 256 2, g_enmFsToUtf8Idx); 257 else 258 rc = VERR_BUFFER_OVERFLOW; 259 } 260 261 NOREF(pszBasePath); /* We don't query the FS for codeset preferences. */ 262 return rc; 263 } 264 -
trunk/src/VBox/Runtime/r3/solaris/rtProcInitExePath-solaris.cpp
r28800 r28915 52 52 pszPath[cchLink] = '\0'; 53 53 54 char *pszTmp = NULL;55 int rc = rtPathFromNative(&pszTmp, pszPath );54 char const *pszTmp; 55 int rc = rtPathFromNative(&pszTmp, pszPath, NULL); 56 56 AssertMsgRCReturn(rc, ("rc=%Rrc pszLink=\"%s\"\nhex: %.*Rhsx\n", rc, pszPath, cchLink, pszPath), rc); 57 58 size_t cch = strlen(pszTmp); 59 AssertReturn(cch <= cchPath, VERR_BUFFER_OVERFLOW); 60 61 memcpy(pszPath, pszTmp, cch + 1); 62 RTStrFree(pszTmp); 63 64 return VINF_SUCCESS; 57 if (pszTmp != pszPath) 58 { 59 rc = RTStrCopy(pszPath, cchPath, pszTmp); 60 rtPathFreeIprt(pszTmp, pszPath); 61 } 62 return rc; 65 63 } 66 64 -
trunk/src/VBox/Runtime/r3/win/dir-win.cpp
r28800 r28915 130 130 131 131 132 int rt OpenDirNative(PRTDIR pDir, char *pszPathBuf)132 int rtDirNativeOpen(PRTDIR pDir, char *pszPathBuf) 133 133 { 134 134 /*
Note:
See TracChangeset
for help on using the changeset viewer.