mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 18:11:57 +00:00
Fixed current directory handling
Added new prompt functions Fixed dangling pointer bug in copy command svn path=/trunk/; revision=874
This commit is contained in:
parent
43d5d0b2f0
commit
8bbcdc3d4a
9 changed files with 350 additions and 159 deletions
|
@ -1,4 +1,4 @@
|
|||
/* $Id: cmd.c,v 1.16 1999/12/07 18:17:17 paolopan Exp $
|
||||
/* $Id: cmd.c,v 1.17 1999/12/15 00:50:41 ekohl Exp $
|
||||
*
|
||||
* CMD.C - command-line interface.
|
||||
*
|
||||
|
@ -107,6 +107,9 @@
|
|||
*
|
||||
* 22-Oct-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||
* Added break handler.
|
||||
*
|
||||
* 15-Dec-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||
* Fixed current directory
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
@ -166,13 +169,44 @@ Execute (LPTSTR first, LPTSTR rest)
|
|||
TCHAR szFullName[MAX_PATH];
|
||||
DWORD dwExitCode = 0;
|
||||
|
||||
#ifdef _DEBUG
|
||||
DebugPrintf ("Execute: \'%s\' \'%s\'\n", first, rest);
|
||||
#endif
|
||||
|
||||
/* check for a drive change */
|
||||
if (!_tcscmp (first + 1, _T(":")) && _istalpha (*first))
|
||||
if ((_istalpha (first[0])) && (!_tcscmp (first + 1, _T(":"))))
|
||||
{
|
||||
TCHAR szPath[MAX_PATH];
|
||||
TCHAR szVar[5];
|
||||
|
||||
_tcscpy (szPath, _T("A:"));
|
||||
szPath[0] = _totupper (*first);
|
||||
#ifdef _DEBUG
|
||||
DebugPrintf ("Drive change to drive %s\n", first);
|
||||
#endif
|
||||
/* save curent directory in environment variable */
|
||||
GetCurrentDirectory (MAX_PATH, szPath);
|
||||
|
||||
_tcscpy (szVar, _T("=A:"));
|
||||
szVar[1] = _totupper (szPath[0]);
|
||||
|
||||
SetEnvironmentVariable (szVar, szPath);
|
||||
|
||||
|
||||
/* check for current directory of new drive */
|
||||
_tcscpy (szVar, _T("=A:"));
|
||||
szVar[1] = _totupper (*first);
|
||||
|
||||
if (GetEnvironmentVariable (szVar, szPath, MAX_PATH) == 0)
|
||||
{
|
||||
/* no environment variable found */
|
||||
_tcscpy (szPath, _T("A:\\"));
|
||||
szPath[0] = _totupper (*first);
|
||||
}
|
||||
|
||||
#ifdef _DEBUG
|
||||
DebugPrintf ("Drive change to drive %s\n", szPath);
|
||||
#endif
|
||||
|
||||
/* set new current directory */
|
||||
SetCurrentDirectory (szPath);
|
||||
GetCurrentDirectory (MAX_PATH, szPath);
|
||||
if (szPath[0] != (TCHAR)_totupper (*first))
|
||||
|
@ -289,6 +323,10 @@ DoCommand (LPTSTR line)
|
|||
INT cl;
|
||||
LPCOMMAND cmdptr;
|
||||
|
||||
#ifdef _DEBUG
|
||||
DebugPrintf ("DoCommand: (\'%s\')\n", line);
|
||||
#endif /* DEBUG */
|
||||
|
||||
/* Skip over initial white space */
|
||||
while (isspace (*rest))
|
||||
rest++;
|
||||
|
@ -383,7 +421,7 @@ VOID ParseCommandLine (LPTSTR cmd)
|
|||
s = &cmdline[0];
|
||||
|
||||
#ifdef _DEBUG
|
||||
DebugPrintf ("ParseCommandLine: (\'%s\')]\n", s);
|
||||
DebugPrintf ("ParseCommandLine: (\'%s\')\n", s);
|
||||
#endif /* DEBUG */
|
||||
|
||||
#ifdef FEATURE_ALIASES
|
||||
|
@ -822,6 +860,23 @@ BOOL BreakHandler (DWORD dwCtrlType)
|
|||
}
|
||||
|
||||
|
||||
VOID AddBreakHandler (VOID)
|
||||
{
|
||||
#ifndef __REACTOS__
|
||||
SetConsoleCtrlHandler ((PHANDLER_ROUTINE)&BreakHandler,
|
||||
TRUE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
VOID RemoveBreakHandler (VOID)
|
||||
{
|
||||
#ifndef __REACTOS__
|
||||
SetConsoleCtrlHandler (NULL, FALSE);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* show commands and options that are available.
|
||||
*
|
||||
|
@ -1036,10 +1091,7 @@ Initialize (int argc, char *argv[])
|
|||
#endif
|
||||
|
||||
/* add ctrl break handler */
|
||||
#ifndef __REACTOS__
|
||||
SetConsoleCtrlHandler ((PHANDLER_ROUTINE)&BreakHandler,
|
||||
TRUE);
|
||||
#endif
|
||||
AddBreakHandler ();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1092,9 +1144,7 @@ static VOID Cleanup (int argc, char *argv[])
|
|||
|
||||
|
||||
/* remove ctrl break handler */
|
||||
#ifndef __REACTOS__
|
||||
SetConsoleCtrlHandler (NULL, FALSE);
|
||||
#endif
|
||||
RemoveBreakHandler ();
|
||||
}
|
||||
|
||||
|
||||
|
@ -1126,3 +1176,5 @@ int main (int argc, char *argv[])
|
|||
|
||||
return nExitCode;
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/*
|
||||
/* $Id: cmd.h,v 1.17 1999/12/15 00:50:41 ekohl Exp $
|
||||
*
|
||||
* CMD.H - header file for the modules in CMD.EXE
|
||||
*
|
||||
*
|
||||
|
@ -57,7 +58,7 @@
|
|||
#define ERROR_E2BIG "ERROR: Argument list too long"
|
||||
#define ERROR_EINVAL "ERROR: Invalid argument"
|
||||
|
||||
#define SHELLINFO "ReactOS Command Line Interface"
|
||||
#define SHELLINFO "ReactOS Command Line Interpreter"
|
||||
|
||||
|
||||
#define D_ON "on"
|
||||
|
@ -65,7 +66,7 @@
|
|||
|
||||
|
||||
|
||||
/* Prototypes for CMD.C */
|
||||
/* global variables */
|
||||
extern HANDLE hOut;
|
||||
extern HANDLE hIn;
|
||||
extern WORD wColor;
|
||||
|
@ -78,9 +79,6 @@ extern SHORT maxx;
|
|||
extern SHORT maxy;
|
||||
extern OSVERSIONINFO osvi;
|
||||
|
||||
void command(char *);
|
||||
VOID ParseCommandLine (LPTSTR);
|
||||
int c_brk(void);
|
||||
|
||||
|
||||
/* Prototypes for ALIAS.C */
|
||||
|
@ -114,6 +112,13 @@ INT CommandChoice (LPTSTR, LPTSTR);
|
|||
INT cmd_cls (LPTSTR, LPTSTR);
|
||||
|
||||
|
||||
/* Prototypes for CMD.C */
|
||||
//void command(char *);
|
||||
VOID ParseCommandLine (LPTSTR);
|
||||
VOID AddBreakHandler (VOID);
|
||||
VOID RemoveBreakHandler (VOID);
|
||||
|
||||
|
||||
/* Prototypes for CMDINPUT.C */
|
||||
VOID ReadCommand (LPTSTR, INT);
|
||||
|
||||
|
@ -144,6 +149,8 @@ VOID DebugPrintf (LPTSTR, ...);
|
|||
#endif /* _DEBUG */
|
||||
|
||||
VOID ConInDummy (VOID);
|
||||
VOID ConInDisable (VOID);
|
||||
VOID ConInEnable (VOID);
|
||||
VOID ConInFlush (VOID);
|
||||
VOID ConInKey (PINPUT_RECORD);
|
||||
|
||||
|
@ -183,8 +190,7 @@ INT CommandDelay (LPTSTR, LPTSTR);
|
|||
|
||||
|
||||
/* Prototypes for DIR.C */
|
||||
//int incline(int *line, unsigned flags);
|
||||
INT cmd_dir (LPTSTR, LPTSTR);
|
||||
INT CommandDir (LPTSTR, LPTSTR);
|
||||
|
||||
|
||||
/* Prototypes for DIRSTACK.C */
|
||||
|
@ -301,6 +307,15 @@ BOOL FileGetString (HANDLE, LPTSTR, INT);
|
|||
HWND GetConsoleWindow(VOID);
|
||||
#endif
|
||||
|
||||
#define PROMPT_NO 0
|
||||
#define PROMPT_YES 1
|
||||
#define PROMPT_ALL 2
|
||||
#define PROMPT_BREAK 3
|
||||
|
||||
INT PagePrompt (VOID);
|
||||
INT FilePromptYN (LPTSTR, ...);
|
||||
INT FilePromptYNA (LPTSTR, ...);
|
||||
|
||||
|
||||
/* Prototypes for MOVE.C */
|
||||
INT cmd_move (LPTSTR, LPTSTR);
|
||||
|
|
|
@ -89,7 +89,7 @@ COMMAND cmds[] =
|
|||
#endif
|
||||
|
||||
#ifdef INCLUDE_CMD_DIR
|
||||
{_T("dir"), CMD_SPECIAL, cmd_dir},
|
||||
{_T("dir"), CMD_SPECIAL, CommandDir},
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_DIRECTORY_STACK
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: console.c,v 1.12 1999/10/23 18:17:37 ekohl Exp $
|
||||
/* $Id: console.c,v 1.13 1999/12/15 00:50:41 ekohl Exp $
|
||||
*
|
||||
* CONSOLE.C - console input/output functions.
|
||||
*
|
||||
|
@ -34,7 +34,7 @@ VOID DebugPrintf (LPTSTR szFormat, ...)
|
|||
_vstprintf (szOut, szFormat, arg_ptr);
|
||||
va_end (arg_ptr);
|
||||
|
||||
WriteFile (GetStdHandle (STD_ERROR_HANDLE),
|
||||
WriteFile (GetStdHandle (STD_ERROR_HANDLE),
|
||||
szOut,
|
||||
_tcslen(szOut) * sizeof(TCHAR),
|
||||
&dwWritten,
|
||||
|
@ -46,6 +46,28 @@ VOID DebugPrintf (LPTSTR szFormat, ...)
|
|||
#endif /* _DEBUG */
|
||||
|
||||
|
||||
VOID ConInDisable (VOID)
|
||||
{
|
||||
HANDLE hInput = GetStdHandle (STD_INPUT_HANDLE);
|
||||
DWORD dwMode;
|
||||
|
||||
GetConsoleMode (hInput, &dwMode);
|
||||
dwMode &= ~ENABLE_PROCESSED_INPUT;
|
||||
SetConsoleMode (hInput, dwMode);
|
||||
}
|
||||
|
||||
|
||||
VOID ConInEnable (VOID)
|
||||
{
|
||||
HANDLE hInput = GetStdHandle (STD_INPUT_HANDLE);
|
||||
DWORD dwMode;
|
||||
|
||||
GetConsoleMode (hInput, &dwMode);
|
||||
dwMode |= ENABLE_PROCESSED_INPUT;
|
||||
SetConsoleMode (hInput, dwMode);
|
||||
}
|
||||
|
||||
|
||||
VOID ConInDummy (VOID)
|
||||
{
|
||||
HANDLE hInput = GetStdHandle (STD_INPUT_HANDLE);
|
||||
|
|
|
@ -611,9 +611,9 @@ INT cmd_copy (LPTSTR first, LPTSTR rest)
|
|||
int files;
|
||||
int copied;
|
||||
|
||||
LPFILES sources;
|
||||
LPFILES sources = NULL;
|
||||
LPFILES start = NULL;
|
||||
FILES dest;
|
||||
LPFILES start;
|
||||
BOOL bMultiple;
|
||||
BOOL bWildcards;
|
||||
BOOL bDestFound;
|
||||
|
@ -738,7 +738,8 @@ INT cmd_copy (LPTSTR first, LPTSTR rest)
|
|||
copied = setup_copy (sources->next, p, bMultiple, drive_d, dir_d, file_d, ext_d, &append, &dwFlags) + 1;
|
||||
}
|
||||
|
||||
DeleteFileList (start);
|
||||
// DeleteFileList (start);
|
||||
DeleteFileList (sources);
|
||||
freep (p);
|
||||
ConOutPrintf (_T(" %d file(s) copied\n"), copied);
|
||||
|
||||
|
|
|
@ -45,12 +45,6 @@
|
|||
#include "batch.h"
|
||||
|
||||
|
||||
#define PROMPT_NO 0
|
||||
#define PROMPT_YES 1
|
||||
#define PROMPT_ALL 2
|
||||
#define PROMPT_BREAK 3
|
||||
|
||||
|
||||
enum
|
||||
{
|
||||
DEL_ATTRIBUTES = 0x001, /* /A : not implemented */
|
||||
|
@ -68,64 +62,6 @@ enum
|
|||
|
||||
|
||||
|
||||
static BOOL ConfirmDeleteAll (VOID)
|
||||
{
|
||||
TCHAR inp[10];
|
||||
LPTSTR p;
|
||||
|
||||
ConOutPrintf (_T("All files in directory will be deleted!\n"
|
||||
"Are you sure (Y/N)? "));
|
||||
ConInString (inp, 10);
|
||||
|
||||
_tcsupr (inp);
|
||||
for (p = inp; _istspace (*p); p++)
|
||||
;
|
||||
|
||||
if (*p == _T('Y'))
|
||||
return PROMPT_YES;
|
||||
else if (*p == _T('N'))
|
||||
return PROMPT_NO;
|
||||
|
||||
#if 0
|
||||
if (*p == _T('A'))
|
||||
return PROMPT_ALL;
|
||||
else if (*p == _T('\03'))
|
||||
return PROMPT_BREAK;
|
||||
#endif
|
||||
|
||||
return PROMPT_NO;
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
static INT Prompt (LPTSTR str)
|
||||
{
|
||||
TCHAR inp[10];
|
||||
LPTSTR p;
|
||||
|
||||
ConOutPrintf (_T("Delete %s (Yes/No)? "), str);
|
||||
ConInString (inp, 10);
|
||||
|
||||
_tcsupr (inp);
|
||||
for (p = inp; _istspace (*p); p++)
|
||||
;
|
||||
|
||||
if (*p == _T('Y'))
|
||||
return PROMPT_YES;
|
||||
else if (*p == _T('N'))
|
||||
return PROMPT_NO;
|
||||
|
||||
#if 0
|
||||
if (*p == _T('A'))
|
||||
return PROMPT_ALL;
|
||||
else if (*p == _T('\03'))
|
||||
return PROMPT_BREAK;
|
||||
#endif
|
||||
|
||||
return PROMPT_NO;
|
||||
}
|
||||
#endif
|
||||
|
||||
static BOOL
|
||||
RemoveFile (LPTSTR lpFileName, DWORD dwFlags)
|
||||
{
|
||||
|
@ -239,11 +175,15 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param)
|
|||
for (i = 0; i < args; i++)
|
||||
{
|
||||
if (!_tcscmp (arg[i], _T("*")) ||
|
||||
!_tcscmp (arg[i], _T("*.*")))
|
||||
!_tcscmp (arg[i], _T("*.*")))
|
||||
{
|
||||
if (!ConfirmDeleteAll ())
|
||||
break;
|
||||
INT res;
|
||||
|
||||
res = FilePromptYN (_T("All files in directory will be deleted!\n"
|
||||
"Are you sure (Y/N)?"));
|
||||
if ((res == PROMPT_NO) ||
|
||||
(res == PROMPT_BREAK))
|
||||
break;
|
||||
}
|
||||
|
||||
if (*arg[i] != _T('/'))
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
/*
|
||||
/* $Id: dir.c,v 1.9 1999/12/15 00:50:41 ekohl Exp $
|
||||
*
|
||||
* DIR.C - dir internal command.
|
||||
*
|
||||
*
|
||||
|
@ -315,7 +316,7 @@ DirReadParam (LPTSTR line, LPTSTR *param, LPDWORD lpFlags)
|
|||
static VOID
|
||||
ExtendFilespec (LPTSTR file)
|
||||
{
|
||||
INT len = 0;
|
||||
INT len = 0;
|
||||
|
||||
if (!file)
|
||||
return;
|
||||
|
@ -341,13 +342,13 @@ ExtendFilespec (LPTSTR file)
|
|||
return;
|
||||
}
|
||||
|
||||
/* if last character is '.' add '*' */
|
||||
len = _tcslen (file);
|
||||
if (file[len - 1] == _T('.'))
|
||||
{
|
||||
_tcscat (file, _T("*"));
|
||||
return;
|
||||
}
|
||||
/* if last character is '.' add '*' */
|
||||
len = _tcslen (file);
|
||||
if (file[len - 1] == _T('.'))
|
||||
{
|
||||
_tcscat (file, _T("*"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -462,40 +463,26 @@ DirParsePathspec (LPTSTR szPathspec, LPTSTR szPath, LPTSTR szFilespec)
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* pause
|
||||
*
|
||||
* pause until a key is pressed
|
||||
*/
|
||||
static INT
|
||||
Pause (VOID)
|
||||
{
|
||||
cmd_pause ("", "");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* incline
|
||||
*
|
||||
* increment our line if paginating, display message at end of screen
|
||||
*/
|
||||
static INT
|
||||
static BOOL
|
||||
IncLine (LPINT pLine, DWORD dwFlags)
|
||||
{
|
||||
if (!(dwFlags & DIR_PAGE))
|
||||
return 0;
|
||||
return FALSE;
|
||||
|
||||
(*pLine)++;
|
||||
|
||||
if (*pLine >= (int)maxy - 2)
|
||||
{
|
||||
*pLine = 0;
|
||||
return Pause ();
|
||||
return (PagePrompt () == PROMPT_BREAK);
|
||||
}
|
||||
|
||||
return 0;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -517,7 +504,7 @@ PrintDirectoryHeader (LPTSTR szPath, LPINT pLine, DWORD dwFlags)
|
|||
/* get the media ID of the drive */
|
||||
szRootName[0] = szPath[0];
|
||||
if (!GetVolumeInformation (szRootName, szVolName, 80, &dwSerialNr,
|
||||
NULL, NULL, NULL, 0))
|
||||
NULL, NULL, NULL, 0))
|
||||
{
|
||||
error_invalid_drive();
|
||||
return FALSE;
|
||||
|
@ -536,7 +523,8 @@ PrintDirectoryHeader (LPTSTR szPath, LPINT pLine, DWORD dwFlags)
|
|||
|
||||
/* print the volume serial number if the return was successful */
|
||||
ConOutPrintf (_T(" Volume Serial Number is %04X-%04X\n"),
|
||||
HIWORD(dwSerialNr), LOWORD(dwSerialNr));
|
||||
HIWORD(dwSerialNr),
|
||||
LOWORD(dwSerialNr));
|
||||
if (IncLine (pLine, dwFlags))
|
||||
return FALSE;
|
||||
|
||||
|
@ -673,11 +661,11 @@ PrintSummary (LPTSTR szPath, ULONG ulFiles, ULONG ulDirs, ULARGE_INTEGER bytes,
|
|||
/* print number of files and bytes */
|
||||
ConvertULong (ulFiles, buffer, sizeof(buffer));
|
||||
ConOutPrintf (_T(" %6s File%c"),
|
||||
buffer, ulFiles == 1 ? _T(' ') : _T('s'));
|
||||
buffer, ulFiles == 1 ? _T(' ') : _T('s'));
|
||||
|
||||
ConvertULargeInteger (bytes, buffer, sizeof(buffer));
|
||||
ConOutPrintf (_T(" %15s byte%c\n"),
|
||||
buffer, bytes.QuadPart == 1 ? _T(' ') : _T('s'));
|
||||
buffer, bytes.QuadPart == 1 ? _T(' ') : _T('s'));
|
||||
|
||||
if (IncLine (pLine, dwFlags))
|
||||
return 1;
|
||||
|
@ -685,7 +673,7 @@ PrintSummary (LPTSTR szPath, ULONG ulFiles, ULONG ulDirs, ULARGE_INTEGER bytes,
|
|||
/* print number of dirs and bytes free */
|
||||
ConvertULong (ulDirs, buffer, sizeof(buffer));
|
||||
ConOutPrintf (_T(" %6s Dir%c"),
|
||||
buffer, ulDirs == 1 ? _T(' ') : _T('s'));
|
||||
buffer, ulDirs == 1 ? _T(' ') : _T('s'));
|
||||
|
||||
|
||||
if (!(dwFlags & DIR_RECURSE))
|
||||
|
@ -699,7 +687,7 @@ PrintSummary (LPTSTR szPath, ULONG ulFiles, ULONG ulDirs, ULARGE_INTEGER bytes,
|
|||
|
||||
szRoot[0] = szPath[0];
|
||||
GetDiskFreeSpace (szRoot, &dwSecPerCl, &dwBytPerSec, &dwFreeCl, &dwTotCl);
|
||||
uliFree.QuadPart = dwSecPerCl * dwBytPerSec * dwFreeCl;
|
||||
uliFree.QuadPart = dwSecPerCl * dwBytPerSec * dwFreeCl;
|
||||
ConvertULargeInteger (uliFree, buffer, sizeof(buffer));
|
||||
ConOutPrintf (_T(" %15s bytes free\n"), buffer);
|
||||
}
|
||||
|
@ -745,9 +733,10 @@ DirList (LPTSTR szPath, LPTSTR szFilespec, LPINT pLine, DWORD dwFlags)
|
|||
*/
|
||||
if ((dwFlags & DIR_RECURSE) == 0)
|
||||
{
|
||||
error_file_not_found ();
|
||||
IncLine (pLine, dwFlags);
|
||||
FindClose (hFile);
|
||||
error_file_not_found ();
|
||||
if (IncLine (pLine, dwFlags))
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
FindClose (hFile);
|
||||
|
@ -1085,7 +1074,7 @@ DirRecurse (LPTSTR szPath, LPTSTR szSpec, LPINT pLine, DWORD dwFlags)
|
|||
*
|
||||
* internal dir command
|
||||
*/
|
||||
INT cmd_dir (LPTSTR first, LPTSTR rest)
|
||||
INT CommandDir (LPTSTR first, LPTSTR rest)
|
||||
{
|
||||
DWORD dwFlags = DIR_NEW | DIR_FOUR;
|
||||
TCHAR dircmd[256];
|
||||
|
@ -1120,7 +1109,8 @@ INT cmd_dir (LPTSTR first, LPTSTR rest)
|
|||
|
||||
if (dwFlags & DIR_RECURSE)
|
||||
{
|
||||
IncLine (&nLine, dwFlags);
|
||||
if (IncLine (&nLine, dwFlags))
|
||||
return 0;
|
||||
if (DirRecurse (szPath, szFilespec, &nLine, dwFlags))
|
||||
return 1;
|
||||
return 0;
|
||||
|
@ -1137,3 +1127,5 @@ INT cmd_dir (LPTSTR first, LPTSTR rest)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* EOF */
|
|
@ -24,15 +24,20 @@
|
|||
*
|
||||
* 28-Jan-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||
* FileGetString() seems to be working now.
|
||||
*
|
||||
* 06-Nov-1999 (Eric Kohl <ekohl@abo.rhein-zeitung.de>)
|
||||
* Added PagePrompt() and FilePrompt().
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <tchar.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
//#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <tchar.h>
|
||||
|
||||
#include "cmd.h"
|
||||
|
||||
|
@ -329,4 +334,169 @@ HWND GetConsoleWindow (VOID)
|
|||
}
|
||||
#endif
|
||||
|
||||
/* EOF */
|
||||
|
||||
INT PagePrompt (VOID)
|
||||
{
|
||||
INPUT_RECORD ir;
|
||||
|
||||
ConOutPrintf ("Press a key to continue...\n");
|
||||
|
||||
RemoveBreakHandler ();
|
||||
ConInDisable ();
|
||||
|
||||
do
|
||||
{
|
||||
ConInKey (&ir);
|
||||
}
|
||||
while ((ir.Event.KeyEvent.wVirtualKeyCode == VK_SHIFT) ||
|
||||
(ir.Event.KeyEvent.wVirtualKeyCode == VK_MENU) ||
|
||||
(ir.Event.KeyEvent.wVirtualKeyCode == VK_CONTROL));
|
||||
|
||||
AddBreakHandler ();
|
||||
ConInEnable ();
|
||||
|
||||
if ((ir.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE) ||
|
||||
((ir.Event.KeyEvent.wVirtualKeyCode == 'C') &&
|
||||
(ir.Event.KeyEvent.dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))))
|
||||
return PROMPT_BREAK;
|
||||
|
||||
return PROMPT_YES;
|
||||
}
|
||||
|
||||
|
||||
INT FilePromptYN (LPTSTR szFormat, ...)
|
||||
{
|
||||
TCHAR szOut[512];
|
||||
va_list arg_ptr;
|
||||
// TCHAR cKey = 0;
|
||||
// LPTSTR szKeys = _T("yna");
|
||||
|
||||
TCHAR szIn[10];
|
||||
LPTSTR p;
|
||||
|
||||
va_start (arg_ptr, szFormat);
|
||||
_vstprintf (szOut, szFormat, arg_ptr);
|
||||
va_end (arg_ptr);
|
||||
|
||||
ConOutPrintf (szFormat);
|
||||
|
||||
/* preliminary fix */
|
||||
ConInString (szIn, 10);
|
||||
ConOutPrintf (_T("\n"));
|
||||
|
||||
_tcsupr (szIn);
|
||||
for (p = szIn; _istspace (*p); p++)
|
||||
;
|
||||
|
||||
if (*p == _T('Y'))
|
||||
return PROMPT_YES;
|
||||
else if (*p == _T('N'))
|
||||
return PROMPT_NO;
|
||||
#if 0
|
||||
else if (*p == _T('\03'))
|
||||
return PROMPT_BREAK;
|
||||
#endif
|
||||
|
||||
return PROMPT_NO;
|
||||
|
||||
|
||||
/* unfinished sollution */
|
||||
#if 0
|
||||
RemoveBreakHandler ();
|
||||
ConInDisable ();
|
||||
|
||||
do
|
||||
{
|
||||
ConInKey (&ir);
|
||||
cKey = _totlower (ir.Event.KeyEvent.uChar.AsciiChar);
|
||||
if (_tcschr (szKeys, cKey[0]) == NULL)
|
||||
cKey = 0;
|
||||
|
||||
|
||||
}
|
||||
while ((ir.Event.KeyEvent.wVirtualKeyCode == VK_SHIFT) ||
|
||||
(ir.Event.KeyEvent.wVirtualKeyCode == VK_MENU) ||
|
||||
(ir.Event.KeyEvent.wVirtualKeyCode == VK_CONTROL));
|
||||
|
||||
AddBreakHandler ();
|
||||
ConInEnable ();
|
||||
|
||||
if ((ir.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE) ||
|
||||
((ir.Event.KeyEvent.wVirtualKeyCode == 'C') &&
|
||||
(ir.Event.KeyEvent.dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))))
|
||||
return PROMPT_BREAK;
|
||||
|
||||
return PROMPT_YES;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
INT FilePromptYNA (LPTSTR szFormat, ...)
|
||||
{
|
||||
TCHAR szOut[512];
|
||||
va_list arg_ptr;
|
||||
// TCHAR cKey = 0;
|
||||
// LPTSTR szKeys = _T("yna");
|
||||
|
||||
TCHAR szIn[10];
|
||||
LPTSTR p;
|
||||
|
||||
va_start (arg_ptr, szFormat);
|
||||
_vstprintf (szOut, szFormat, arg_ptr);
|
||||
va_end (arg_ptr);
|
||||
|
||||
ConOutPrintf (szFormat);
|
||||
|
||||
/* preliminary fix */
|
||||
ConInString (szIn, 10);
|
||||
ConOutPrintf (_T("\n"));
|
||||
|
||||
_tcsupr (szIn);
|
||||
for (p = szIn; _istspace (*p); p++)
|
||||
;
|
||||
|
||||
if (*p == _T('Y'))
|
||||
return PROMPT_YES;
|
||||
else if (*p == _T('N'))
|
||||
return PROMPT_NO;
|
||||
if (*p == _T('A'))
|
||||
return PROMPT_ALL;
|
||||
#if 0
|
||||
else if (*p == _T('\03'))
|
||||
return PROMPT_BREAK;
|
||||
#endif
|
||||
|
||||
return PROMPT_NO;
|
||||
|
||||
|
||||
/* unfinished sollution */
|
||||
#if 0
|
||||
RemoveBreakHandler ();
|
||||
ConInDisable ();
|
||||
|
||||
do
|
||||
{
|
||||
ConInKey (&ir);
|
||||
cKey = _totlower (ir.Event.KeyEvent.uChar.AsciiChar);
|
||||
if (_tcschr (szKeys, cKey[0]) == NULL)
|
||||
cKey = 0;
|
||||
|
||||
|
||||
}
|
||||
while ((ir.Event.KeyEvent.wVirtualKeyCode == VK_SHIFT) ||
|
||||
(ir.Event.KeyEvent.wVirtualKeyCode == VK_MENU) ||
|
||||
(ir.Event.KeyEvent.wVirtualKeyCode == VK_CONTROL));
|
||||
|
||||
AddBreakHandler ();
|
||||
ConInEnable ();
|
||||
|
||||
if ((ir.Event.KeyEvent.wVirtualKeyCode == VK_ESCAPE) ||
|
||||
((ir.Event.KeyEvent.wVirtualKeyCode == 'C') &&
|
||||
(ir.Event.KeyEvent.dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))))
|
||||
return PROMPT_BREAK;
|
||||
|
||||
return PROMPT_YES;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* EOF */
|
||||
|
|
|
@ -79,33 +79,33 @@ INT cmd_move (LPTSTR cmd, LPTSTR param)
|
|||
{
|
||||
#if 0
|
||||
ConOutPuts (_T("Moves files and renames files and directories.\n\n"
|
||||
"To move one or more files:\n"
|
||||
"MOVE [/N][/Y|/-Y][drive:][path]filename1[,...] destination\n"
|
||||
"\n"
|
||||
"To rename a directory:\n"
|
||||
"MOVE [/N][/Y|/-Y][drive:][path]dirname1 dirname2\n"
|
||||
"\n"
|
||||
" [drive:][path]filename1 Specifies the location and name of the file\n"
|
||||
" or files you want to move.\n"
|
||||
" /N Nothing. Don everthing but move files or direcories.\n"
|
||||
" /Y\n"
|
||||
" /-Y\n"
|
||||
"..."));
|
||||
"To move one or more files:\n"
|
||||
"MOVE [/N][/Y|/-Y][drive:][path]filename1[,...] destination\n"
|
||||
"\n"
|
||||
"To rename a directory:\n"
|
||||
"MOVE [/N][/Y|/-Y][drive:][path]dirname1 dirname2\n"
|
||||
"\n"
|
||||
" [drive:][path]filename1 Specifies the location and name of the file\n"
|
||||
" or files you want to move.\n"
|
||||
" /N Nothing. Don everthing but move files or direcories.\n"
|
||||
" /Y\n"
|
||||
" /-Y\n"
|
||||
"..."));
|
||||
#else
|
||||
ConOutPuts (_T("Moves files and renames files and directories.\n\n"
|
||||
"To move one or more files:\n"
|
||||
"MOVE [/N][drive:][path]filename1[,...] destination\n"
|
||||
"\n"
|
||||
"To rename a directory:\n"
|
||||
"MOVE [/N][drive:][path]dirname1 dirname2\n"
|
||||
"\n"
|
||||
" [drive:][path]filename1 Specifies the location and name of the file\n"
|
||||
" or files you want to move.\n"
|
||||
" /N Nothing. Don everthing but move files or direcories.\n"
|
||||
"\n"
|
||||
"Current limitations:\n"
|
||||
" - You can't move a file or directory from one drive to another.\n"
|
||||
));
|
||||
"To move one or more files:\n"
|
||||
"MOVE [/N][drive:][path]filename1[,...] destination\n"
|
||||
"\n"
|
||||
"To rename a directory:\n"
|
||||
"MOVE [/N][drive:][path]dirname1 dirname2\n"
|
||||
"\n"
|
||||
" [drive:][path]filename1 Specifies the location and name of the file\n"
|
||||
" or files you want to move.\n"
|
||||
" /N Nothing. Don everthing but move files or direcories.\n"
|
||||
"\n"
|
||||
"Current limitations:\n"
|
||||
" - You can't move a file or directory from one drive to another.\n"
|
||||
));
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
@ -257,7 +257,6 @@ INT cmd_move (LPTSTR cmd, LPTSTR param)
|
|||
FindClose (hFile);
|
||||
}
|
||||
|
||||
|
||||
freep (arg);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue