Changeset 79321 in vbox for trunk/src/VBox/Additions/common/VBoxService
- Timestamp:
- Jun 25, 2019 12:00:40 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp
r79296 r79321 133 133 * @param pObjInfo The object info buffer. (ditto) 134 134 */ 135 static int vgsvcGstCtrlSessionHandleDirRemoveSub(char *pszDir, size_t cchDir, PRTDIRENTRY pDirEntry , PRTFSOBJINFO pObjInfo)135 static int vgsvcGstCtrlSessionHandleDirRemoveSub(char *pszDir, size_t cchDir, PRTDIRENTRY pDirEntry) 136 136 { 137 137 RTDIR hDir; … … 145 145 { 146 146 /* Construct the full name of the entry. */ 147 if (cchDir + pDirEntry->cbName + 1 /* dir slash */ >= RTPATH_MAX) 147 if (cchDir + pDirEntry->cbName + 1 /* dir slash */ < RTPATH_MAX) 148 memcpy(&pszDir[cchDir], pDirEntry->szName, pDirEntry->cbName + 1); 149 else 148 150 { 149 151 rc = VERR_FILENAME_TOO_LONG; 150 152 break; 151 153 } 152 memcpy(&pszDir[cchDir], pDirEntry->szName, pDirEntry->cbName + 1); 153 154 /* Deal with the unknown type. */ 154 155 /* Switch on type. */ 155 156 if (pDirEntry->enmType == RTDIRENTRYTYPE_UNKNOWN) 156 { 157 rc = RTPathQueryInfoEx(pszDir, pObjInfo, RTFSOBJATTRADD_NOTHING, RTPATH_F_ON_LINK); 158 if (RT_SUCCESS(rc) && RTFS_IS_DIRECTORY(pObjInfo->Attr.fMode)) 159 pDirEntry->enmType = RTDIRENTRYTYPE_DIRECTORY; 160 else if (RT_SUCCESS(rc) && RTFS_IS_FILE(pObjInfo->Attr.fMode)) 161 pDirEntry->enmType = RTDIRENTRYTYPE_FILE; 162 else if (RT_SUCCESS(rc) && RTFS_IS_SYMLINK(pObjInfo->Attr.fMode)) 163 pDirEntry->enmType = RTDIRENTRYTYPE_SYMLINK; 164 } 165 166 /* Try the delete the fs object. */ 157 RTDirQueryUnknownType(pszDir, false /*fFollowSymlinks*/, &pDirEntry->enmType); 167 158 switch (pDirEntry->enmType) 168 159 { 169 160 case RTDIRENTRYTYPE_DIRECTORY: 170 161 { 171 size_t cchSubDir = cchDir + pDirEntry->cbName;172 pszDir[cchSubDir++] = '/';162 size_t cchSubDir = cchDir + pDirEntry->cbName; 163 pszDir[cchSubDir++] = RTPATH_SLASH; 173 164 pszDir[cchSubDir] = '\0'; 174 rc = vgsvcGstCtrlSessionHandleDirRemoveSub(pszDir, cchSubDir, pDirEntry , pObjInfo);165 rc = vgsvcGstCtrlSessionHandleDirRemoveSub(pszDir, cchSubDir, pDirEntry); 175 166 if (RT_SUCCESS(rc)) 176 167 { … … 180 171 break; 181 172 } 182 183 /** @todo Implement deleting symlinks? Play safe for now. */184 173 185 174 default: … … 230 219 else /* Only remove empty directory structures. Will fail if non-empty. */ 231 220 { 232 RTDIRENTRY dirEntry;233 RT FSOBJINFO objInfo;234 rc = vgsvcGstCtrlSessionHandleDirRemoveSub(szDir, strlen(szDir), & dirEntry, &objInfo);221 RTDIRENTRY DirEntry; 222 RTPathEnsureTrailingSeparator(szDir, sizeof(szDir)); 223 rc = vgsvcGstCtrlSessionHandleDirRemoveSub(szDir, strlen(szDir), &DirEntry); 235 224 } 236 225 VGSvcVerbose(4, "[Dir %s]: rmdir /s (%#x) -> rc=%Rrc\n", szDir, fFlags, rc);
Note:
See TracChangeset
for help on using the changeset viewer.