Changeset 78153 in vbox for trunk/src/VBox/Runtime/r3
- Timestamp:
- Apr 17, 2019 12:30:08 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 130068
- Location:
- trunk/src/VBox/Runtime/r3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/dir.cpp
r78050 r78153 543 543 544 544 cbFilter = cucFilter0 = 0; 545 pszAbsPath = RTPathAbs Dup(pszPath);545 pszAbsPath = RTPathAbsExDup(NULL, pszPath, RTPATHABS_F_ENSURE_TRAILING_SLASH); 546 546 } 547 547 else … … 557 557 return VERR_NO_MEMORY; 558 558 pszTmp[pszFilter - pszPath] = '\0'; 559 pszAbsPath = RTPathAbs Dup(pszTmp);559 pszAbsPath = RTPathAbsExDup(NULL, pszTmp, RTPATHABS_F_ENSURE_TRAILING_SLASH); 560 560 RTStrFree(pszTmp); 561 561 } 562 562 else 563 pszAbsPath = RTPathAbs Dup(".");563 pszAbsPath = RTPathAbsExDup(NULL, ".", RTPATHABS_F_ENSURE_TRAILING_SLASH); 564 564 fDirSlash = true; 565 565 } 566 566 if (!pszAbsPath) 567 567 return VERR_NO_MEMORY; 568 569 568 Assert(strchr(pszAbsPath, '\0')[-1] == RTPATH_SLASH); 570 569 571 570 /* … … 576 575 */ 577 576 size_t const cchAbsPath = strlen(pszAbsPath); 578 size_t const cchAbsPathExtra = !RTPATH_IS_SEP(pszAbsPath[cchAbsPath - 1]) ? 1 : 0; /* add trailing '/' if missing */579 577 size_t const cbDir = rtDirNativeGetStructSize(pszAbsPath); 580 578 size_t const cbAllocated = cbDir 581 579 + cucFilter0 * sizeof(RTUNICP) 582 580 + cbFilter 583 + cchAbsPath + cchAbsPathExtra +1 + 4;581 + cchAbsPath + 1 + 4; 584 582 PRTDIRINTERNAL pDir = (PRTDIRINTERNAL)RTMemAllocZ(cbAllocated); 585 583 if (!pDir) … … 627 625 break; 628 626 } 629 pDir->cchPath = cchAbsPath + cchAbsPathExtra;627 pDir->cchPath = cchAbsPath; 630 628 pDir->pszPath = (char *)memcpy(pb, pszAbsPath, cchAbsPath); 631 pb[cchAbsPath] = RTPATH_SLASH; 632 pb[cchAbsPath + cchAbsPathExtra] = '\0'; 633 Assert(pb - (uint8_t *)pDir + cchAbsPath + cchAbsPathExtra + 1 <= cbAllocated); 629 pb[cchAbsPath] = '\0'; 630 Assert(pb - (uint8_t *)pDir + cchAbsPath + 1 <= cbAllocated); 634 631 pDir->pszName = NULL; 635 632 pDir->cchName = 0; -
trunk/src/VBox/Runtime/r3/win/path-win.cpp
r76553 r78153 671 671 int rc; 672 672 673 /* 674 * GetCurrentDirectory may in some cases omit the drive letter, according 675 * to MSDN, thus the GetFullPathName call. 676 */ 677 RTUTF16 wszCurPath[RTPATH_MAX]; 678 if (GetCurrentDirectoryW(RTPATH_MAX, wszCurPath)) 679 { 680 RTUTF16 wszFullPath[RTPATH_MAX]; 681 if (GetFullPathNameW(wszCurPath, RTPATH_MAX, wszFullPath, NULL)) 682 rc = RTUtf16ToUtf8Ex(&wszFullPath[0], RTSTR_MAX, &pszPath, cchPath, NULL); 673 if (cchPath > 0) 674 { 675 /* 676 * GetCurrentDirectory may in some cases omit the drive letter, according 677 * to MSDN, thus the GetFullPathName call. 678 */ 679 RTUTF16 wszCurPath[RTPATH_MAX]; 680 if (GetCurrentDirectoryW(RTPATH_MAX, wszCurPath)) 681 { 682 RTUTF16 wszFullPath[RTPATH_MAX]; 683 if (GetFullPathNameW(wszCurPath, RTPATH_MAX, wszFullPath, NULL)) 684 rc = RTUtf16ToUtf8Ex(&wszFullPath[0], RTSTR_MAX, &pszPath, cchPath, NULL); 685 else 686 rc = RTErrConvertFromWin32(GetLastError()); 687 } 683 688 else 684 689 rc = RTErrConvertFromWin32(GetLastError()); 685 690 } 686 691 else 687 rc = RTErrConvertFromWin32(GetLastError());692 rc = VERR_BUFFER_OVERFLOW; 688 693 return rc; 689 694 } … … 724 729 RTDECL(int) RTPathGetCurrentOnDrive(char chDrive, char *pszPath, size_t cbPath) 725 730 { 726 WCHAR wszInput[4];727 wszInput[0] = chDrive;728 wszInput[1] = ':';729 wszInput[2] = '\0';730 731 731 int rc; 732 RTUTF16 wszFullPath[RTPATH_MAX]; 733 if (GetFullPathNameW(wszInput, RTPATH_MAX, wszFullPath, NULL)) 734 rc = RTUtf16ToUtf8Ex(&wszFullPath[0], RTSTR_MAX, &pszPath, cbPath, NULL); 732 if (cbPath > 0) 733 { 734 WCHAR wszInput[4]; 735 wszInput[0] = chDrive; 736 wszInput[1] = ':'; 737 wszInput[2] = '\0'; 738 RTUTF16 wszFullPath[RTPATH_MAX]; 739 if (GetFullPathNameW(wszInput, RTPATH_MAX, wszFullPath, NULL)) 740 rc = RTUtf16ToUtf8Ex(&wszFullPath[0], RTSTR_MAX, &pszPath, cbPath, NULL); 741 else 742 rc = RTErrConvertFromWin32(GetLastError()); 743 } 735 744 else 736 rc = RTErrConvertFromWin32(GetLastError());745 rc = VERR_BUFFER_OVERFLOW; 737 746 return rc; 738 747 }
Note:
See TracChangeset
for help on using the changeset viewer.