mirror of
https://github.com/reactos/reactos.git
synced 2024-12-25 16:50:57 +00:00
Fixed bugs and improved del command.
svn path=/trunk/; revision=352
This commit is contained in:
parent
74b0d03ccc
commit
e4bcefde7d
16 changed files with 350 additions and 160 deletions
|
@ -30,7 +30,7 @@
|
|||
#include <tchar.h>
|
||||
|
||||
|
||||
#define CMD_VER "0.1 pre 1"
|
||||
#define CMD_VER "0.1 pre 2"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define SHELLVER "Version " CMD_VER " [" __DATE__ ", msc]"
|
||||
|
@ -58,8 +58,7 @@
|
|||
#define ERROR_E2BIG "ERROR: Argument list too long"
|
||||
#define ERROR_EINVAL "ERROR: Invalid argument"
|
||||
|
||||
#define SHELLINFO "ReactOS Command Line Interface"
|
||||
#define USAGE "usage"
|
||||
#define SHELLINFO "ReactOS Command Line Interface"
|
||||
|
||||
|
||||
#define D_ON "on"
|
||||
|
|
|
@ -21,8 +21,11 @@
|
|||
* 21-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeiung.de>)
|
||||
* 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.
|
||||
*
|
||||
* 30-Mar-1999 (Eric Kohl <ekohl@abo.rhein-zeiung.de>)
|
||||
* Added quiet ("/Q"), wipe ("/W") and zap ("/Z") option.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -33,7 +36,6 @@
|
|||
#include <tchar.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "cmd.h"
|
||||
|
||||
|
@ -44,13 +46,30 @@
|
|||
#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)
|
||||
{
|
||||
TCHAR inp[10];
|
||||
LPTSTR p;
|
||||
|
||||
ConOutPrintf ("All files in directory will be deleted!\n"
|
||||
"Are you sure (Y/N)? ");
|
||||
ConOutPrintf (_T("All files in directory will be deleted!\n"
|
||||
"Are you sure (Y/N)? "));
|
||||
ConInString (inp, 10);
|
||||
|
||||
_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)
|
||||
{
|
||||
LPTSTR *arg = NULL;
|
||||
INT args;
|
||||
INT i;
|
||||
INT nEvalArgs = 0; /* nunber of evaluated arguments */
|
||||
BOOL bNothing = FALSE;
|
||||
BOOL bQuiet = FALSE;
|
||||
BOOL bPrompt = FALSE;
|
||||
INT nEvalArgs = 0; /* nunber of evaluated arguments */
|
||||
DWORD dwFlags = 0;
|
||||
DWORD dwFiles = 0;
|
||||
|
||||
HANDLE hFile;
|
||||
WIN32_FIND_DATA f;
|
||||
// DWORD dwAttributes;
|
||||
|
||||
|
||||
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"
|
||||
"\n"
|
||||
"DEL [/N /P /Q] file ...\n"
|
||||
"DELETE [/N /P /Q] file ...\n"
|
||||
"ERASE [/N /P /Q] file ...\n"
|
||||
"DEL [/N /P /T /Q /W /Z] file ...\n"
|
||||
"DELETE [/N /P /T /Q /W /Z] file ...\n"
|
||||
"ERASE [/N /P /T /Q /W /Z] file ...\n"
|
||||
"\n"
|
||||
" file Specifies the file(s) to delete.\n"
|
||||
"\n"
|
||||
" /N Nothing.\n"
|
||||
" /P Prompts for confirmation before deleting each file.\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;
|
||||
|
@ -160,15 +182,31 @@ INT cmd_del (LPTSTR cmd, LPTSTR param)
|
|||
switch (_totupper (arg[i][1]))
|
||||
{
|
||||
case _T('N'):
|
||||
bNothing = TRUE;
|
||||
dwFlags |= DEL_NOTHING;
|
||||
break;
|
||||
|
||||
case _T('P'):
|
||||
bPrompt = TRUE;
|
||||
dwFlags |= DEL_PROMPT;
|
||||
break;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -200,14 +238,14 @@ INT cmd_del (LPTSTR cmd, LPTSTR param)
|
|||
if (*arg[i] != _T('/'))
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
ConErrPrintf ("File: %s\n", arg[i]);
|
||||
ConErrPrintf (_T("File: %s\n"), arg[i]);
|
||||
#endif
|
||||
|
||||
if (_tcschr (arg[i], _T('*')) || _tcschr (arg[i], _T('?')))
|
||||
{
|
||||
/* wildcards in filespec */
|
||||
#ifdef _DEBUG
|
||||
ConErrPrintf ("Wildcards!\n\n");
|
||||
ConErrPrintf (_T("Wildcards!\n\n"));
|
||||
#endif
|
||||
|
||||
hFile = FindFirstFile (arg[i], &f);
|
||||
|
@ -220,18 +258,46 @@ INT cmd_del (LPTSTR cmd, LPTSTR param)
|
|||
|
||||
do
|
||||
{
|
||||
/* ignore "." and ".." */
|
||||
if (!_tcscmp (f.cFileName, _T(".")) ||
|
||||
!_tcscmp (f.cFileName, _T("..")))
|
||||
continue;
|
||||
|
||||
#ifdef _DEBUG
|
||||
ConErrPrintf ("Delete file: %s\n", f.cFileName);
|
||||
#endif
|
||||
if (!(dwFlags & DEL_QUIET) && !(dwFlags & DEL_TOTAL))
|
||||
ConErrPrintf (_T("Deleting: %s\n"), f.cFileName);
|
||||
|
||||
if (!bNothing)
|
||||
/* delete the file */
|
||||
if (!(dwFlags & DEL_NOTHING))
|
||||
{
|
||||
if (!DeleteFile (f.cFileName))
|
||||
ErrorMessage (GetLastError(), _T(""));
|
||||
if (RemoveFile (f.cFileName, dwFlags))
|
||||
{
|
||||
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
|
||||
{
|
||||
/* no wildcards in filespec */
|
||||
|
||||
#ifdef _DEBUG
|
||||
ConErrPrintf ("No Wildcards!\n");
|
||||
ConErrPrintf ("Delete file: %s\n", arg[i]);
|
||||
ConErrPrintf (_T("No Wildcards!\n"));
|
||||
#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]))
|
||||
ErrorMessage (GetLastError(), _T(""));
|
||||
if (RemoveFile (arg[i], dwFlags))
|
||||
{
|
||||
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);
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -237,7 +237,7 @@ DirReadParam (LPTSTR line, LPTSTR *param, LPDWORD lpFlags)
|
|||
{
|
||||
if (_totupper (*line) == _T('S'))
|
||||
*lpFlags |= DIR_RECURSE;
|
||||
else if (_toupper (*line) == _T('P'))
|
||||
else if (_totupper (*line) == _T('P'))
|
||||
*lpFlags |= DIR_PAGE;
|
||||
else if (_totupper (*line) == _T('W'))
|
||||
*lpFlags |= DIR_WIDE;
|
||||
|
@ -811,8 +811,8 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
|
|||
count = 0;
|
||||
}
|
||||
|
||||
uliSize.u.LowPart += file.nFileSizeLow;
|
||||
uliSize.u.HighPart += file.nFileSizeHigh;
|
||||
uliSize.u.LowPart = file.nFileSizeLow;
|
||||
uliSize.u.HighPart = file.nFileSizeHigh;
|
||||
bytecount.QuadPart += uliSize.QuadPart;
|
||||
}
|
||||
else if (dwFlags & DIR_BARE)
|
||||
|
@ -842,8 +842,8 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
|
|||
if (IncLine (pLine, dwFlags))
|
||||
return 1;
|
||||
|
||||
uliSize.u.LowPart += file.nFileSizeLow;
|
||||
uliSize.u.HighPart += file.nFileSizeHigh;
|
||||
uliSize.u.LowPart = file.nFileSizeLow;
|
||||
uliSize.u.HighPart = file.nFileSizeHigh;
|
||||
bytecount.QuadPart += uliSize.QuadPart;
|
||||
}
|
||||
else
|
||||
|
@ -867,8 +867,8 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
|
|||
{
|
||||
ULARGE_INTEGER uliSize;
|
||||
|
||||
uliSize.u.LowPart = file.nFileSizeLow;
|
||||
uliSize.u.HighPart = file.nFileSizeHigh;
|
||||
uliSize.u.LowPart = file.nFileSizeLow;
|
||||
uliSize.u.HighPart = file.nFileSizeHigh;
|
||||
|
||||
ConvertULargeInteger (uliSize, buffer, sizeof(buffer));
|
||||
ConOutPrintf (_T(" %20s"), buffer);
|
||||
|
@ -919,8 +919,8 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
|
|||
{
|
||||
ULARGE_INTEGER uliSize;
|
||||
|
||||
uliSize.u.LowPart = file.nFileSizeLow;
|
||||
uliSize.u.HighPart = file.nFileSizeHigh;
|
||||
uliSize.u.LowPart = file.nFileSizeLow;
|
||||
uliSize.u.HighPart = file.nFileSizeHigh;
|
||||
|
||||
ConvertULargeInteger (uliSize, buffer, sizeof(buffer));
|
||||
ConOutPrintf (_T(" %10s "), buffer);
|
||||
|
|
|
@ -342,4 +342,12 @@ o ATTRIB and DEL can handle multiple filenames now.
|
|||
o Fixed handling of environment variables.
|
||||
o Added CHCP command.
|
||||
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.
|
||||
|
|
|
@ -8,10 +8,12 @@
|
|||
# target: executable (not tested/experimental)
|
||||
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\
|
||||
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\
|
||||
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\
|
||||
verify.o vol.o where.o
|
||||
OBJECTS = ../common/crt0.o cmd.o attrib.o alias.o batch.o beep.o call.o \
|
||||
chcp.o cls.o cmdinput.o cmdtable.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 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
|
||||
|
||||
|
|
|
@ -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.
|
||||
It was converted from the FreeDOS COMMAND.COM.
|
||||
|
@ -7,7 +7,7 @@ It was converted from the FreeDOS COMMAND.COM.
|
|||
|
||||
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,
|
||||
they might destroy your files or the file system!!!
|
||||
|
||||
|
|
|
@ -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
|
|
@ -2,8 +2,6 @@ Things to do
|
|||
~~~~~~~~~~~~
|
||||
Fix bugs :)
|
||||
|
||||
Rewrite DIR command (Unicode aware / new structure).
|
||||
|
||||
Optimize the code! For size and speed. There are numerous places
|
||||
where the code is hardly optimal for either.
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
#include <tchar.h>
|
||||
|
||||
|
||||
#define CMD_VER "0.1 pre 1"
|
||||
#define CMD_VER "0.1 pre 2"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#define SHELLVER "Version " CMD_VER " [" __DATE__ ", msc]"
|
||||
|
@ -58,8 +58,7 @@
|
|||
#define ERROR_E2BIG "ERROR: Argument list too long"
|
||||
#define ERROR_EINVAL "ERROR: Invalid argument"
|
||||
|
||||
#define SHELLINFO "ReactOS Command Line Interface"
|
||||
#define USAGE "usage"
|
||||
#define SHELLINFO "ReactOS Command Line Interface"
|
||||
|
||||
|
||||
#define D_ON "on"
|
||||
|
|
|
@ -21,8 +21,11 @@
|
|||
* 21-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeiung.de>)
|
||||
* 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.
|
||||
*
|
||||
* 30-Mar-1999 (Eric Kohl <ekohl@abo.rhein-zeiung.de>)
|
||||
* Added quiet ("/Q"), wipe ("/W") and zap ("/Z") option.
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -33,7 +36,6 @@
|
|||
#include <tchar.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "cmd.h"
|
||||
|
||||
|
@ -44,13 +46,30 @@
|
|||
#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)
|
||||
{
|
||||
TCHAR inp[10];
|
||||
LPTSTR p;
|
||||
|
||||
ConOutPrintf ("All files in directory will be deleted!\n"
|
||||
"Are you sure (Y/N)? ");
|
||||
ConOutPrintf (_T("All files in directory will be deleted!\n"
|
||||
"Are you sure (Y/N)? "));
|
||||
ConInString (inp, 10);
|
||||
|
||||
_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)
|
||||
{
|
||||
LPTSTR *arg = NULL;
|
||||
INT args;
|
||||
INT i;
|
||||
INT nEvalArgs = 0; /* nunber of evaluated arguments */
|
||||
BOOL bNothing = FALSE;
|
||||
BOOL bQuiet = FALSE;
|
||||
BOOL bPrompt = FALSE;
|
||||
INT nEvalArgs = 0; /* nunber of evaluated arguments */
|
||||
DWORD dwFlags = 0;
|
||||
DWORD dwFiles = 0;
|
||||
|
||||
HANDLE hFile;
|
||||
WIN32_FIND_DATA f;
|
||||
// DWORD dwAttributes;
|
||||
|
||||
|
||||
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"
|
||||
"\n"
|
||||
"DEL [/N /P /Q] file ...\n"
|
||||
"DELETE [/N /P /Q] file ...\n"
|
||||
"ERASE [/N /P /Q] file ...\n"
|
||||
"DEL [/N /P /T /Q /W /Z] file ...\n"
|
||||
"DELETE [/N /P /T /Q /W /Z] file ...\n"
|
||||
"ERASE [/N /P /T /Q /W /Z] file ...\n"
|
||||
"\n"
|
||||
" file Specifies the file(s) to delete.\n"
|
||||
"\n"
|
||||
" /N Nothing.\n"
|
||||
" /P Prompts for confirmation before deleting each file.\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;
|
||||
|
@ -160,15 +182,31 @@ INT cmd_del (LPTSTR cmd, LPTSTR param)
|
|||
switch (_totupper (arg[i][1]))
|
||||
{
|
||||
case _T('N'):
|
||||
bNothing = TRUE;
|
||||
dwFlags |= DEL_NOTHING;
|
||||
break;
|
||||
|
||||
case _T('P'):
|
||||
bPrompt = TRUE;
|
||||
dwFlags |= DEL_PROMPT;
|
||||
break;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -200,14 +238,14 @@ INT cmd_del (LPTSTR cmd, LPTSTR param)
|
|||
if (*arg[i] != _T('/'))
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
ConErrPrintf ("File: %s\n", arg[i]);
|
||||
ConErrPrintf (_T("File: %s\n"), arg[i]);
|
||||
#endif
|
||||
|
||||
if (_tcschr (arg[i], _T('*')) || _tcschr (arg[i], _T('?')))
|
||||
{
|
||||
/* wildcards in filespec */
|
||||
#ifdef _DEBUG
|
||||
ConErrPrintf ("Wildcards!\n\n");
|
||||
ConErrPrintf (_T("Wildcards!\n\n"));
|
||||
#endif
|
||||
|
||||
hFile = FindFirstFile (arg[i], &f);
|
||||
|
@ -220,18 +258,46 @@ INT cmd_del (LPTSTR cmd, LPTSTR param)
|
|||
|
||||
do
|
||||
{
|
||||
/* ignore "." and ".." */
|
||||
if (!_tcscmp (f.cFileName, _T(".")) ||
|
||||
!_tcscmp (f.cFileName, _T("..")))
|
||||
continue;
|
||||
|
||||
#ifdef _DEBUG
|
||||
ConErrPrintf ("Delete file: %s\n", f.cFileName);
|
||||
#endif
|
||||
if (!(dwFlags & DEL_QUIET) && !(dwFlags & DEL_TOTAL))
|
||||
ConErrPrintf (_T("Deleting: %s\n"), f.cFileName);
|
||||
|
||||
if (!bNothing)
|
||||
/* delete the file */
|
||||
if (!(dwFlags & DEL_NOTHING))
|
||||
{
|
||||
if (!DeleteFile (f.cFileName))
|
||||
ErrorMessage (GetLastError(), _T(""));
|
||||
if (RemoveFile (f.cFileName, dwFlags))
|
||||
{
|
||||
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
|
||||
{
|
||||
/* no wildcards in filespec */
|
||||
|
||||
#ifdef _DEBUG
|
||||
ConErrPrintf ("No Wildcards!\n");
|
||||
ConErrPrintf ("Delete file: %s\n", arg[i]);
|
||||
ConErrPrintf (_T("No Wildcards!\n"));
|
||||
#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]))
|
||||
ErrorMessage (GetLastError(), _T(""));
|
||||
if (RemoveFile (arg[i], dwFlags))
|
||||
{
|
||||
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);
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -237,7 +237,7 @@ DirReadParam (LPTSTR line, LPTSTR *param, LPDWORD lpFlags)
|
|||
{
|
||||
if (_totupper (*line) == _T('S'))
|
||||
*lpFlags |= DIR_RECURSE;
|
||||
else if (_toupper (*line) == _T('P'))
|
||||
else if (_totupper (*line) == _T('P'))
|
||||
*lpFlags |= DIR_PAGE;
|
||||
else if (_totupper (*line) == _T('W'))
|
||||
*lpFlags |= DIR_WIDE;
|
||||
|
@ -811,8 +811,8 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
|
|||
count = 0;
|
||||
}
|
||||
|
||||
uliSize.u.LowPart += file.nFileSizeLow;
|
||||
uliSize.u.HighPart += file.nFileSizeHigh;
|
||||
uliSize.u.LowPart = file.nFileSizeLow;
|
||||
uliSize.u.HighPart = file.nFileSizeHigh;
|
||||
bytecount.QuadPart += uliSize.QuadPart;
|
||||
}
|
||||
else if (dwFlags & DIR_BARE)
|
||||
|
@ -842,8 +842,8 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
|
|||
if (IncLine (pLine, dwFlags))
|
||||
return 1;
|
||||
|
||||
uliSize.u.LowPart += file.nFileSizeLow;
|
||||
uliSize.u.HighPart += file.nFileSizeHigh;
|
||||
uliSize.u.LowPart = file.nFileSizeLow;
|
||||
uliSize.u.HighPart = file.nFileSizeHigh;
|
||||
bytecount.QuadPart += uliSize.QuadPart;
|
||||
}
|
||||
else
|
||||
|
@ -867,8 +867,8 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
|
|||
{
|
||||
ULARGE_INTEGER uliSize;
|
||||
|
||||
uliSize.u.LowPart = file.nFileSizeLow;
|
||||
uliSize.u.HighPart = file.nFileSizeHigh;
|
||||
uliSize.u.LowPart = file.nFileSizeLow;
|
||||
uliSize.u.HighPart = file.nFileSizeHigh;
|
||||
|
||||
ConvertULargeInteger (uliSize, buffer, sizeof(buffer));
|
||||
ConOutPrintf (_T(" %20s"), buffer);
|
||||
|
@ -919,8 +919,8 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
|
|||
{
|
||||
ULARGE_INTEGER uliSize;
|
||||
|
||||
uliSize.u.LowPart = file.nFileSizeLow;
|
||||
uliSize.u.HighPart = file.nFileSizeHigh;
|
||||
uliSize.u.LowPart = file.nFileSizeLow;
|
||||
uliSize.u.HighPart = file.nFileSizeHigh;
|
||||
|
||||
ConvertULargeInteger (uliSize, buffer, sizeof(buffer));
|
||||
ConOutPrintf (_T(" %10s "), buffer);
|
||||
|
|
|
@ -342,4 +342,12 @@ o ATTRIB and DEL can handle multiple filenames now.
|
|||
o Fixed handling of environment variables.
|
||||
o Added CHCP command.
|
||||
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.
|
||||
|
|
|
@ -8,10 +8,12 @@
|
|||
# target: executable (not tested/experimental)
|
||||
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\
|
||||
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\
|
||||
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\
|
||||
verify.o vol.o where.o
|
||||
OBJECTS = ../common/crt0.o cmd.o attrib.o alias.o batch.o beep.o call.o \
|
||||
chcp.o cls.o cmdinput.o cmdtable.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 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
|
||||
|
||||
|
|
|
@ -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.
|
||||
It was converted from the FreeDOS COMMAND.COM.
|
||||
|
@ -7,7 +7,7 @@ It was converted from the FreeDOS COMMAND.COM.
|
|||
|
||||
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,
|
||||
they might destroy your files or the file system!!!
|
||||
|
||||
|
|
|
@ -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
|
|
@ -2,8 +2,6 @@ Things to do
|
|||
~~~~~~~~~~~~
|
||||
Fix bugs :)
|
||||
|
||||
Rewrite DIR command (Unicode aware / new structure).
|
||||
|
||||
Optimize the code! For size and speed. There are numerous places
|
||||
where the code is hardly optimal for either.
|
||||
|
||||
|
|
Loading…
Reference in a new issue