Changeset 78098 in vbox
- Timestamp:
- Apr 10, 2019 3:51:59 PM (5 years ago)
- Location:
- trunk
- Files:
-
- 1 deleted
- 10 edited
- 1 moved
-
include/iprt/mangling.h (modified) (1 diff)
-
include/iprt/path.h (modified) (2 diffs)
-
src/VBox/HostServices/SharedFolders/vbsfpathabs.cpp (modified) (1 diff)
-
src/VBox/Main/src-server/MachineImpl.cpp (modified) (1 diff)
-
src/VBox/Main/src-server/VirtualBoxImpl.cpp (modified) (1 diff)
-
src/VBox/Runtime/Makefile.kmk (modified) (13 diffs)
-
src/VBox/Runtime/common/path/RTPathAbsEx.cpp (moved) (moved from trunk/src/VBox/Runtime/common/path/RTPathAbsExEx.cpp ) (16 diffs)
-
src/VBox/Runtime/common/path/RTPathAbsExDup.cpp (modified) (2 diffs)
-
src/VBox/Runtime/generic/RTPathAbs-generic.cpp (deleted)
-
src/VBox/Runtime/r3/generic/dirrel-r3-generic.cpp (modified) (1 diff)
-
src/VBox/Runtime/r3/nt/dirrel-r3-nt.cpp (modified) (1 diff)
-
src/VBox/Runtime/testcase/tstRTPath.cpp (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/mangling.h
r78066 r78098 1600 1600 # define RTPathAbsDup RT_MANGLER(RTPathAbsDup) 1601 1601 # define RTPathAbsEx RT_MANGLER(RTPathAbsEx) 1602 # define RTPathAbsExEx RT_MANGLER(RTPathAbsExEx)1603 1602 # define RTPathAbsExDup RT_MANGLER(RTPathAbsExDup) 1604 1603 # define RTPathAppDocs RT_MANGLER(RTPathAppDocs) -
trunk/include/iprt/path.h
r78051 r78098 332 332 /** 333 333 * Get the absolute path (no symlinks, no . or .. components), assuming the 334 * given base path as the current directory. The resulting path doesn't have335 * to exist.336 *337 * @returns iprt status code.338 * @param pszBase The base path to act like a current directory.339 * When NULL, the actual cwd is used (i.e. the call340 * is equivalent to RTPathAbs(pszPath, ...).341 * @param pszPath The path to resolve.342 * @param pszAbsPath Where to store the absolute path.343 * @param cbAbsPath Size of the buffer.344 *345 * @note Current implementation is buggy and will remove trailing slashes346 * that would normally specify a directory. Don't depend on this.347 */348 RTDECL(int) RTPathAbsEx(const char *pszBase, const char *pszPath, char *pszAbsPath, size_t cbAbsPath);349 350 /**351 * Get the absolute path (no symlinks, no . or .. components), assuming the352 334 * given base path as the current directory. 353 335 * … … 369 351 * failures. 370 352 */ 371 RTDECL(int) RTPathAbsEx Ex(const char *pszBase, const char *pszPath, uint32_t fFlags, char *pszAbsPath, size_t *pcbAbsPath);353 RTDECL(int) RTPathAbsEx(const char *pszBase, const char *pszPath, uint32_t fFlags, char *pszAbsPath, size_t *pcbAbsPath); 372 354 373 355 /** @name RTPATHABS_F_XXX - Flags for RTPathAbsEx. -
trunk/src/VBox/HostServices/SharedFolders/vbsfpathabs.cpp
r78090 r78098 185 185 /* Fallback for the common paths. */ 186 186 187 return RTPathAbsEx Ex(pszRoot, pszPath, RTPATH_STR_F_STYLE_HOST, pszAbsPath, &cbAbsPath);187 return RTPathAbsEx(pszRoot, pszPath, RTPATH_STR_F_STYLE_HOST, pszAbsPath, &cbAbsPath); 188 188 } -
trunk/src/VBox/Main/src-server/MachineImpl.cpp
r78090 r78098 7260 7260 char szFolder[RTPATH_MAX]; 7261 7261 size_t cbFolder = sizeof(szFolder); 7262 int vrc = RTPathAbsEx Ex(strSettingsDir.c_str(), strPath.c_str(), RTPATH_STR_F_STYLE_HOST, szFolder, &cbFolder);7262 int vrc = RTPathAbsEx(strSettingsDir.c_str(), strPath.c_str(), RTPATH_STR_F_STYLE_HOST, szFolder, &cbFolder); 7263 7263 if (RT_SUCCESS(vrc)) 7264 7264 aResult = szFolder; -
trunk/src/VBox/Main/src-server/VirtualBoxImpl.cpp
r78090 r78098 4014 4014 char szFolder[RTPATH_MAX]; 4015 4015 size_t cbFolder = sizeof(szFolder); 4016 int vrc = RTPathAbsEx Ex(m->strHomeDir.c_str(),4017 strPath.c_str(),4018 RTPATH_STR_F_STYLE_HOST,4019 szFolder,4020 &cbFolder);4016 int vrc = RTPathAbsEx(m->strHomeDir.c_str(), 4017 strPath.c_str(), 4018 RTPATH_STR_F_STYLE_HOST, 4019 szFolder, 4020 &cbFolder); 4021 4021 if (RT_SUCCESS(vrc)) 4022 4022 aResult = szFolder; -
trunk/src/VBox/Runtime/Makefile.kmk
r78096 r78098 512 512 common/path/RTPathAbsEx.cpp \ 513 513 common/path/RTPathAbsExDup.cpp \ 514 common/path/RTPathAbsExEx.cpp \515 514 common/path/RTPathAppend.cpp \ 516 515 common/path/RTPathAppendEx.cpp \ … … 827 826 generic/RTMpGetCurFrequency-generic.cpp \ 828 827 generic/RTMpGetMaxFrequency-generic.cpp \ 829 generic/RTPathAbs-generic.cpp \830 828 generic/RTRandAdvCreateSystemFaster-generic.cpp \ 831 829 generic/RTRandAdvCreateSystemTruer-generic.cpp \ … … 917 915 generic/RTFileMove-generic.cpp \ 918 916 generic/RTLogWriteDebugger-generic.cpp \ 919 generic/RTPathAbs-generic.cpp \920 917 generic/RTPathGetCurrentOnDrive-generic.cpp \ 921 918 generic/RTProcDaemonize-generic.cpp \ … … 1024 1021 generic/RTFileSetAllocationSize-generic.cpp \ 1025 1022 generic/RTLogWriteDebugger-generic.cpp \ 1026 generic/RTPathAbs-generic.cpp \1027 1023 generic/RTPathGetCurrentOnDrive-generic.cpp \ 1028 1024 generic/RTProcDaemonize-generic.cpp \ … … 1106 1102 generic/RTFileSetAllocationSize-generic.cpp \ 1107 1103 generic/RTLogWriteDebugger-generic.cpp \ 1108 generic/RTPathAbs-generic.cpp \1109 1104 generic/RTPathGetCurrentOnDrive-generic.cpp \ 1110 1105 generic/RTProcDaemonize-generic.cpp \ … … 1192 1187 generic/RTFileSetAllocationSize-generic.cpp \ 1193 1188 generic/RTLogWriteDebugger-generic.cpp \ 1194 generic/RTPathAbs-generic.cpp \1195 1189 generic/RTPathGetCurrentOnDrive-generic.cpp \ 1196 1190 generic/RTSemEventMultiWait-2-ex-generic.cpp \ … … 1275 1269 generic/RTFileMove-generic.cpp \ 1276 1270 generic/RTLogWriteDebugger-generic.cpp \ 1277 generic/RTPathAbs-generic.cpp \1278 1271 generic/RTSemEventMultiWait-2-ex-generic.cpp \ 1279 1272 generic/RTSemEventMultiWaitNoResume-2-ex-generic.cpp \ … … 1357 1350 generic/RTFileMove-generic.cpp \ 1358 1351 generic/RTLogWriteDebugger-generic.cpp \ 1359 generic/RTPathAbs-generic.cpp \1360 1352 generic/RTPathGetCurrentOnDrive-generic.cpp \ 1361 1353 generic/RTProcDaemonize-generic.cpp \ … … 1454 1446 generic/RTFileSetAllocationSize-generic.cpp \ 1455 1447 generic/RTLogWriteDebugger-generic.cpp \ 1456 generic/RTPathAbs-generic.cpp \1457 1448 generic/RTPathGetCurrentOnDrive-generic.cpp \ 1458 1449 generic/RTProcDaemonize-generic.cpp \ … … 1707 1698 common/path/RTPathAbsEx.cpp \ 1708 1699 common/path/RTPathAbsExDup.cpp \ 1709 common/path/RTPathAbsExEx.cpp \1710 1700 common/path/RTPathAppend.cpp \ 1711 1701 common/path/RTPathAppendEx.cpp \ … … 1888 1878 generic/RTFileExists-generic.cpp \ 1889 1879 generic/RTFileSetAllocationSize-generic.cpp \ 1890 generic/RTPathAbs-generic.cpp \1891 1880 generic/RTRandAdvCreateSystemFaster-generic.cpp \ 1892 1881 generic/RTRandAdvCreateSystemTruer-generic.cpp \ … … 1957 1946 generic/RTFileSetAllocationSize-generic.cpp \ 1958 1947 generic/RTLogWriteDebugger-generic.cpp \ 1959 generic/RTPathAbs-generic.cpp \1960 1948 generic/RTPathGetCurrentOnDrive-generic.cpp \ 1961 1949 generic/RTRandAdvCreateSystemFaster-generic.cpp \ … … 2720 2708 common/path/RTPathAbsEx.cpp \ 2721 2709 common/path/RTPathAbsExDup.cpp \ 2722 common/path/RTPathAbsExEx.cpp \2723 2710 common/path/RTPathAppend.cpp \ 2724 2711 common/path/RTPathAppendEx.cpp \ -
trunk/src/VBox/Runtime/common/path/RTPathAbsEx.cpp
r78097 r78098 1 1 /* $Id$ */ 2 2 /** @file 3 * IPRT - RTPathAbsEx Ex3 * IPRT - RTPathAbsEx and RTPathAbs. 4 4 */ 5 5 … … 44 44 * Ensures that the drive letter is capitalized (prereq: RTPATH_PROP_VOLUME). 45 45 */ 46 DECLINLINE(void) rtPathAbsEx ExUpperCaseDriveLetter(char *pszAbsPath)46 DECLINLINE(void) rtPathAbsExUpperCaseDriveLetter(char *pszAbsPath) 47 47 { 48 48 AssertReturnVoid(pszAbsPath[1] == ':'); … … 58 58 * Uses RTPATHABS_F_STOP_AT_BASE for RTPATHABS_F_STOP_AT_CWD. 59 59 */ 60 static int rtPathAbsEx ExWithCwdOrBaseCommon(const char *pszBase, size_t cchBaseInPlace, PRTPATHPARSED pBaseParsed,61 const char *pszPath, PRTPATHPARSED pParsed, uint32_t fFlags,62 char *pszAbsPath, size_t *pcbAbsPath)60 static int rtPathAbsExWithCwdOrBaseCommon(const char *pszBase, size_t cchBaseInPlace, PRTPATHPARSED pBaseParsed, 61 const char *pszPath, PRTPATHPARSED pParsed, uint32_t fFlags, 62 char *pszAbsPath, size_t *pcbAbsPath) 63 63 { 64 64 AssertReturn(pBaseParsed->cComps > 0, VERR_INVALID_PARAMETER); … … 199 199 { 200 200 if (pBaseParsed->fProps & RTPATH_PROP_VOLUME) 201 rtPathAbsEx ExUpperCaseDriveLetter(pszAbsPath);201 rtPathAbsExUpperCaseDriveLetter(pszAbsPath); 202 202 203 203 cchBaseInPlace = pBaseParsed->cchPath; … … 232 232 * Handles the no-root-path scenario where we do CWD prefixing. 233 233 */ 234 static int rtPathAbsEx ExWithCwd(const char *pszPath, PRTPATHPARSED pParsed, uint32_t fFlags, char *pszAbsPath, size_t *pcbAbsPath)234 static int rtPathAbsExWithCwd(const char *pszPath, PRTPATHPARSED pParsed, uint32_t fFlags, char *pszAbsPath, size_t *pcbAbsPath) 235 235 { 236 236 /* … … 313 313 else 314 314 fFlags &= ~RTPATHABS_F_STOP_AT_BASE; 315 rc = rtPathAbsEx ExWithCwdOrBaseCommon(pszCwd, cchInPlace, pCwdParsed, pszPath, pParsed, fFlags, pszAbsPath, pcbAbsPath);315 rc = rtPathAbsExWithCwdOrBaseCommon(pszCwd, cchInPlace, pCwdParsed, pszPath, pParsed, fFlags, pszAbsPath, pcbAbsPath); 316 316 if (pCwdParsedFree) 317 317 RTMemTmpFree(pCwdParsedFree); … … 325 325 * Handles the no-root-path scenario where we've got a base path. 326 326 */ 327 static int rtPathAbsEx ExWithBase(const char *pszBase, const char *pszPath, PRTPATHPARSED pParsed, uint32_t fFlags,328 char *pszAbsPath, size_t *pcbAbsPath)327 static int rtPathAbsExWithBase(const char *pszBase, const char *pszPath, PRTPATHPARSED pParsed, uint32_t fFlags, 328 char *pszAbsPath, size_t *pcbAbsPath) 329 329 { 330 330 /* … … 362 362 { 363 363 cchInPlace = *pcbAbsPath; 364 rc = RTPathAbsEx Ex(NULL, pszBase, fFlags, pszAbsPath, &cchInPlace);364 rc = RTPathAbsEx(NULL, pszBase, fFlags, pszAbsPath, &cchInPlace); 365 365 if (RT_SUCCESS(rc)) 366 366 { … … 400 400 * Join paths with the CWD code. 401 401 */ 402 rc = rtPathAbsEx ExWithCwdOrBaseCommon(cchInPlace ? pszAbsPath : pszBase, cchInPlace, pBaseParsed,403 pszPath, pParsed, fFlags, pszAbsPath, pcbAbsPath);402 rc = rtPathAbsExWithCwdOrBaseCommon(cchInPlace ? pszAbsPath : pszBase, cchInPlace, pBaseParsed, 403 pszPath, pParsed, fFlags, pszAbsPath, pcbAbsPath); 404 404 if (pBaseParsedFree) 405 405 RTMemTmpFree(pBaseParsedFree); … … 411 411 * Handles the RTPATH_PROP_ROOT_SLASH case. 412 412 */ 413 static int rtPathAbsEx ExRootSlash(const char *pszBase, const char *pszPath, PRTPATHPARSED pParsed,414 uint32_t fFlags, char *pszAbsPath, size_t *pcbAbsPath)413 static int rtPathAbsExRootSlash(const char *pszBase, const char *pszPath, PRTPATHPARSED pParsed, 414 uint32_t fFlags, char *pszAbsPath, size_t *pcbAbsPath) 415 415 { 416 416 /* … … 482 482 return VERR_BUFFER_OVERFLOW; 483 483 } 484 rtPathAbsEx ExUpperCaseDriveLetter(pszAbsPath);484 rtPathAbsExUpperCaseDriveLetter(pszAbsPath); 485 485 } 486 486 else if (uBase.Parsed.fProps & RTPATH_PROP_UNC) … … 560 560 * Handles the RTPATH_PROP_ABSOLUTE case. 561 561 */ 562 static int rtPathAbsExExAbsolute(const char *pszPath, PRTPATHPARSED pParsed, 563 uint32_t fFlags, char *pszAbsPath, size_t *pcbAbsPath) 562 static int rtPathAbsExAbsolute(const char *pszPath, PRTPATHPARSED pParsed, uint32_t fFlags, char *pszAbsPath, size_t *pcbAbsPath) 564 563 { 565 564 if (pParsed->fProps & RTPATH_PROP_DOT_REFS) … … 574 573 *pcbAbsPath = pParsed->cchPath + (rc == VERR_BUFFER_OVERFLOW); 575 574 if (RT_SUCCESS(rc) && (pParsed->fProps & RTPATH_PROP_VOLUME)) 576 rtPathAbsEx ExUpperCaseDriveLetter(pszAbsPath);575 rtPathAbsExUpperCaseDriveLetter(pszAbsPath); 577 576 return rc; 578 577 } 579 578 580 579 581 RTDECL(int) RTPathAbsEx Ex(const char *pszBase, const char *pszPath, uint32_t fFlags, char *pszAbsPath, size_t *pcbAbsPath)580 RTDECL(int) RTPathAbsEx(const char *pszBase, const char *pszPath, uint32_t fFlags, char *pszAbsPath, size_t *pcbAbsPath) 582 581 { 583 582 /* … … 624 623 */ 625 624 if (pParsed->fProps & RTPATH_PROP_ABSOLUTE) 626 rc = rtPathAbsEx ExAbsolute(pszPath, pParsed, fFlags, pszAbsPath, pcbAbsPath);625 rc = rtPathAbsExAbsolute(pszPath, pParsed, fFlags, pszAbsPath, pcbAbsPath); 627 626 /* 628 627 * What about relative but with a root slash. 629 628 */ 630 629 else if (pParsed->fProps & RTPATH_PROP_ROOT_SLASH) 631 rc = rtPathAbsEx ExRootSlash(pszBase, pszPath, pParsed, fFlags, pszAbsPath, pcbAbsPath);630 rc = rtPathAbsExRootSlash(pszBase, pszPath, pParsed, fFlags, pszAbsPath, pcbAbsPath); 632 631 /* 633 632 * Not exactly perfect. No root slash. … … 646 645 ) 647 646 ) 648 rc = rtPathAbsEx ExWithBase(pszBase, pszPath, pParsed, fFlags, pszAbsPath, pcbAbsPath);649 else 650 rc = rtPathAbsEx ExWithCwd(pszPath, pParsed, fFlags, pszAbsPath, pcbAbsPath);647 rc = rtPathAbsExWithBase(pszBase, pszPath, pParsed, fFlags, pszAbsPath, pcbAbsPath); 648 else 649 rc = rtPathAbsExWithCwd(pszPath, pParsed, fFlags, pszAbsPath, pcbAbsPath); 651 650 652 651 if (pParsedFree) … … 655 654 } 656 655 656 657 RTDECL(int) RTPathAbs(const char *pszPath, char *pszAbsPath, size_t cbAbsPath) 658 { 659 return RTPathAbsEx(NULL, pszPath, RTPATH_STR_F_STYLE_HOST, pszAbsPath, &cbAbsPath); 660 } 661 -
trunk/src/VBox/Runtime/common/path/RTPathAbsExDup.cpp
r78090 r78098 51 51 char szPath[RTPATH_MAX]; 52 52 size_t cbPath = sizeof(szPath); 53 int rc = RTPathAbsEx Ex(pszBase, pszPath, RTPATH_STR_F_STYLE_HOST, szPath, &cbPath);53 int rc = RTPathAbsEx(pszBase, pszPath, RTPATH_STR_F_STYLE_HOST, szPath, &cbPath); 54 54 if (RT_SUCCESS(rc)) 55 55 return RTStrDup(szPath); … … 66 66 if (pszAbsPath) 67 67 { 68 rc = RTPathAbsEx Ex(pszBase, pszPath, RTPATH_STR_F_STYLE_HOST, pszAbsPath, &cbPath);68 rc = RTPathAbsEx(pszBase, pszPath, RTPATH_STR_F_STYLE_HOST, pszAbsPath, &cbPath); 69 69 if (RT_SUCCESS(rc)) 70 70 return pszAbsPath; -
trunk/src/VBox/Runtime/r3/generic/dirrel-r3-generic.cpp
r78090 r78098 84 84 * This ASSUMES that pThis->pszPath is an absolute path. 85 85 */ 86 int rc = RTPathAbsEx Ex(pThis->pszPath, pszRelPath, RTPATH_STR_F_STYLE_HOST, pszPathDst, &cbPathDst);86 int rc = RTPathAbsEx(pThis->pszPath, pszRelPath, RTPATH_STR_F_STYLE_HOST, pszPathDst, &cbPathDst); 87 87 if (RT_SUCCESS(rc)) 88 88 { -
trunk/src/VBox/Runtime/r3/nt/dirrel-r3-nt.cpp
r78090 r78098 95 95 * This ASSUMES that pThis->pszPath is an absolute path. 96 96 */ 97 int rc = RTPathAbsEx Ex(pThis->pszPath, pszRelPath, RTPATH_STR_F_STYLE_HOST, pszPathDst, &cbPathDst);97 int rc = RTPathAbsEx(pThis->pszPath, pszRelPath, RTPATH_STR_F_STYLE_HOST, pszPathDst, &cbPathDst); 98 98 if (RT_SUCCESS(rc)) 99 99 { -
trunk/src/VBox/Runtime/testcase/tstRTPath.cpp
r78090 r78098 267 267 268 268 269 #if 0 270 /* 271 * RTPathAbsEx 269 /* 270 * RTPathAbsEx. 272 271 */ 273 272 RTTestSub(hTest, "RTPathAbsEx"); 274 static const struct275 {276 const char *pcszInputBase;277 const char *pcszInputPath;278 int rc;279 const char *pcszOutput;280 }281 s_aRTPathAbsExTests[] =282 {283 #if defined (RT_OS_OS2) || defined (RT_OS_WINDOWS)284 { NULL, "", VERR_INVALID_PARAMETER, NULL },285 { NULL, ".", VINF_SUCCESS, "%p" },286 { NULL, "\\", VINF_SUCCESS, "%d\\" },287 { NULL, "\\..", VINF_SUCCESS, "%d\\" },288 { NULL, "/absolute/..", VINF_SUCCESS, "%d\\" },289 { NULL, "/absolute\\\\../..", VINF_SUCCESS, "%d\\" },290 { NULL, "/absolute//../path\\", VINF_SUCCESS, "%d\\path" },291 { NULL, "/absolute/../../path", VINF_SUCCESS, "%d\\path" },292 { NULL, "relative/../dir\\.\\.\\.\\file.txt", VINF_SUCCESS, "%p\\dir\\file.txt" },293 { NULL, "\\data\\", VINF_SUCCESS, "%d\\data" },294 { "relative_base/dir\\", "\\from_root", VINF_SUCCESS, "%d\\from_root" },295 { "relative_base/dir/", "relative_also", VINF_SUCCESS, "%p\\relative_base\\dir\\relative_also" },296 #else297 { NULL, "", VERR_INVALID_PARAMETER, NULL },298 { NULL, ".", VINF_SUCCESS, "%p" },299 { NULL, "/", VINF_SUCCESS, "/" },300 { NULL, "/..", VINF_SUCCESS, "/" },301 { NULL, "/absolute/..", VINF_SUCCESS, "/" },302 { NULL, "/absolute\\\\../..", VINF_SUCCESS, "/" },303 { NULL, "/absolute//../path/", VINF_SUCCESS, "/path" },304 { NULL, "/absolute/../../path", VINF_SUCCESS, "/path" },305 { NULL, "relative/../dir/./././file.txt", VINF_SUCCESS, "%p/dir/file.txt" },306 { NULL, "relative/../dir\\.\\.\\.\\file.txt", VINF_SUCCESS, "%p/dir\\.\\.\\.\\file.txt" }, /* linux-specific */307 { NULL, "/data/", VINF_SUCCESS, "/data" },308 { "relative_base/dir/", "/from_root", VINF_SUCCESS, "/from_root" },309 { "relative_base/dir/", "relative_also", VINF_SUCCESS, "%p/relative_base/dir/relative_also" },310 #endif311 #if defined (RT_OS_OS2) || defined (RT_OS_WINDOWS)312 { NULL, "C:\\", VINF_SUCCESS, "C:\\" },313 { "C:\\", "..", VINF_SUCCESS, "C:\\" },314 { "C:\\temp", "..", VINF_SUCCESS, "C:\\" },315 { "C:\\VirtualBox/Machines", "..\\VirtualBox.xml", VINF_SUCCESS, "C:\\VirtualBox\\VirtualBox.xml" },316 { "C:\\MustDie", "\\from_root/dir/..", VINF_SUCCESS, "C:\\from_root" },317 { "C:\\temp", "D:\\data", VINF_SUCCESS, "D:\\data" },318 { NULL, "\\\\server\\..\\share", VINF_SUCCESS, "\\\\server\\..\\share" /* kind of strange */ },319 { NULL, "\\\\server/", VINF_SUCCESS, "\\\\server\\" },320 { NULL, "\\\\", VINF_SUCCESS, "\\\\" },321 { NULL, "\\\\\\something", VINF_SUCCESS, "\\\\\\something" /* kind of strange */ },322 { "\\\\server\\share_as_base", "/from_root", VINF_SUCCESS, "\\\\server\\from_root" },323 { "\\\\just_server", "/from_root", VINF_SUCCESS, "\\\\just_server\\from_root" },324 { "\\\\server\\share_as_base", "relative\\data", VINF_SUCCESS, "\\\\server\\share_as_base\\relative\\data" },325 { "base", "\\\\?\\UNC\\relative/edwef/..", VINF_SUCCESS, "\\\\?\\UNC\\relative" },326 { "\\\\?\\UNC\\base", "/from_root", VERR_INVALID_NAME, NULL },327 #else328 { "/temp", "..", VINF_SUCCESS, "/" },329 { "/VirtualBox/Machines", "../VirtualBox.xml", VINF_SUCCESS, "/VirtualBox/VirtualBox.xml" },330 { "/MustDie", "/from_root/dir/..", VINF_SUCCESS, "/from_root" },331 { "\\temp", "\\data", VINF_SUCCESS, "%p/\\temp/\\data" },332 #endif333 };334 335 for (unsigned i = 0; i < RT_ELEMENTS(s_aRTPathAbsExTests); ++ i)336 {337 rc = RTPathAbsEx(s_aRTPathAbsExTests[i].pcszInputBase,338 s_aRTPathAbsExTests[i].pcszInputPath,339 szPath, sizeof(szPath));340 if (rc != s_aRTPathAbsExTests[i].rc)341 {342 RTTestIFailed("unexpected result code!\n"343 " input base: '%s'\n"344 " input path: '%s'\n"345 " output: '%s'\n"346 " rc: %Rrc\n"347 " expected rc: %Rrc",348 s_aRTPathAbsExTests[i].pcszInputBase,349 s_aRTPathAbsExTests[i].pcszInputPath,350 szPath, rc,351 s_aRTPathAbsExTests[i].rc);352 continue;353 }354 355 char szTmp[RTPATH_MAX];356 char *pszExpected = NULL;357 if (s_aRTPathAbsExTests[i].pcszOutput != NULL)358 {359 if (s_aRTPathAbsExTests[i].pcszOutput[0] == '%')360 {361 RTTESTI_CHECK_RC(rc = RTPathGetCurrent(szTmp, sizeof(szTmp)), VINF_SUCCESS);362 if (RT_FAILURE(rc))363 break;364 365 pszExpected = szTmp;366 367 if (s_aRTPathAbsExTests[i].pcszOutput[1] == 'p')368 {369 cch = strlen(szTmp);370 if (cch + strlen(s_aRTPathAbsExTests[i].pcszOutput) - 2 <= sizeof(szTmp))371 strcpy(szTmp + cch, s_aRTPathAbsExTests[i].pcszOutput + 2);372 }373 #if defined(RT_OS_OS2) || defined(RT_OS_WINDOWS)374 else if (s_aRTPathAbsExTests[i].pcszOutput[1] == 'd')375 {376 if (2 + strlen(s_aRTPathAbsExTests[i].pcszOutput) - 2 <= sizeof(szTmp))377 strcpy(szTmp + 2, s_aRTPathAbsExTests[i].pcszOutput + 2);378 }379 #endif380 }381 else382 {383 strcpy(szTmp, s_aRTPathAbsExTests[i].pcszOutput);384 pszExpected = szTmp;385 }386 387 if (strcmp(szPath, pszExpected))388 {389 RTTestIFailed("Unexpected result\n"390 " input base: '%s'\n"391 " input path: '%s'\n"392 " output: '%s'\n"393 " expected: '%s'",394 s_aRTPathAbsExTests[i].pcszInputBase,395 s_aRTPathAbsExTests[i].pcszInputPath,396 szPath,397 s_aRTPathAbsExTests[i].pcszOutput);398 }399 }400 }401 #endif402 403 /*404 * RTPathAbsExEx - will replace RTPathAbsEx shortly.405 */406 RTTestSub(hTest, "RTPathAbsExEx");407 273 static const struct 408 274 { … … 477 343 478 344 size_t cbAbsPath = sizeof(szPath); 479 rc = RTPathAbsEx Ex(s_aRTPathAbsExExTests[i].pcszInputBase,480 s_aRTPathAbsExExTests[i].pcszInputPath,481 s_aRTPathAbsExExTests[i].fFlags,482 szPath, &cbAbsPath);345 rc = RTPathAbsEx(s_aRTPathAbsExExTests[i].pcszInputBase, 346 s_aRTPathAbsExExTests[i].pcszInputPath, 347 s_aRTPathAbsExExTests[i].fFlags, 348 szPath, &cbAbsPath); 483 349 484 350 if (RT_FAILURE(s_aRTPathAbsExExTests[i].rc))
Note:
See TracChangeset
for help on using the changeset viewer.

