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); free(com);
} }

View file

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

View file

@ -107,7 +107,8 @@ RemoveFile (LPTSTR lpFileName, DWORD dwFlags, WIN32_FIND_DATA* f)
/*This function is called by CommandDelete and /*This function is called by CommandDelete and
does the actual process of deleting the single does the actual process of deleting the single
file*/ file*/
if(CheckCtrlBreak(BREAK_INPUT))
return 1;
/*check to see if it is read only and if this is done based on /A /*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 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 */ /* read the parameters */
if (!DirReadParam(rest, &params, &entries, &stFlags)) if (!DirReadParam(rest, &params, &entries, &stFlags) || CheckCtrlBreak(BREAK_INPUT))
{ {
nErrorLevel = 1; nErrorLevel = 1;
return 1; return 1;
@ -2044,7 +2044,7 @@ CommandDir(LPTSTR first, LPTSTR rest)
for(loop = 0; loop < entries; loop++) for(loop = 0; loop < entries; loop++)
{ {
/* parse the directory info */ /* parse the directory info */
if (DirParsePathspec (params[loop], szPath, szFilespec)) if (DirParsePathspec (params[loop], szPath, szFilespec) || CheckCtrlBreak(BREAK_INPUT))
{ {
nErrorLevel = 1; nErrorLevel = 1;
return 1; return 1;