Fixed bugs and improved del command.

svn path=/trunk/; revision=352
This commit is contained in:
Eric Kohl 1999-03-30 22:06:36 +00:00
parent 74b0d03ccc
commit e4bcefde7d
16 changed files with 350 additions and 160 deletions

View file

@ -30,7 +30,7 @@
#include <tchar.h> #include <tchar.h>
#define CMD_VER "0.1 pre 1" #define CMD_VER "0.1 pre 2"
#ifdef _MSC_VER #ifdef _MSC_VER
#define SHELLVER "Version " CMD_VER " [" __DATE__ ", msc]" #define SHELLVER "Version " CMD_VER " [" __DATE__ ", msc]"
@ -58,8 +58,7 @@
#define ERROR_E2BIG "ERROR: Argument list too long" #define ERROR_E2BIG "ERROR: Argument list too long"
#define ERROR_EINVAL "ERROR: Invalid argument" #define ERROR_EINVAL "ERROR: Invalid argument"
#define SHELLINFO "ReactOS Command Line Interface" #define SHELLINFO "ReactOS Command Line Interface"
#define USAGE "usage"
#define D_ON "on" #define D_ON "on"

View file

@ -21,8 +21,11 @@
* 21-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeiung.de>) * 21-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeiung.de>)
* Started major rewrite using a new structure. * Started major rewrite using a new structure.
* *
* 03-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeiung.de>) * 03-Feb-1999 (Eric Kohl <ekohl@abo.rhein-zeiung.de>)
* First working version. * First working version.
*
* 30-Mar-1999 (Eric Kohl <ekohl@abo.rhein-zeiung.de>)
* Added quiet ("/Q"), wipe ("/W") and zap ("/Z") option.
*/ */
#include "config.h" #include "config.h"
@ -33,7 +36,6 @@
#include <tchar.h> #include <tchar.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h>
#include "cmd.h" #include "cmd.h"
@ -44,13 +46,30 @@
#define PROMPT_BREAK 3 #define PROMPT_BREAK 3
enum
{
DEL_ATTRIBUTES = 0x001, /* /A : not implemented */
DEL_ERROR = 0x002, /* /E : not implemented */
DEL_NOTHING = 0x004, /* /N */
DEL_PROMPT = 0x008, /* /P : not implemented */
DEL_QUIET = 0x010, /* /Q */
DEL_SUBDIR = 0x020, /* /S : not implemented */
DEL_TOTAL = 0x040, /* /T */
DEL_WIPE = 0x080, /* /W */
DEL_EMPTYDIR = 0x100, /* /X : not implemented */
DEL_YES = 0x200, /* /Y : not implemented */
DEL_ZAP = 0x400 /* /Z */
};
static BOOL ConfirmDeleteAll (VOID) static BOOL ConfirmDeleteAll (VOID)
{ {
TCHAR inp[10]; TCHAR inp[10];
LPTSTR p; LPTSTR p;
ConOutPrintf ("All files in directory will be deleted!\n" ConOutPrintf (_T("All files in directory will be deleted!\n"
"Are you sure (Y/N)? "); "Are you sure (Y/N)? "));
ConInString (inp, 10); ConInString (inp, 10);
_tcsupr (inp); _tcsupr (inp);
@ -101,46 +120,49 @@ static INT Prompt (LPTSTR str)
} }
static BOOL
RemoveFile (LPTSTR lpFileName, DWORD dwFlags)
{
if (dwFlags & DEL_WIPE)
{
/* FIXME: Wipe the given file */
}
return DeleteFile (lpFileName);
}
INT cmd_del (LPTSTR cmd, LPTSTR param) INT cmd_del (LPTSTR cmd, LPTSTR param)
{ {
LPTSTR *arg = NULL; LPTSTR *arg = NULL;
INT args; INT args;
INT i; INT i;
INT nEvalArgs = 0; /* nunber of evaluated arguments */ INT nEvalArgs = 0; /* nunber of evaluated arguments */
BOOL bNothing = FALSE; DWORD dwFlags = 0;
BOOL bQuiet = FALSE; DWORD dwFiles = 0;
BOOL bPrompt = FALSE;
HANDLE hFile; HANDLE hFile;
WIN32_FIND_DATA f; WIN32_FIND_DATA f;
// DWORD dwAttributes;
if (!_tcsncmp (param, _T("/?"), 2)) if (!_tcsncmp (param, _T("/?"), 2))
{ {
/*
ConOutPuts (_T("Deletes one or more files.\n\n"
"DEL [drive:][path]filename [/P]\n"
"DELETE [drive:][path]filename [/P]\n"
"ERASE [drive:][path]filename [/P]\n\n"
" [drive:][path]filename Specifies the file(s) to delete. Specify multiple\n"
" files by using wildcards.\n"
" /P Prompts for confirmation before deleting each file."));
*/
ConOutPuts (_T("Deletes one or more files.\n" ConOutPuts (_T("Deletes one or more files.\n"
"\n" "\n"
"DEL [/N /P /Q] file ...\n" "DEL [/N /P /T /Q /W /Z] file ...\n"
"DELETE [/N /P /Q] file ...\n" "DELETE [/N /P /T /Q /W /Z] file ...\n"
"ERASE [/N /P /Q] file ...\n" "ERASE [/N /P /T /Q /W /Z] file ...\n"
"\n" "\n"
" file Specifies the file(s) to delete.\n" " file Specifies the file(s) to delete.\n"
"\n" "\n"
" /N Nothing.\n" " /N Nothing.\n"
" /P Prompts for confirmation before deleting each file.\n" " /P Prompts for confirmation before deleting each file.\n"
" (Not implemented yet!)\n" " (Not implemented yet!)\n"
" /Q Quiet." " /T Display total number of deleted files and freed disk space.\n"
" /Q Quiet.\n"
" /W Wipe. Overwrite the file with zeros before deleting it.\n"
" /Z Zap (delete hidden, read-only and system files).\n"
)); ));
return 0; return 0;
@ -160,15 +182,31 @@ INT cmd_del (LPTSTR cmd, LPTSTR param)
switch (_totupper (arg[i][1])) switch (_totupper (arg[i][1]))
{ {
case _T('N'): case _T('N'):
bNothing = TRUE; dwFlags |= DEL_NOTHING;
break; break;
case _T('P'): case _T('P'):
bPrompt = TRUE; dwFlags |= DEL_PROMPT;
break; break;
case _T('Q'): case _T('Q'):
bQuiet = TRUE; dwFlags |= DEL_QUIET;
break;
case _T('S'):
dwFlags |= DEL_SUBDIR;
break;
case _T('T'):
dwFlags |= DEL_TOTAL;
break;
case _T('W'):
dwFlags |= DEL_WIPE;
break;
case _T('Z'):
dwFlags |= DEL_ZAP;
break; break;
} }
@ -200,14 +238,14 @@ INT cmd_del (LPTSTR cmd, LPTSTR param)
if (*arg[i] != _T('/')) if (*arg[i] != _T('/'))
{ {
#ifdef _DEBUG #ifdef _DEBUG
ConErrPrintf ("File: %s\n", arg[i]); ConErrPrintf (_T("File: %s\n"), arg[i]);
#endif #endif
if (_tcschr (arg[i], _T('*')) || _tcschr (arg[i], _T('?'))) if (_tcschr (arg[i], _T('*')) || _tcschr (arg[i], _T('?')))
{ {
/* wildcards in filespec */ /* wildcards in filespec */
#ifdef _DEBUG #ifdef _DEBUG
ConErrPrintf ("Wildcards!\n\n"); ConErrPrintf (_T("Wildcards!\n\n"));
#endif #endif
hFile = FindFirstFile (arg[i], &f); hFile = FindFirstFile (arg[i], &f);
@ -220,18 +258,46 @@ INT cmd_del (LPTSTR cmd, LPTSTR param)
do do
{ {
/* ignore "." and ".." */
if (!_tcscmp (f.cFileName, _T(".")) || if (!_tcscmp (f.cFileName, _T(".")) ||
!_tcscmp (f.cFileName, _T(".."))) !_tcscmp (f.cFileName, _T("..")))
continue; continue;
#ifdef _DEBUG if (!(dwFlags & DEL_QUIET) && !(dwFlags & DEL_TOTAL))
ConErrPrintf ("Delete file: %s\n", f.cFileName); ConErrPrintf (_T("Deleting: %s\n"), f.cFileName);
#endif
if (!bNothing) /* delete the file */
if (!(dwFlags & DEL_NOTHING))
{ {
if (!DeleteFile (f.cFileName)) if (RemoveFile (f.cFileName, dwFlags))
ErrorMessage (GetLastError(), _T("")); {
dwFiles++;
}
else
{
if (dwFlags & DEL_ZAP)
{
if (SetFileAttributes (arg[i], 0))
{
if (RemoveFile (arg[i], dwFlags))
{
dwFiles++;
}
else
{
ErrorMessage (GetLastError(), _T(""));
}
}
else
{
ErrorMessage (GetLastError(), _T(""));
}
}
else
{
ErrorMessage (GetLastError(), _T(""));
}
}
} }
@ -242,15 +308,45 @@ INT cmd_del (LPTSTR cmd, LPTSTR param)
else else
{ {
/* no wildcards in filespec */ /* no wildcards in filespec */
#ifdef _DEBUG #ifdef _DEBUG
ConErrPrintf ("No Wildcards!\n"); ConErrPrintf (_T("No Wildcards!\n"));
ConErrPrintf ("Delete file: %s\n", arg[i]);
#endif #endif
if (!bNothing) if (!(dwFlags & DEL_QUIET) && !(dwFlags & DEL_TOTAL))
ConOutPrintf (_T("Deleting %s\n"), arg[i]);
if (!(dwFlags & DEL_NOTHING))
{ {
if (!DeleteFile (arg[i])) if (RemoveFile (arg[i], dwFlags))
ErrorMessage (GetLastError(), _T("")); {
dwFiles++;
}
else
{
if (dwFlags & DEL_ZAP)
{
if (SetFileAttributes (arg[i], 0))
{
if (RemoveFile (arg[i], dwFlags))
{
dwFiles++;
}
else
{
ErrorMessage (GetLastError(), _T(""));
}
}
else
{
ErrorMessage (GetLastError(), _T(""));
}
}
else
{
ErrorMessage (GetLastError(), _T(""));
}
}
} }
} }
} }
@ -266,6 +362,16 @@ INT cmd_del (LPTSTR cmd, LPTSTR param)
freep (arg); freep (arg);
if (!(dwFlags & DEL_QUIET))
{
if (dwFiles == 0)
ConOutPrintf (_T(" 0 files deleted\n"));
else
ConOutPrintf (_T(" %lu file%s deleted\n"),
dwFiles, (dwFiles == 1) ? "s" : "");
}
return 0; return 0;
} }

View file

@ -237,7 +237,7 @@ DirReadParam (LPTSTR line, LPTSTR *param, LPDWORD lpFlags)
{ {
if (_totupper (*line) == _T('S')) if (_totupper (*line) == _T('S'))
*lpFlags |= DIR_RECURSE; *lpFlags |= DIR_RECURSE;
else if (_toupper (*line) == _T('P')) else if (_totupper (*line) == _T('P'))
*lpFlags |= DIR_PAGE; *lpFlags |= DIR_PAGE;
else if (_totupper (*line) == _T('W')) else if (_totupper (*line) == _T('W'))
*lpFlags |= DIR_WIDE; *lpFlags |= DIR_WIDE;
@ -811,8 +811,8 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
count = 0; count = 0;
} }
uliSize.u.LowPart += file.nFileSizeLow; uliSize.u.LowPart = file.nFileSizeLow;
uliSize.u.HighPart += file.nFileSizeHigh; uliSize.u.HighPart = file.nFileSizeHigh;
bytecount.QuadPart += uliSize.QuadPart; bytecount.QuadPart += uliSize.QuadPart;
} }
else if (dwFlags & DIR_BARE) else if (dwFlags & DIR_BARE)
@ -842,8 +842,8 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
if (IncLine (pLine, dwFlags)) if (IncLine (pLine, dwFlags))
return 1; return 1;
uliSize.u.LowPart += file.nFileSizeLow; uliSize.u.LowPart = file.nFileSizeLow;
uliSize.u.HighPart += file.nFileSizeHigh; uliSize.u.HighPart = file.nFileSizeHigh;
bytecount.QuadPart += uliSize.QuadPart; bytecount.QuadPart += uliSize.QuadPart;
} }
else else
@ -867,8 +867,8 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
{ {
ULARGE_INTEGER uliSize; ULARGE_INTEGER uliSize;
uliSize.u.LowPart = file.nFileSizeLow; uliSize.u.LowPart = file.nFileSizeLow;
uliSize.u.HighPart = file.nFileSizeHigh; uliSize.u.HighPart = file.nFileSizeHigh;
ConvertULargeInteger (uliSize, buffer, sizeof(buffer)); ConvertULargeInteger (uliSize, buffer, sizeof(buffer));
ConOutPrintf (_T(" %20s"), buffer); ConOutPrintf (_T(" %20s"), buffer);
@ -919,8 +919,8 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
{ {
ULARGE_INTEGER uliSize; ULARGE_INTEGER uliSize;
uliSize.u.LowPart = file.nFileSizeLow; uliSize.u.LowPart = file.nFileSizeLow;
uliSize.u.HighPart = file.nFileSizeHigh; uliSize.u.HighPart = file.nFileSizeHigh;
ConvertULargeInteger (uliSize, buffer, sizeof(buffer)); ConvertULargeInteger (uliSize, buffer, sizeof(buffer));
ConOutPrintf (_T(" %10s "), buffer); ConOutPrintf (_T(" %10s "), buffer);

View file

@ -342,4 +342,12 @@ o ATTRIB and DEL can handle multiple filenames now.
o Fixed handling of environment variables. o Fixed handling of environment variables.
o Added CHCP command. o Added CHCP command.
o Fixed keyboard input bug. o Fixed keyboard input bug.
o Rewrote DEL and MOVE commands. o Rewrote DEL and MOVE commands.
30-Mar-1999 ReactOS CMD version 0.1 pre 2 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
o Cleaned up DIR command.
o Searching for executables in the right order.
o Fixed some little but nasty bugs.
o Added TITLE command. Thanks to Emanuele Aliberti!
o Added "/Q", "/W" and "/Z" options to DEL command.

View file

@ -8,10 +8,12 @@
# target: executable (not tested/experimental) # target: executable (not tested/experimental)
all: cmd.exe all: cmd.exe
OBJECTS = ../common/crt0.o cmd.o attrib.o alias.o batch.o beep.o call.o chcp.o cls.o cmdinput.o cmdtable.o\ OBJECTS = ../common/crt0.o cmd.o attrib.o alias.o batch.o beep.o call.o \
color.o console.o copy.o date.o del.o dir.o dirstack.o echo.o error.o filecomp.o for.o goto.o history.o if.o\ chcp.o cls.o cmdinput.o cmdtable.o color.o console.o copy.o date.o \
internal.o label.o locale.o misc.o move.o path.o pause.o prompt.o redir.o ren.o ros.o set.o shift.o time.o title.o type.o ver.o\ del.o dir.o dirstack.o echo.o error.o filecomp.o for.o goto.o \
verify.o vol.o where.o history.o if.o internal.o label.o locale.o misc.o move.o path.o \
pause.o prompt.o redir.o ren.o set.o shift.o time.o title.o type.o \
ver.o verify.o vol.o where.o
LIBS= ../../lib/kernel32/kernel32.a ../../lib/ntdll/ntdll.a LIBS= ../../lib/kernel32/kernel32.a ../../lib/ntdll/ntdll.a

View file

@ -1,5 +1,5 @@
ReactOS Command Line Interface "CMD" version 0.0.4 ReactOS Command Line Interface "CMD" version 0.1 pre 2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is the fourth pre-alpha release of CMD.EXE for ReactOS. This is the fourth pre-alpha release of CMD.EXE for ReactOS.
It was converted from the FreeDOS COMMAND.COM. It was converted from the FreeDOS COMMAND.COM.
@ -7,7 +7,7 @@ It was converted from the FreeDOS COMMAND.COM.
Warning!! Warning!! Warning!! Warning!! Warning!! Warning!!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is a pre-alpha version! Many features have not been tested! This is an alpha version! Many features have not been tested!
Be careful when you use commands that write to your disk drives, Be careful when you use commands that write to your disk drives,
they might destroy your files or the file system!!! they might destroy your files or the file system!!!

View file

@ -90,22 +90,4 @@ _makepath( char *path, const char *drive, const char *dir, const char *fname, co
} }
} }
#if 0
int getch(void)
{
DWORD NumberOfCharsRead = 0;
DWORD dwWritten;
char c;
ReadConsoleA (GetStdHandle (STD_INPUT_HANDLE), &c, 1, &NumberOfCharsRead, NULL);
if ( c == 10 )
c = 13;
WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), &c, 1, &dwWritten, NULL);
return c;
}
#endif
#endif #endif

View file

@ -2,8 +2,6 @@ Things to do
~~~~~~~~~~~~ ~~~~~~~~~~~~
Fix bugs :) Fix bugs :)
Rewrite DIR command (Unicode aware / new structure).
Optimize the code! For size and speed. There are numerous places Optimize the code! For size and speed. There are numerous places
where the code is hardly optimal for either. where the code is hardly optimal for either.

