Add some ctrl breaker checks into copy, del, and dir.

svn path=/trunk/; revision=19024
This commit is contained in:
Brandon Turner 2005-11-06 01:24:21 +00:00
parent 4c532d38d2
commit dee7dbd301
4 changed files with 24 additions and 6 deletions

View file

@ -643,6 +643,8 @@ DoCommand (LPTSTR line)
}
}
}
/* Just in case a CTRL+C slipped through a command */
bCtrlBreak = FALSE;
free(com);
}

View file

@ -51,7 +51,12 @@ enum
#define BUFF_SIZE 16384 /* 16k = max buffer size */
int copy (TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFlags, BOOL bTouch)
INT
copy (TCHAR source[MAX_PATH],
TCHAR dest[MAX_PATH],
INT append,
DWORD lpdwFlags,
BOOL bTouch)
{
TCHAR szMsg[RC_STRING_MAX_SIZE];
FILETIME srctime,NewFileTime;
@ -68,6 +73,9 @@ int copy (TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFl
TCHAR * FileName;
SYSTEMTIME CurrentTime;
/* Check Breaker */
if(CheckCtrlBreak(BREAK_INPUT))
return 0;
#ifdef _DEBUG
DebugPrintf (_T("checking mode\n"));
@ -235,6 +243,7 @@ int copy (TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFl
do
{
ReadFile (hFileSrc, buffer, BUFF_SIZE, &dwRead, NULL);
if (lpdwFlags & COPY_ASCII)
{
@ -254,14 +263,14 @@ int copy (TCHAR source[MAX_PATH], TCHAR dest[MAX_PATH], INT append, DWORD lpdwFl
break;
WriteFile (hFileDest, buffer, dwRead, &dwWritten, NULL);
if (dwWritten != dwRead)
if (dwWritten != dwRead || CheckCtrlBreak(BREAK_INPUT))
{
ConOutResPuts(STRING_COPY_ERROR3);
free (buffer);
CloseHandle (hFileDest);
CloseHandle (hFileSrc);
nErrorLevel = 1;
nErrorLevel = 1;
return 0;
}
}
@ -731,6 +740,12 @@ INT cmd_copy (LPTSTR cmd, LPTSTR param)
do
{
/* Check Breaker */
if(CheckCtrlBreak(BREAK_INPUT))
{
freep(arg);
return 1;
}
/* Set the override to yes each new file */
nOverwrite = 1;

View file

@ -107,7 +107,8 @@ RemoveFile (LPTSTR lpFileName, DWORD dwFlags, WIN32_FIND_DATA* f)
/*This function is called by CommandDelete and
does the actual process of deleting the single
file*/
if(CheckCtrlBreak(BREAK_INPUT))
return 1;
/*check to see if it is read only and if this is done based on /A
if it is done by file name, access is denied. However, if it is done

View file

@ -2027,7 +2027,7 @@ CommandDir(LPTSTR first, LPTSTR rest)
}
/* read the parameters */
if (!DirReadParam(rest, &params, &entries, &stFlags))
if (!DirReadParam(rest, &params, &entries, &stFlags) || CheckCtrlBreak(BREAK_INPUT))
{
nErrorLevel = 1;
return 1;
@ -2044,7 +2044,7 @@ CommandDir(LPTSTR first, LPTSTR rest)
for(loop = 0; loop < entries; loop++)
{
/* parse the directory info */
if (DirParsePathspec (params[loop], szPath, szFilespec))
if (DirParsePathspec (params[loop], szPath, szFilespec) || CheckCtrlBreak(BREAK_INPUT))
{
nErrorLevel = 1;
return 1;