'Del *.*' ignores directories.

This fixes bug 291.

svn path=/trunk/; revision=9174
This commit is contained in:
Eric Kohl 2004-04-17 12:01:04 +00:00
parent 9e9160f508
commit 4845295e63

View file

@ -110,6 +110,7 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param)
LPTSTR *arg = NULL; LPTSTR *arg = NULL;
INT args; INT args;
INT i; INT i;
INT res;
INT nEvalArgs = 0; /* nunber of evaluated arguments */ INT nEvalArgs = 0; /* nunber of evaluated arguments */
DWORD dwFlags = 0; DWORD dwFlags = 0;
DWORD dwFiles = 0; DWORD dwFiles = 0;
@ -206,14 +207,12 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param)
if (!_tcscmp (arg[i], _T("*")) || if (!_tcscmp (arg[i], _T("*")) ||
!_tcscmp (arg[i], _T("*.*"))) !_tcscmp (arg[i], _T("*.*")))
{ {
INT res;
if (!((dwFlags & DEL_YES) || (dwFlags & DEL_QUIET) || (dwFlags & DEL_PROMPT))) if (!((dwFlags & DEL_YES) || (dwFlags & DEL_QUIET) || (dwFlags & DEL_PROMPT)))
{ {
res = FilePromptYN (_T("All files in the directory will be deleted!\n" res = FilePromptYN (_T("All files in the directory will be deleted!\n"
"Are you sure (Y/N)?")); "Are you sure (Y/N)?"));
if ((res == PROMPT_NO) || if ((res == PROMPT_NO) || (res == PROMPT_BREAK))
(res == PROMPT_BREAK))
break; break;
} }
} }
@ -251,9 +250,10 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param)
do do
{ {
/* ignore "." and ".." */ /* ignore ".", ".." and directories */
if (!_tcscmp (f.cFileName, _T(".")) || if (!_tcscmp (f.cFileName, _T(".")) ||
!_tcscmp (f.cFileName, _T(".."))) !_tcscmp (f.cFileName, _T("..")) ||
f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
continue; continue;
_tcscpy (pFilePart, f.cFileName); _tcscpy (pFilePart, f.cFileName);
@ -261,10 +261,9 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param)
#ifdef _DEBUG #ifdef _DEBUG
ConErrPrintf (_T("Full filename: %s\n"), szFullPath); ConErrPrintf (_T("Full filename: %s\n"), szFullPath);
#endif #endif
/*ask for deleting */ /* ask for deleting */
if(dwFlags & DEL_PROMPT) if (dwFlags & DEL_PROMPT)
{ {
INT res;
ConErrPrintf (_T("The file %s will be deleted! "), szFullPath); ConErrPrintf (_T("The file %s will be deleted! "), szFullPath);
res = FilePromptYN (_T("Are you sure (Y/N)?")); res = FilePromptYN (_T("Are you sure (Y/N)?"));
@ -277,8 +276,6 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param)
if (!(dwFlags & DEL_QUIET) && !(dwFlags & DEL_TOTAL)) if (!(dwFlags & DEL_QUIET) && !(dwFlags & DEL_TOTAL))
ConErrPrintf (_T("Deleting: %s\n"), szFullPath); ConErrPrintf (_T("Deleting: %s\n"), szFullPath);
/* delete the file */ /* delete the file */
if (!(dwFlags & DEL_NOTHING)) if (!(dwFlags & DEL_NOTHING))
{ {
@ -327,11 +324,9 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param)
szFullPath, szFullPath,
&pFilePart); &pFilePart);
/*ask for deleting */ /*ask for deleting */
if((dwFlags & DEL_PROMPT) && (FindFirstFile(szFullPath, &f) != INVALID_HANDLE_VALUE)) //Don't ask if the file doesn't exist, the following code will make the error-msg if((dwFlags & DEL_PROMPT) && (FindFirstFile(szFullPath, &f) != INVALID_HANDLE_VALUE)) //Don't ask if the file doesn't exist, the following code will make the error-msg
{ {
INT res;
ConErrPrintf (_T("The file %s will be deleted! "), szFullPath); ConErrPrintf (_T("The file %s will be deleted! "), szFullPath);
res = FilePromptYN (_T("Are you sure (Y/N)?")); res = FilePromptYN (_T("Are you sure (Y/N)?"));