diff --git a/base/shell/cmd/del.c b/base/shell/cmd/del.c index 5d3d3ca4c01..4c0dc3a876e 100644 --- a/base/shell/cmd/del.c +++ b/base/shell/cmd/del.c @@ -284,39 +284,46 @@ ProcessDirectory(LPTSTR FileName, DWORD* dwFlags, DWORD dwAttrFlags) WIN32_FIND_DATA f; DWORD dwFiles = 0; + /* Get the full path to the file */ GetFullPathName(FileName, MAX_PATH, szFullPath, &pFilePart); + /* Delete all the files in this directory */ dwFiles = DeleteFiles(szFullPath, dwFlags, dwAttrFlags); - if (dwFiles & 0x80000000) return dwFiles; + if (dwFiles & 0x80000000) + return dwFiles; if (*dwFlags & DEL_SUBDIR) { /* Get just the file name */ - pSearchPart = _tcsrchr(FileName,_T('\\')); - if (pSearchPart != NULL) - pSearchPart++; - else - pSearchPart = FileName; - - /* Get the full path to the file */ - GetFullPathName (FileName,MAX_PATH,szFullPath,NULL); - - /* strip the filename off of it */ - pFilePart = _tcsrchr(szFullPath, _T('\\')); - if (pFilePart == NULL) + pSearchPart = _T("*"); + if (!IsExistingDirectory(szFullPath)) { - pFilePart = szFullPath; + pSearchPart = _tcsrchr(FileName, _T('\\')); + if (pSearchPart != NULL) + pSearchPart++; + else + pSearchPart = FileName; + } + + /* If no wildcard or file was specified and this is a directory, then + display all files in it */ + if (pFilePart == NULL || IsExistingDirectory(szFullPath)) + { + pFilePart = &szFullPath[_tcslen(szFullPath)]; + if (*(pFilePart-1) != _T('\\')) + *pFilePart++ = _T('\\'); + _tcscpy(pFilePart, _T("*")); } else { - pFilePart++; + /* strip the filename off of it */ + _tcscpy(pFilePart, _T("*")); } - _tcscpy(pFilePart, _T("*")); - + /* Enumerate all the sub-directories */ hFile = FindFirstFile(szFullPath, &f); if (hFile != INVALID_HANDLE_VALUE) { @@ -341,6 +348,7 @@ ProcessDirectory(LPTSTR FileName, DWORD* dwFlags, DWORD dwAttrFlags) FindClose (hFile); } } + return dwFiles; }