View file

@ -30,7 +30,7 @@
#include <tchar.h> #include <tchar.h>
#define CMD_VER "0.1 pre 1" #define CMD_VER "0.1 pre 2"
#ifdef _MSC_VER #ifdef _MSC_VER
#define SHELLVER "Version " CMD_VER " [" __DATE__ ", msc]" #define SHELLVER "Version " CMD_VER " [" __DATE__ ", msc]"
@ -58,8 +58,7 @@
#define ERROR_E2BIG "ERROR: Argument list too long" #define ERROR_E2BIG "ERROR: Argument list too long"
#define ERROR_EINVAL "ERROR: Invalid argument" #define ERROR_EINVAL "ERROR: Invalid argument"
#define SHELLINFO "ReactOS Command Line Interface" #define SHELLINFO "ReactOS Command Line Interface"
#define USAGE "usage"
#define D_ON "on" #define D_ON "on"

View file

@ -21,8 +21,11 @@
* 21-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeiung.de>) * 21-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeiung.de>)
* Started major rewrite using a new structure. * Started major rewrite using a new structure.
* *
* 03-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeiung.de>) * 03-Feb-1999 (Eric Kohl <ekohl@abo.rhein-zeiung.de>)
* First working version. * First working version.
*
* 30-Mar-1999 (Eric Kohl <ekohl@abo.rhein-zeiung.de>)
* Added quiet ("/Q"), wipe ("/W") and zap ("/Z") option.
*/ */
#include "config.h" #include "config.h"
@ -33,7 +36,6 @@
#include <tchar.h> #include <tchar.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <ctype.h>
#include "cmd.h" #include "cmd.h"
@ -44,13 +46,30 @@
#define PROMPT_BREAK 3 #define PROMPT_BREAK 3
enum
{
DEL_ATTRIBUTES = 0x001, /* /A : not implemented */
DEL_ERROR = 0x002, /* /E : not implemented */
DEL_NOTHING = 0x004, /* /N */
DEL_PROMPT = 0x008, /* /P : not implemented */
DEL_QUIET = 0x010, /* /Q */
DEL_SUBDIR = 0x020, /* /S : not implemented */
DEL_TOTAL = 0x040, /* /T */
DEL_WIPE = 0x080, /* /W */
DEL_EMPTYDIR = 0x100, /* /X : not implemented */
DEL_YES = 0x200, /* /Y : not implemented */
DEL_ZAP = 0x400 /* /Z */
};
static BOOL ConfirmDeleteAll (VOID) static BOOL ConfirmDeleteAll (VOID)
{ {
TCHAR inp[10]; TCHAR inp[10];
LPTSTR p; LPTSTR p;
ConOutPrintf ("All files in directory will be deleted!\n" ConOutPrintf (_T("All files in directory will be deleted!\n"
"Are you sure (Y/N)? "); "Are you sure (Y/N)? "));
ConInString (inp, 10); ConInString (inp, 10);
_tcsupr (inp); _tcsupr (inp);
@ -101,46 +120,49 @@ static INT Prompt (LPTSTR str)
} }
static BOOL
RemoveFile (LPTSTR lpFileName, DWORD dwFlags)
{
if (dwFlags & DEL_WIPE)
{
/* FIXME: Wipe the given file */
}
return DeleteFile (lpFileName);
}
INT cmd_del (LPTSTR cmd, LPTSTR param) INT cmd_del (LPTSTR cmd, LPTSTR param)
{ {
LPTSTR *arg = NULL; LPTSTR *arg = NULL;
INT args; INT args;
INT i; INT i;
INT nEvalArgs = 0; /* nunber of evaluated arguments */ INT nEvalArgs = 0; /* nunber of evaluated arguments */
BOOL bNothing = FALSE; DWORD dwFlags = 0;
BOOL bQuiet = FALSE; DWORD dwFiles = 0;
BOOL bPrompt = FALSE;
HANDLE hFile; HANDLE hFile;
WIN32_FIND_DATA f; WIN32_FIND_DATA f;
// DWORD dwAttributes;
if (!_tcsncmp (param, _T("/?"), 2)) if (!_tcsncmp (param, _T("/?"), 2))
{ {
/*
ConOutPuts (_T("Deletes one or more files.\n\n"
"DEL [drive:][path]filename [/P]\n"
"DELETE [drive:][path]filename [/P]\n"
"ERASE [drive:][path]filename [/P]\n\n"
" [drive:][path]filename Specifies the file(s) to delete. Specify multiple\n"
" files by using wildcards.\n"
" /P Prompts for confirmation before deleting each file."));
*/
ConOutPuts (_T("Deletes one or more files.\n" ConOutPuts (_T("Deletes one or more files.\n"
"\n" "\n"
"DEL [/N /P /Q] file ...\n" "DEL [/N /P /T /Q /W /Z] file ...\n"
"DELETE [/N /P /Q] file ...\n" "DELETE [/N /P /T /Q /W /Z] file ...\n"
"ERASE [/N /P /Q] file ...\n" "ERASE [/N /P /T /Q /W /Z] file ...\n"
"\n" "\n"
" file Specifies the file(s) to delete.\n" " file Specifies the file(s) to delete.\n"
"\n" "\n"
" /N Nothing.\n" " /N Nothing.\n"
" /P Prompts for confirmation before deleting each file.\n" " /P Prompts for confirmation before deleting each file.\n"
" (Not implemented yet!)\n" " (Not implemented yet!)\n"
" /Q Quiet." " /T Display total number of deleted files and freed disk space.\n"
" /Q Quiet.\n"
" /W Wipe. Overwrite the file with zeros before deleting it.\n"
" /Z Zap (delete hidden, read-only and system files).\n"
)); ));
return 0; return 0;
@ -160,15 +182,31 @@ INT cmd_del (LPTSTR cmd, LPTSTR param)
switch (_totupper (arg[i][1])) switch (_totupper (arg[i][1]))
{ {
case _T('N'): case _T('N'):
bNothing = TRUE; dwFlags |= DEL_NOTHING;
break; break;
case _T('P'): case _T('P'):
bPrompt = TRUE; dwFlags |= DEL_PROMPT;
break; break;
case _T('Q'): case _T('Q'):
bQuiet = TRUE; dwFlags |= DEL_QUIET;
break;
case _T('S'):
dwFlags |= DEL_SUBDIR;
break;
case _T('T'):
dwFlags |= DEL_TOTAL;
break;
case _T('W'):
dwFlags |= DEL_WIPE;
break;
case _T('Z'):
dwFlags |= DEL_ZAP;
break; break;
} }
@ -200,14 +238,14 @@ INT cmd_del (LPTSTR cmd, LPTSTR param)
if (*arg[i] != _T('/')) if (*arg[i] != _T('/'))
{ {
#ifdef _DEBUG #ifdef _DEBUG
ConErrPrintf ("File: %s\n", arg[i]); ConErrPrintf (_T("File: %s\n"), arg[i]);
#endif #endif
if (_tcschr (arg[i], _T('*')) || _tcschr (arg[i], _T('?'))) if (_tcschr (arg[i], _T('*')) || _tcschr (arg[i], _T('?')))
{ {
/* wildcards in filespec */ /* wildcards in filespec */
#ifdef _DEBUG #ifdef _DEBUG
ConErrPrintf ("Wildcards!\n\n"); ConErrPrintf (_T("Wildcards!\n\n"));
#endif #endif
hFile = FindFirstFile (arg[i], &f); hFile = FindFirstFile (arg[i], &f);
@ -220,18 +258,46 @@ INT cmd_del (LPTSTR cmd, LPTSTR param)
do do
{ {
/* ignore "." and ".." */
if (!_tcscmp (f.cFileName, _T(".")) || if (!_tcscmp (f.cFileName, _T(".")) ||
!_tcscmp (f.cFileName, _T(".."))) !_tcscmp (f.cFileName, _T("..")))
continue; continue;
#ifdef _DEBUG if (!(dwFlags & DEL_QUIET) && !(dwFlags & DEL_TOTAL))
ConErrPrintf ("Delete file: %s\n", f.cFileName); ConErrPrintf (_T("Deleting: %s\n"), f.cFileName);
#endif
if (!bNothing) /* delete the file */
if (!(dwFlags & DEL_NOTHING))
{ {
if (!DeleteFile (f.cFileName)) if (RemoveFile (f.cFileName, dwFlags))
ErrorMessage (GetLastError(), _T("")); {
dwFiles++;
}
else
{
if (dwFlags & DEL_ZAP)
{
if (SetFileAttributes (arg[i], 0))
{
if (RemoveFile (arg[i], dwFlags))
{
dwFiles++;
}
else
{
ErrorMessage (GetLastError(), _T(""));
}
}
else
{
ErrorMessage (GetLastError(), _T(""));
}
}
else
{
ErrorMessage (GetLastError(), _T(""));
}
}
} }
@ -242,15 +308,45 @@ INT cmd_del (LPTSTR cmd, LPTSTR param)
else else
{ {
/* no wildcards in filespec */ /* no wildcards in filespec */
#ifdef _DEBUG #ifdef _DEBUG
ConErrPrintf ("No Wildcards!\n"); ConErrPrintf (_T("No Wildcards!\n"));
ConErrPrintf ("Delete file: %s\n", arg[i]);
#endif #endif
if (!bNothing) if (!(dwFlags & DEL_QUIET) && !(dwFlags & DEL_TOTAL))
ConOutPrintf (_T("Deleting %s\n"), arg[i]);
if (!(dwFlags & DEL_NOTHING))
{ {
if (!DeleteFile (arg[i])) if (RemoveFile (arg[i], dwFlags))
ErrorMessage (GetLastError(), _T("")); {
dwFiles++;
}
else
{
if (dwFlags & DEL_ZAP)
{
if (SetFileAttributes (arg[i], 0))
{
if (RemoveFile (arg[i], dwFlags))
{
dwFiles++;
}
else
{
ErrorMessage (GetLastError(), _T(""));
}
}
else
{
ErrorMessage (GetLastError(), _T(""));
}
}
else
{
ErrorMessage (GetLastError(), _T(""));
}
}
} }
} }
} }
@ -266,6 +362,16 @@ INT cmd_del (LPTSTR cmd, LPTSTR param)
freep (arg); freep (arg);
if (!(dwFlags & DEL_QUIET))
{
if (dwFiles == 0)
ConOutPrintf (_T(" 0 files deleted\n"));
else
ConOutPrintf (_T(" %lu file%s deleted\n"),
dwFiles, (dwFiles == 1) ? "s" : "");
}
return 0; return 0;
} }

View file

@ -237,7 +237,7 @@ DirReadParam (LPTSTR line, LPTSTR *param, LPDWORD lpFlags)
{ {
if (_totupper (*line) == _T('S')) if (_totupper (*line) == _T('S'))
*lpFlags |= DIR_RECURSE; *lpFlags |= DIR_RECURSE;
else if (_toupper (*line) == _T('P')) else if (_totupper (*line) == _T('P'))
*lpFlags |= DIR_PAGE; *lpFlags |= DIR_PAGE;
else if (_totupper (*line) == _T('W')) else if (_totupper (*line) == _T('W'))
*lpFlags |= DIR_WIDE; *lpFlags |= DIR_WIDE;
@ -811,8 +811,8 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
count = 0; count = 0;
} }
uliSize.u.LowPart += file.nFileSizeLow; uliSize.u.LowPart = file.nFileSizeLow;
uliSize.u.HighPart += file.nFileSizeHigh; uliSize.u.HighPart = file.nFileSizeHigh;
bytecount.QuadPart += uliSize.QuadPart; bytecount.QuadPart += uliSize.QuadPart;
} }
else if (dwFlags & DIR_BARE) else if (dwFlags & DIR_BARE)
@ -842,8 +842,8 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
if (IncLine (pLine, dwFlags)) if (IncLine (pLine, dwFlags))
return 1; return 1;
uliSize.u.LowPart += file.nFileSizeLow; uliSize.u.LowPart = file.nFileSizeLow;
uliSize.u.HighPart += file.nFileSizeHigh; uliSize.u.HighPart = file.nFileSizeHigh;
bytecount.QuadPart += uliSize.QuadPart; bytecount.QuadPart += uliSize.QuadPart;
} }
else else
@ -867,8 +867,8 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
{ {
ULARGE_INTEGER uliSize; ULARGE_INTEGER uliSize;
uliSize.u.LowPart = file.nFileSizeLow; uliSize.u.LowPart = file.nFileSizeLow;
uliSize.u.HighPart = file.nFileSizeHigh; uliSize.u.HighPart = file.nFileSizeHigh;
ConvertULargeInteger (uliSize, buffer, sizeof(buffer)); ConvertULargeInteger (uliSize, buffer, sizeof(buffer));
ConOutPrintf (_T(" %20s"), buffer); ConOutPrintf (_T(" %20s"), buffer);
@ -919,8 +919,8 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
{ {
ULARGE_INTEGER uliSize; ULARGE_INTEGER uliSize;
uliSize.u.LowPart = file.nFileSizeLow; uliSize.u.LowPart = file.nFileSizeLow;
uliSize.u.HighPart = file.nFileSizeHigh; uliSize.u.HighPart = file.nFileSizeHigh;
ConvertULargeInteger (uliSize, buffer, sizeof(buffer)); ConvertULargeInteger (uliSize, buffer, sizeof(buffer));
ConOutPrintf (_T(" %10s "), buffer); ConOutPrintf (_T(" %10s "), buffer);

View file

@ -342,4 +342,12 @@ o ATTRIB and DEL can handle multiple filenames now.
o Fixed handling of environment variables. o Fixed handling of environment variables.
o Added CHCP command. o Added CHCP command.
o Fixed keyboard input bug. o Fixed keyboard input bug.
o Rewrote DEL and MOVE commands. o Rewrote DEL and MOVE commands.
30-Mar-1999 ReactOS CMD version 0.1 pre 2 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
o Cleaned up DIR command.
o Searching for executables in the right order.
o Fixed some little but nasty bugs.
o Added TITLE command. Thanks to Emanuele Aliberti!
o Added "/Q", "/W" and "/Z" options to DEL command.

View file

@ -8,10 +8,12 @@
# target: executable (not tested/experimental) # target: executable (not tested/experimental)
all: cmd.exe all: cmd.exe
OBJECTS = ../common/crt0.o cmd.o attrib.o alias.o batch.o beep.o call.o chcp.o cls.o cmdinput.o cmdtable.o\ OBJECTS = ../common/crt0.o cmd.o attrib.o alias.o batch.o beep.o call.o \
color.o console.o copy.o date.o del.o dir.o dirstack.o echo.o error.o filecomp.o for.o goto.o history.o if.o\ chcp.o cls.o cmdinput.o cmdtable.o color.o console.o copy.o date.o \
internal.o label.o locale.o misc.o move.o path.o pause.o prompt.o redir.o ren.o ros.o set.o shift.o time.o title.o type.o ver.o\ del.o dir.o dirstack.o echo.o error.o filecomp.o for.o goto.o \
verify.o vol.o where.o history.o if.o internal.o label.o locale.o misc.o move.o path.o \
pause.o prompt.o redir.o ren.o set.o shift.o time.o title.o type.o \
ver.o verify.o vol.o where.o
LIBS= ../../lib/kernel32/kernel32.a ../../lib/ntdll/ntdll.a LIBS= ../../lib/kernel32/kernel32.a ../../lib/ntdll/ntdll.a

View file

@ -1,5 +1,5 @@
ReactOS Command Line Interface "CMD" version 0.0.4 ReactOS Command Line Interface "CMD" version 0.1 pre 2
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is the fourth pre-alpha release of CMD.EXE for ReactOS. This is the fourth pre-alpha release of CMD.EXE for ReactOS.
It was converted from the FreeDOS COMMAND.COM. It was converted from the FreeDOS COMMAND.COM.
@ -7,7 +7,7 @@ It was converted from the FreeDOS COMMAND.COM.
Warning!! Warning!! Warning!! Warning!! Warning!! Warning!!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
This is a pre-alpha version! Many features have not been tested! This is an alpha version! Many features have not been tested!
Be careful when you use commands that write to your disk drives, Be careful when you use commands that write to your disk drives,
they might destroy your files or the file system!!! they might destroy your files or the file system!!!

View file

@ -90,22 +90,4 @@ _makepath( char *path, const char *drive, const char *dir, const char *fname, co
} }
} }
#if 0
int getch(void)
{
DWORD NumberOfCharsRead = 0;
DWORD dwWritten;
char c;
ReadConsoleA (GetStdHandle (STD_INPUT_HANDLE), &c, 1, &NumberOfCharsRead, NULL);
if ( c == 10 )
c = 13;
WriteFile (GetStdHandle (STD_OUTPUT_HANDLE), &c, 1, &dwWritten, NULL);
return c;
}
#endif
#endif #endif

View file

@ -2,8 +2,6 @@ Things to do
~~~~~~~~~~~~ ~~~~~~~~~~~~
Fix bugs :) Fix bugs :)
Rewrite DIR command (Unicode aware / new structure).
Optimize the code! For size and speed. There are numerous places Optimize the code! For size and speed. There are numerous places
where the code is hardly optimal for either. where the code is hardly optimal for either.