Changeset 26133 in vbox
- Timestamp:
- Feb 1, 2010 4:13:05 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 57135
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/path.h
r25923 r26133 403 403 404 404 /** 405 * Like RTPathAppend, but with the base path as a separate argument instead of 406 * in the path buffer. 407 * 408 * @retval VINF_SUCCESS on success. 409 * @retval VERR_BUFFER_OVERFLOW if the result is too big to fit within 410 * cbPathDst bytes. 411 * @retval VERR_INVALID_PARAMETER if the string pointed to by pszPath is longer 412 * than cbPathDst-1 bytes (failed to find terminator). Asserted. 413 * 414 * @param pszPathDst Where to store the resulting path. 415 * @param cbPathDst The size of the buffer pszPathDst points to, 416 * terminator included. 417 * @param pszPathSrc The base path to copy into @a pszPathDst before 418 * appending @a pszAppend. 419 * @param pszAppend The partial path to append to pszPathSrc. This can 420 * be NULL, in which case nothing is done. 421 * 422 */ 423 RTDECL(int) RTPathJoin(char *pszPathDst, size_t cbPathDst, const char *pszPathSrc, 424 const char *pszAppend); 425 426 /** 405 427 * Callback for RTPathTraverseList that's called for each element. 406 428 * -
trunk/src/VBox/Runtime/Makefile.kmk
r26116 r26133 274 274 common/path/RTPathHaveExt.cpp \ 275 275 common/path/RTPathHavePath.cpp \ 276 common/path/RTPathJoin.cpp \ 276 277 common/path/RTPathParse.cpp \ 277 278 common/path/RTPathRealDup.cpp \ … … 831 832 common/path/RTPathHaveExt.cpp \ 832 833 common/path/RTPathHavePath.cpp \ 834 common/path/RTPathJoin.cpp \ 833 835 common/path/RTPathParse.cpp \ 834 836 common/path/RTPathRealDup.cpp \ -
trunk/src/VBox/Runtime/testcase/tstRTPath.cpp
r25924 r26133 331 331 332 332 /* 333 * RTPathJoin - reuse the append tests. 334 */ 335 RTTestSub(hTest, "RTPathJoin"); 336 for (unsigned i = 0; i < RT_ELEMENTS(s_apszAppendTests); i += 3) 337 { 338 const char *pszInput = s_apszAppendTests[i]; 339 const char *pszAppend = s_apszAppendTests[i + 1]; 340 const char *pszExpect = s_apszAppendTests[i + 2]; 341 342 memset(szPath, 'a', sizeof(szPath)); szPath[sizeof(szPath) - 1] = '\0'; 343 344 RTTESTI_CHECK_RC(rc = RTPathJoin(szPath, sizeof(szPath), pszInput, pszAppend), VINF_SUCCESS); 345 if (RT_FAILURE(rc)) 346 continue; 347 if (strcmp(szPath, pszExpect)) 348 { 349 RTTestIFailed("Unexpected result\n" 350 " input: '%s'\n" 351 " append: '%s'\n" 352 " output: '%s'\n" 353 "expected: '%s'", 354 pszInput, pszAppend, szPath, pszExpect); 355 } 356 else 357 { 358 size_t const cchResult = strlen(szPath); 359 360 memset(szPath, 'a', sizeof(szPath)); szPath[sizeof(szPath) - 1] = '\0'; 361 RTTESTI_CHECK_RC(rc = RTPathJoin(szPath, cchResult + 2, pszInput, pszAppend), VINF_SUCCESS); 362 RTTESTI_CHECK(RT_FAILURE(rc) || !strcmp(szPath, pszExpect)); 363 364 memset(szPath, 'a', sizeof(szPath)); szPath[sizeof(szPath) - 1] = '\0'; 365 RTTESTI_CHECK_RC(rc = RTPathJoin(szPath, cchResult + 1, pszInput, pszAppend), VINF_SUCCESS); 366 RTTESTI_CHECK(RT_FAILURE(rc) || !strcmp(szPath, pszExpect)); 367 368 RTTESTI_CHECK_RC(rc = RTPathJoin(szPath, cchResult, pszInput, pszAppend), VERR_BUFFER_OVERFLOW); 369 } 370 } 371 372 /* 333 373 * RTPathStripTrailingSlash 334 374 */
Note:
See TracChangeset
for help on using the changeset viewer.