Changeset 78186 in vbox for trunk/src/VBox/Runtime/r3
- Timestamp:
- Apr 17, 2019 9:36:59 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 130107
- Location:
- trunk/src/VBox/Runtime/r3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/r3/dir.cpp
r78184 r78186 527 527 * for querying extra information about the objects we list. 528 528 * As a sideeffect we also validate the path here. 529 * 530 * Note! The RTDIR_F_NO_ABS_PATH mess is there purely for allowing us to 531 * work around PATH_MAX using CWD on linux and other unixy systems. 529 532 */ 530 533 char *pszAbsPath; … … 542 545 543 546 cbFilter = cucFilter0 = 0; 544 pszAbsPath = RTPathAbsExDup(NULL, pszPath, RTPATHABS_F_ENSURE_TRAILING_SLASH); 547 if (!(fFlags & RTDIR_F_NO_ABS_PATH)) 548 pszAbsPath = RTPathAbsExDup(NULL, pszPath, RTPATHABS_F_ENSURE_TRAILING_SLASH); 549 else 550 { 551 size_t cchTmp = strlen(pszPath); 552 pszAbsPath = RTStrAlloc(cchTmp + 2); 553 if (pszAbsPath) 554 { 555 memcpy(pszAbsPath, pszPath, cchTmp); 556 pszAbsPath[cchTmp] = RTPATH_SLASH; 557 pszAbsPath[cchTmp + 1 - fDirSlash] = '\0'; 558 } 559 } 545 560 } 546 561 else … … 556 571 return VERR_NO_MEMORY; 557 572 pszTmp[pszFilter - pszPath] = '\0'; 558 pszAbsPath = RTPathAbsExDup(NULL, pszTmp, RTPATHABS_F_ENSURE_TRAILING_SLASH); 559 RTStrFree(pszTmp); 560 } 573 if (!(fFlags & RTDIR_F_NO_ABS_PATH)) 574 { 575 pszAbsPath = RTPathAbsExDup(NULL, pszTmp, RTPATHABS_F_ENSURE_TRAILING_SLASH); 576 RTStrFree(pszTmp); 577 } 578 else 579 { 580 pszAbsPath = pszTmp; 581 RTPathEnsureTrailingSeparator(pszAbsPath, strlen(pszPath) + 1); 582 } 583 } 584 else if (!(fFlags & RTDIR_F_NO_ABS_PATH)) 585 pszAbsPath = RTPathAbsExDup(NULL, ".", RTPATHABS_F_ENSURE_TRAILING_SLASH); 561 586 else 562 pszAbsPath = RT PathAbsExDup(NULL, ".", RTPATHABS_F_ENSURE_TRAILING_SLASH);587 pszAbsPath = RTStrDup("." RTPATH_SLASH_STR); 563 588 fDirSlash = true; 564 589 } -
trunk/src/VBox/Runtime/r3/dir2.cpp
r78178 r78186 56 56 * @param pDirEntry The dir entry buffer. (Shared to save stack.) 57 57 * @param pObjInfo The object info buffer. (ditto) 58 * @param fFlags RTDIRRMREC_F_XXX. 58 59 */ 59 static int rtDirRemoveRecursiveSub(char *pszBuf, size_t cchDir, size_t cbBuf, PRTDIRENTRY pDirEntry, PRTFSOBJINFO pObjInfo) 60 static int rtDirRemoveRecursiveSub(char *pszBuf, size_t cchDir, size_t cbBuf, PRTDIRENTRY pDirEntry, PRTFSOBJINFO pObjInfo, 61 uint32_t fFlags) 60 62 { 61 63 AssertReturn(RTPATH_IS_SLASH(pszBuf[cchDir - 1]), VERR_INTERNAL_ERROR_4); … … 65 67 */ 66 68 RTDIR hDir; 67 int rc = RTDirOpen (&hDir, pszBuf);69 int rc = RTDirOpenFiltered(&hDir, pszBuf, RTDIRFILTER_NONE, fFlags & RTDIRRMREC_F_NO_ABS_PATH ? RTDIR_F_NO_ABS_PATH : 0); 68 70 if (RT_FAILURE(rc)) 69 71 return rc; … … 104 106 pszBuf[cchSubDir++] = '/'; 105 107 pszBuf[cchSubDir] = '\0'; 106 rc = rtDirRemoveRecursiveSub(pszBuf, cchSubDir, cbBuf, pDirEntry, pObjInfo );108 rc = rtDirRemoveRecursiveSub(pszBuf, cchSubDir, cbBuf, pDirEntry, pObjInfo, fFlags); 107 109 if (RT_SUCCESS(rc)) 108 110 { … … 153 155 * eliminates any races with changing CWD. 154 156 */ 155 /** @todo use RTPathReal here instead? */ 156 int rc = RTPathAbs(pszPath, pszAbsPath, cbAbsPathBuf); 157 int rc; 158 if (!(fFlags & RTDIRRMREC_F_NO_ABS_PATH)) 159 rc = RTPathAbs(pszPath, pszAbsPath, cbAbsPathBuf); 160 else if (*pszPath != '\0') 161 rc = RTStrCopy(pszAbsPath, cbAbsPathBuf, pszPath); 162 else 163 rc = VERR_PATH_ZERO_LENGTH; 157 164 if (RT_SUCCESS(rc)) 158 165 { … … 160 167 * This API is not permitted applied to the root of anything. 161 168 */ 162 if (RTPathCountComponents(pszAbsPath) <= 1) 169 union 170 { 171 RTPATHPARSED Parsed; 172 uint8_t abParsed[RT_UOFFSETOF(RTPATHPARSED, aComps[1])]; 173 } uBuf; 174 RTPathParse(pszPath, &uBuf.Parsed, sizeof(uBuf), RTPATH_STR_F_STYLE_HOST); 175 if ( uBuf.Parsed.cComps <= 1 176 && (uBuf.Parsed.fProps & RTPATH_PROP_ROOT_SLASH)) 163 177 rc = VERR_ACCESS_DENIED; 164 178 else … … 191 205 */ 192 206 RTDIRENTRY SharedDirEntryBuf; 193 rc = rtDirRemoveRecursiveSub(pszAbsPath, cchAbsPath, cbAbsPathBuf, &SharedDirEntryBuf, &SharedObjInfoBuf); 207 rc = rtDirRemoveRecursiveSub(pszAbsPath, cchAbsPath, cbAbsPathBuf, 208 &SharedDirEntryBuf, &SharedObjInfoBuf, fFlags); 194 209 195 210 /*
Note:
See TracChangeset
for help on using the changeset viewer.