Changeset 58069 in vbox for trunk/src/VBox/Runtime
- Timestamp:
- Oct 7, 2015 12:05:47 AM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 103125
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/common/misc/uri.cpp
r58068 r58069 1153 1153 1154 1154 1155 RTDECL(char *) RTUriFilePath(const char *pszUri, uint32_t uFormat) 1156 { 1157 uint32_t fPathStyle; 1158 switch (uFormat) 1159 { 1160 case URI_FILE_FORMAT_WIN: fPathStyle = RTPATH_STR_F_STYLE_DOS; break; 1161 case URI_FILE_FORMAT_UNIX: fPathStyle = RTPATH_STR_F_STYLE_UNIX; break; 1162 case URI_FILE_FORMAT_AUTO: fPathStyle = RTPATH_STR_F_STYLE_HOST; break; 1163 default: AssertFailedReturn(NULL); 1164 } 1165 1155 RTDECL(char *) RTUriFilePath(const char *pszUri) 1156 { 1166 1157 char *pszPath = NULL; 1167 int rc = RTUriFilePathEx(pszUri, fPathStyle, &pszPath, 0 /*cbPath*/, NULL /*pcchPath*/);1158 int rc = RTUriFilePathEx(pszUri, RTPATH_STR_F_STYLE_HOST, &pszPath, 0 /*cbPath*/, NULL /*pcchPath*/); 1168 1159 if (RT_SUCCESS(rc)) 1169 1160 return pszPath; -
trunk/src/VBox/Runtime/testcase/tstRTUri.cpp
r58068 r58069 307 307 uint32_t fPathPathStyle; 308 308 const char *pszUri; 309 uint32_t uFormat;309 uint32_t fUriPathStyle; 310 310 const char *pszCreatedPath; 311 311 const char *pszCreatedUri; … … 316 316 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 317 317 /* .pszUri =*/ "file:///C:%5Cover/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60%5Cthere", 318 /* . uFormat =*/ URI_FILE_FORMAT_WIN,318 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 319 319 /* .pszCreatedPath =*/ "C:\\over\\ <>#%\"{}|^[]`\\there", 320 320 /* .pszCreatedUri =*/ "file:///C:/over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there", … … 326 326 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_UNIX, 327 327 /* .pszUri =*/ "file:///over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there", 328 /* . uFormat =*/ URI_FILE_FORMAT_UNIX,328 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_UNIX, 329 329 /* .pszCreatedPath =*/ "/over/ <>#%\"{}|^[]`/there", 330 330 /* .pszCreatedUri =*/ "file:///over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there", … … 336 336 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_UNIX, 337 337 /* .pszUri =*/ "file://", 338 /* . uFormat =*/ URI_FILE_FORMAT_UNIX,338 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_UNIX, 339 339 /* .pszCreatedPath =*/ NULL, 340 340 /* .pszCreatedUri =*/ NULL, … … 346 346 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 347 347 /* .pszUri =*/ "file://", 348 /* . uFormat =*/ URI_FILE_FORMAT_WIN,348 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 349 349 /* .pszCreatedPath =*/ NULL, 350 350 /* .pszCreatedUri =*/ NULL, … … 356 356 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_UNIX, 357 357 /* .pszUri =*/ "file:///", 358 /* . uFormat =*/ URI_FILE_FORMAT_UNIX,358 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_UNIX, 359 359 /* .pszCreatedPath =*/ "/", 360 360 /* .pszCreatedUri =*/ "file:///", … … 366 366 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 367 367 /* .pszUri =*/ "file:///", 368 /* . uFormat =*/ URI_FILE_FORMAT_WIN,368 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 369 369 /* .pszCreatedPath =*/ "\\", 370 370 /* .pszCreatedUri =*/ "file:///", … … 376 376 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_UNIX, 377 377 /* .pszUri =*/ "file:///foo/bar", 378 /* . uFormat =*/ URI_FILE_FORMAT_UNIX,378 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_UNIX, 379 379 /* .pszCreatedPath =*/ "/foo/bar", 380 380 /* .pszCreatedUri =*/ "file:///foo/bar", … … 386 386 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 387 387 /* .pszUri =*/ "file:///foo%5Cbar", 388 /* . uFormat =*/ URI_FILE_FORMAT_WIN,388 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 389 389 /* .pszCreatedPath =*/ "\\foo\\bar", 390 390 /* .pszCreatedUri =*/ "file:///foo/bar", … … 396 396 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_UNIX, 397 397 /* .pszUri =*/ "file:///C:/over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there", 398 /* . uFormat =*/ URI_FILE_FORMAT_UNIX,398 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_UNIX, 399 399 /* .pszCreatedPath =*/ "C:/over/ <>#%\"{}|^[]`/there", 400 400 /* .pszCreatedUri =*/ "file:///C:/over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there", … … 406 406 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 407 407 /* .pszUri =*/ "file:///over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there", 408 /* . uFormat =*/ URI_FILE_FORMAT_WIN,408 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 409 409 /* .pszCreatedPath =*/ "\\over\\ <>#%\"{}|^[]`\\there", 410 410 /* .pszCreatedUri =*/ "file:///over/%20%3C%3E%23%25%22%7B%7D%7C%5E%5B%5D%60/there", … … 416 416 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_UNIX, 417 417 /* .pszUri =*/ "file:///usr/bin/grep", 418 /* . uFormat =*/ URI_FILE_FORMAT_UNIX,418 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_UNIX, 419 419 /* .pszCreatedPath =*/ "/usr/bin/grep", 420 420 /* .pszCreatedUri =*/ "file:///usr/bin/grep", … … 426 426 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 427 427 /* .pszUri =*/ "file:///usr/bin/grep", 428 /* . uFormat =*/ URI_FILE_FORMAT_WIN,428 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 429 429 /* .pszCreatedPath =*/ "\\usr\\bin\\grep", 430 430 /* .pszCreatedUri =*/ "file:///usr/bin/grep", … … 436 436 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_UNIX, 437 437 /* .pszUri =*/ "file:///somerootsubdir/isos/files.lst", 438 /* . uFormat =*/ URI_FILE_FORMAT_UNIX,438 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_UNIX, 439 439 /* .pszCreatedPath =*/ "/somerootsubdir/isos/files.lst", 440 440 /* .pszCreatedUri =*/ "file:///somerootsubdir/isos/files.lst", … … 446 446 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 447 447 /* .pszUri =*/ "file:///not-a-cifsserver/isos/files.lst", 448 /* . uFormat =*/ URI_FILE_FORMAT_WIN,448 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 449 449 /* .pszCreatedPath =*/ "\\not-a-cifsserver\\isos\\files.lst", 450 450 /* .pszCreatedUri =*/ "file:///not-a-cifsserver/isos/files.lst", … … 456 456 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_UNIX, 457 457 /* .pszUri =*/ "file:///rootsubdir/isos/files.lst", 458 /* . uFormat =*/ URI_FILE_FORMAT_UNIX,458 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_UNIX, 459 459 /* .pszCreatedPath =*/ "/rootsubdir/isos/files.lst", 460 460 /* .pszCreatedUri =*/ "file:///rootsubdir/isos/files.lst", … … 466 466 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 467 467 /* .pszUri =*/ "file:///not-a-cifsserver-either/isos/files.lst", 468 /* . uFormat =*/ URI_FILE_FORMAT_WIN,468 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 469 469 /* .pszCreatedPath =*/ "\\not-a-cifsserver-either\\isos\\files.lst", 470 470 /* .pszCreatedUri =*/ "file:///not-a-cifsserver-either/isos/files.lst", … … 476 476 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 477 477 /* .pszUri =*/ "file:////cifsserver/isos/files.lst", 478 /* . uFormat =*/ URI_FILE_FORMAT_WIN,478 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 479 479 /* .pszCreatedPath =*/ "\\\\cifsserver\\isos\\files.lst", 480 480 /* .pszCreatedUri =*/ "file://cifsserver/isos/files.lst", … … 486 486 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 487 487 /* .pszUri =*/ "file://localhost/c:boot.ini", 488 /* . uFormat =*/ URI_FILE_FORMAT_WIN,488 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 489 489 /* .pszCreatedPath =*/ "c:boot.ini", 490 490 /* .pszCreatedUri =*/ "file:///c:boot.ini", … … 496 496 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 497 497 /* .pszUri =*/ "file:///c|boot.ini", 498 /* . uFormat =*/ URI_FILE_FORMAT_WIN,498 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 499 499 /* .pszCreatedPath =*/ "c:boot.ini", 500 500 /* .pszCreatedUri =*/ "file:///c:boot.ini", … … 506 506 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 507 507 /* .pszUri =*/ "file:c:\\legacy-no-slash%2Eini", 508 /* . uFormat =*/ URI_FILE_FORMAT_WIN,508 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 509 509 /* .pszCreatedPath =*/ "c:\\legacy-no-slash.ini", 510 510 /* .pszCreatedUri =*/ "file:///c:/legacy-no-slash.ini", … … 516 516 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 517 517 /* .pszUri =*/ "file:c|\\legacy-no-slash%2Eini", 518 /* . uFormat =*/ URI_FILE_FORMAT_WIN,518 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 519 519 /* .pszCreatedPath =*/ "c:\\legacy-no-slash.ini", 520 520 /* .pszCreatedUri =*/ "file:///c:/legacy-no-slash.ini", … … 526 526 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 527 527 /* .pszUri =*/ "file:/c:\\legacy-single-slash%2Eini", 528 /* . uFormat =*/ URI_FILE_FORMAT_WIN,528 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 529 529 /* .pszCreatedPath =*/ "c:\\legacy-single-slash.ini", 530 530 /* .pszCreatedUri =*/ "file:///c:/legacy-single-slash.ini", … … 536 536 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 537 537 /* .pszUri =*/ "file:/c:\\legacy-single-slash%2Eini", 538 /* . uFormat =*/ URI_FILE_FORMAT_WIN,538 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 539 539 /* .pszCreatedPath =*/ "c:\\legacy-single-slash.ini", 540 540 /* .pszCreatedUri =*/ "file:///c:/legacy-single-slash.ini", … … 546 546 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 547 547 /* .pszUri =*/ "file:/legacy-single-slash%2Eini", 548 /* . uFormat =*/ URI_FILE_FORMAT_WIN,548 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 549 549 /* .pszCreatedPath =*/ "\\legacy-single-slash.ini", 550 550 /* .pszCreatedUri =*/ "file:///legacy-single-slash.ini", … … 556 556 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 557 557 /* .pszUri =*/ "file://C:\\legacy-double-slash%2E.ini", 558 /* . uFormat =*/ URI_FILE_FORMAT_WIN,558 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 559 559 /* .pszCreatedPath =*/ "C:\\legacy-double-slash%2E.ini", 560 560 /* .pszCreatedUri =*/ "file:///C:/legacy-double-slash%252E.ini", … … 566 566 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 567 567 /* .pszUri =*/ "file://C|/legacy-double-slash%2E.ini", 568 /* . uFormat =*/ URI_FILE_FORMAT_WIN,568 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 569 569 /* .pszCreatedPath =*/ "C:\\legacy-double-slash%2E.ini", 570 570 /* .pszCreatedUri =*/ "file:///C:/legacy-double-slash%252E.ini", … … 576 576 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 577 577 /* .pszUri =*/ "file:////C|/legacy-4-slashes%2E.ini", 578 /* . uFormat =*/ URI_FILE_FORMAT_WIN,578 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 579 579 /* .pszCreatedPath =*/ "C:\\legacy-4-slashes%2E.ini", 580 580 /* .pszCreatedUri =*/ "file:///C:/legacy-4-slashes%252E.ini", … … 586 586 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 587 587 /* .pszUri =*/ "file:////C:/legacy-4-slashes%2E.ini", 588 /* . uFormat =*/ URI_FILE_FORMAT_WIN,588 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 589 589 /* .pszCreatedPath =*/ "C:\\legacy-4-slashes%2E.ini", 590 590 /* .pszCreatedUri =*/ "file:///C:/legacy-4-slashes%252E.ini", … … 596 596 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 597 597 /* .pszUri =*/ "file:////cifsserver/share/legacy-4-slashes%2E.ini", 598 /* . uFormat =*/ URI_FILE_FORMAT_WIN,598 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 599 599 /* .pszCreatedPath =*/ "\\\\cifsserver\\share\\legacy-4-slashes%2E.ini", 600 600 /* .pszCreatedUri =*/ "file://cifsserver/share/legacy-4-slashes%252E.ini", … … 606 606 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 607 607 /* .pszUri =*/ "file://///cifsserver/share/legacy-5-slashes%2Eini", 608 /* . uFormat =*/ URI_FILE_FORMAT_WIN,608 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 609 609 /* .pszCreatedPath =*/ "\\\\cifsserver\\share\\legacy-5-slashes.ini", 610 610 /* .pszCreatedUri =*/ "file://cifsserver/share/legacy-5-slashes.ini", … … 616 616 /* .fPathPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 617 617 /* .pszUri =*/ "file://///C|/share/legacy-5-slashes%2Eini", 618 /* . uFormat =*/ URI_FILE_FORMAT_WIN,618 /* .fUriPathStyle =*/ RTPATH_STR_F_STYLE_DOS, 619 619 /* .pszCreatedPath =*/ "\\\\C|\\share\\legacy-5-slashes.ini", 620 620 /* .pszCreatedUri =*/ "file://C%7C/share/legacy-5-slashes.ini", … … 654 654 } 655 655 656 static const char *tstNamePathStyle(uint32_t fPathStyle) 657 { 658 switch (fPathStyle) 659 { 660 case RTPATH_STR_F_STYLE_DOS: return "RTPATH_STR_F_STYLE_DOS"; 661 case RTPATH_STR_F_STYLE_UNIX: return "RTPATH_STR_F_STYLE_UNIX"; 662 case RTPATH_STR_F_STYLE_HOST: return "RTPATH_STR_F_STYLE_HOST"; 663 default: AssertFailedReturn("Invalid"); 664 } 665 } 666 656 667 static void tstWindowsReferenceResults(void) 657 668 { … … 668 679 tstPrintCString(g_aCreateFileURIs[i].pszPath); 669 680 RTPrintf(",\n"); 681 RTPrintf(" /* .fPathPathStyle =*/ %s,\n", tstNamePathStyle(g_aCreateFileURIs[i].fPathPathStyle)); 670 682 RTPrintf(" /* .pszUri =*/ "); 671 683 tstPrintCString(g_aCreateFileURIs[i].pszUri); 672 684 RTPrintf(",\n"); 673 RTPrintf(" /* .uFormat =*/ %s,\n", 674 g_aCreateFileURIs[i].uFormat == URI_FILE_FORMAT_WIN ? "URI_FILE_FORMAT_WIN" 675 : g_aCreateFileURIs[i].uFormat == URI_FILE_FORMAT_UNIX ? "URI_FILE_FORMAT_UNIX" 676 : g_aCreateFileURIs[i].uFormat == URI_FILE_FORMAT_AUTO ? "URI_FILE_FORMAT_AUTO" : "URI_FILE_FORMAT_INVALID"); 685 RTPrintf(" /* .fUriPathStyle =*/ %s,\n", tstNamePathStyle(g_aCreateFileURIs[i].fUriPathStyle)); 677 686 RTPrintf(" /* .pszCreatedPath =*/ "); 678 687 tstPrintCString(g_aCreateFileURIs[i].pszCreatedPath); … … 751 760 752 761 762 static void tstRTUriFilePathEx(void) 763 { 764 RTTestISub("RTUriFilePathEx"); 765 for (size_t i = 0; i < RT_ELEMENTS(g_aCreateFileURIs); ++i) 766 { 767 uint32_t const fPathStyle = g_aCreateFileURIs[i].fUriPathStyle; 768 const char * const pszUri = g_aCreateFileURIs[i].pszUri; 769 char *pszPath = (char *)&pszPath; 770 int rc = RTUriFilePathEx(pszUri, fPathStyle, &pszPath, 0, NULL); 771 if (RT_SUCCESS(rc)) 772 { 773 if (g_aCreateFileURIs[i].pszCreatedPath) 774 { 775 if (strcmp(pszPath, g_aCreateFileURIs[i].pszCreatedPath) == 0) 776 { 777 /** @todo check out the other variations of the API. */ 778 } 779 else 780 RTTestIFailed("#%u: '%s'/%#x => '%s', expected '%s'", 781 i, pszUri, fPathStyle, pszPath, g_aCreateFileURIs[i].pszCreatedPath); 782 } 783 else 784 RTTestIFailed("#%u: bad testcase; pszCreatedPath is NULL\n", i); 785 } 786 else if (rc != VERR_PATH_ZERO_LENGTH || RTStrCmp(pszUri, "file://") != 0) 787 RTTestIFailed("#%u: '%s'/%#x => %Rrc", i, pszUri, fPathStyle, rc); 788 } 789 } 790 791 753 792 static void tstRTUriFileCreateEx(void) 754 793 { … … 839 878 bool fSavedQuiet = RTAssertSetQuiet(true); 840 879 841 /* File Uri path */ 842 RTTestISub("RTUriFilePath"); 843 for (size_t i = 0; i < RT_ELEMENTS(g_aCreateFileURIs); ++i) 844 CHECK_STR_API(RTUriFilePath(g_aCreateFileURIs[i].pszUri, g_aCreateFileURIs[i].uFormat), 845 g_aCreateFileURIs[i].pszCreatedPath); 846 847 /* File Uri creation */ 880 tstRTUriFilePathEx(); 848 881 tstRTUriFileCreateEx(); 849 882
Note:
See TracChangeset
for help on using the changeset viewer.