Changeset 79326 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Jun 25, 2019 2:19:35 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp
r79322 r79326 126 126 * 127 127 * @returns IPRT status code. 128 * @param pszDir The directory buffer. Contains the abs path to the 129 * directory to recurse into. Trailing slash. 128 * @param pszDir The directory buffer, RTPATH_MAX in length. 129 * Contains the abs path to the directory to 130 * recurse into. Trailing slash. 130 131 * @param cchDir The length of the directory we're recursing into, 131 132 * including the trailing slash. … … 137 138 int rc = RTDirOpen(&hDir, pszDir); 138 139 if (RT_FAILURE(rc)) 140 { 141 /* Ignore non-existing directories like RTDirRemoveRecursive does: */ 142 if (rc == VERR_FILE_NOT_FOUND || rc == VERR_PATH_NOT_FOUND) 143 return VINF_SUCCESS; 139 144 return rc; 140 141 while (RT_SUCCESS(rc = RTDirRead(hDir, pDirEntry, NULL))) 142 { 145 } 146 147 for (;;) 148 { 149 rc = RTDirRead(hDir, pDirEntry, NULL); 150 if (RT_FAILURE(rc)) 151 { 152 if (rc == VERR_NO_MORE_FILES) 153 rc = VINF_SUCCESS; 154 break; 155 } 156 143 157 if (!RTDirEntryIsStdDotLink(pDirEntry)) 144 158 { … … 152 166 } 153 167 154 /* Switch ontype. */168 /* Make sure we've got the entry type. */ 155 169 if (pDirEntry->enmType == RTDIRENTRYTYPE_UNKNOWN) 156 170 RTDirQueryUnknownType(pszDir, false /*fFollowSymlinks*/, &pDirEntry->enmType); 157 switch (pDirEntry->enmType) 171 172 /* Recurse into subdirs and remove them: */ 173 if (pDirEntry->enmType == RTDIRENTRYTYPE_DIRECTORY) 158 174 { 159 case RTDIRENTRYTYPE_DIRECTORY: 175 size_t cchSubDir = cchDir + pDirEntry->cbName; 176 pszDir[cchSubDir++] = RTPATH_SLASH; 177 pszDir[cchSubDir] = '\0'; 178 rc = vgsvcGstCtrlSessionHandleDirRemoveSub(pszDir, cchSubDir, pDirEntry); 179 if (RT_SUCCESS(rc)) 160 180 { 161 size_t cchSubDir = cchDir + pDirEntry->cbName; 162 pszDir[cchSubDir++] = RTPATH_SLASH; 163 pszDir[cchSubDir] = '\0'; 164 rc = vgsvcGstCtrlSessionHandleDirRemoveSub(pszDir, cchSubDir, pDirEntry); 165 if (RT_SUCCESS(rc)) 166 { 167 pszDir[cchSubDir] = '\0'; 168 rc = RTDirRemove(pszDir); 169 } 170 break; 181 pszDir[cchSubDir] = '\0'; 182 rc = RTDirRemove(pszDir); 183 if (RT_FAILURE(rc)) 184 break; 171 185 } 172 173 default: 174 rc = VERR_DIR_NOT_EMPTY; 186 else 175 187 break; 176 188 } 177 if (RT_FAILURE(rc)) 178 break; 179 } 180 } 181 if (rc == VERR_NO_MORE_FILES) 182 rc = VINF_SUCCESS; 189 /* Not a subdirectory - fail: */ 190 else 191 { 192 rc = VERR_DIR_NOT_EMPTY; 193 break; 194 } 195 } 196 } 197 183 198 RTDirClose(hDir); 184 199 return rc; … … 206 221 if (fFlags & DIRREMOVEREC_FLAG_RECURSIVE) 207 222 { 208 if ( fFlags & DIRREMOVEREC_FLAG_CONTENT_AND_DIR 209 || fFlags & DIRREMOVEREC_FLAG_CONTENT_ONLY) 223 if (fFlags & (DIRREMOVEREC_FLAG_CONTENT_AND_DIR | DIRREMOVEREC_FLAG_CONTENT_ONLY)) 210 224 { 211 uint32_t fFlagsRemRec = 0; 212 if (fFlags & DIRREMOVEREC_FLAG_CONTENT_AND_DIR) 213 fFlagsRemRec |= RTDIRRMREC_F_CONTENT_AND_DIR; 214 else if (fFlags & DIRREMOVEREC_FLAG_CONTENT_ONLY) 215 fFlagsRemRec |= RTDIRRMREC_F_CONTENT_ONLY; 225 uint32_t fFlagsRemRec = fFlags & DIRREMOVEREC_FLAG_CONTENT_AND_DIR 226 ? RTDIRRMREC_F_CONTENT_AND_DIR : RTDIRRMREC_F_CONTENT_ONLY; 216 227 rc = RTDirRemoveRecursive(szDir, fFlagsRemRec); 217 228 }
Note:
See TracChangeset
for help on using the changeset viewer.