Changeset 44615 in vbox
- Timestamp:
- Feb 10, 2013 6:10:50 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 83701
- Location:
- trunk
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/path.h
r44528 r44615 594 594 595 595 596 /** 597 * Create a relative path between the two given paths. 598 * 599 * @returns IPRT status code. 600 * @retval VINF_SUCCESS on success. 601 * @retval VERR_BUFFER_OVERFLOW if the result is too big to fit within 602 * cbPathDst bytes. 603 * @retval VERR_NOT_SUPPORTED if both paths start with different volume specifiers. 604 * @param pszPathDst Where to store the resulting path. 605 * @param cbPathDst The size of the buffer pszPathDst points to, 606 * terminator included. 607 * @param pszPathFrom The path to start from creating the relative path. 608 * @param pszPathTo The path to reach with the created relative path. 609 */ 610 RTDECL(int) RTPathCreateRelative(char *pszPathDst, size_t cbPathDst, 611 const char *pszPathFrom, 612 const char *pszPathTo); 613 596 614 #ifdef IN_RING3 597 615 -
trunk/src/VBox/Runtime/testcase/tstRTPath.cpp
r36881 r44615 554 554 } 555 555 556 /* 557 * RTPathCreateRelative 558 */ 559 RTTestSub(hTest, "RTPathCreateRelative"); 560 struct 561 { 562 const char *pszFrom; 563 const char *pszTo; 564 int rc; 565 const char *pszExpected; 566 } s_aRelPath[] = 567 { 568 { "/home/test.ext", "/home/test2.ext", VINF_SUCCESS, "test2.ext"}, 569 { "/dir/test.ext", "/dir/dir2/test2.ext", VINF_SUCCESS, "dir2/test2.ext"}, 570 { "/dir/dir2/test.ext", "/dir/test2.ext", VINF_SUCCESS, "../test2.ext"}, 571 { "/dir/dir2/test.ext", "/dir/dir3/test2.ext", VINF_SUCCESS, "../dir3/test2.ext"}, 572 #if defined (RT_OS_OS2) || defined (RT_OS_WINDOWS) 573 { "\\\\server\\share\\test.ext", "\\\\server\\share2\\test2.ext", VERR_NOT_SUPPORTED, ""}, 574 { "c:\\dir\\test.ext", "f:\\dir\\test.ext", VERR_NOT_SUPPORTED, ""} 575 #endif 576 }; 577 for (unsigned i = 0; i < RT_ELEMENTS(s_aRelPath); i++) 578 { 579 const char *pszFrom = s_aRelPath[i].pszFrom; 580 const char *pszTo = s_aRelPath[i].pszTo; 581 582 rc = RTPathCreateRelative(szPath, sizeof(szPath), pszFrom, pszTo); 583 if (rc != s_aRelPath[i].rc) 584 RTTestIFailed("Unexpected return code\n" 585 " got: %Rrc\n" 586 "expected: %Rrc", 587 rc, s_aRelPath[i].rc); 588 else if ( RT_SUCCESS(rc) 589 && strcmp(szPath, s_aRelPath[i].pszExpected)) 590 RTTestIFailed("Unexpected result\n" 591 " from: '%s'\n" 592 " to: '%s'\n" 593 " output: '%s'\n" 594 "expected: '%s'", 595 pszFrom, pszTo, szPath, s_aRelPath[i].pszExpected); 596 } 556 597 557 598 /*
Note:
See TracChangeset
for help on using the changeset viewer.