Remove more hardcode string to En.rc

svn path=/trunk/; revision=14476
This commit is contained in:
Magnus Olsen 2005-04-03 13:40:15 +00:00
parent 7f6485630b
commit 2f4cc70e0f
5 changed files with 176 additions and 81 deletions

View file

@ -134,6 +134,23 @@ DATE [/T][date]\n\n \
Type DATE without parameters to display the current date setting and\n \ Type DATE without parameters to display the current date setting and\n \
a prompt for a new one. Press ENTER to keep the same date." a prompt for a new one. Press ENTER to keep the same date."
STRING_DEL_HELP1, "Deletes one or more files.\n\n \
DEL [/%c /%c /%c /%c /%c /%c /%c] file ...\n \
DELETE [/%c /%c /%c /%c /%c /%c /%c] file ...\n \
ERASE [/%c /%c /%c /%c /%c /%c /%c] file ...\n\n \
file Specifies the file(s) to delete.\n\n \
/%c Nothing.\n \
/%c Prompt. Ask before deleting each file.\n \
/%c Total. Display total number of deleted files and freed disk space.\n \
/%c Quiet.\n \
/%c Wipe. Overwrite the file with random numbers before deleting it.\n \
/%c Yes. Kill even *.* without asking.\n \
/%c Zap. Delete hidden, read-only and system files).\n"
STRING_DEL_HELP3, " %lu file%s deleted\n"
STRING_DEL_HELP4, " %lu files deleted\n"
STRING_EXIT_HELP, "Exits the command line interpreter.\n\nEXIT" STRING_EXIT_HELP, "Exits the command line interpreter.\n\nEXIT"
STRING_MKDIR_HELP, "Creates a directory.\n\n \ STRING_MKDIR_HELP, "Creates a directory.\n\n \
@ -144,14 +161,18 @@ RMDIR [drive:]path\nRD [drive:]path"
STRING_REM_HELP, "Starts a comment line in a batch file.\n\nREM [Comment]" STRING_REM_HELP, "Starts a comment line in a batch file.\n\nREM [Comment]"
STRING_DEL_HELP2, "All files in the directory will be deleted!\nAre you sure (Y/N)?"
STRING_CHOICE_OPTION, "YN" STRING_CHOICE_OPTION, "YN"
STRING_COPY_OPTION, "YNA" STRING_COPY_OPTION, "YNA"
STRING_DEL_OPTION, "AENPQSTWXYZ"
STRING_ALIAS_ERROR, "Command line too long after alias expansion!\n" STRING_ALIAS_ERROR, "Command line too long after alias expansion!\n"
@ -168,12 +189,24 @@ STRING_CMD_ERROR2, "Error creating temporary file for pipe data\n"
STRING_CMD_ERROR3, "Can't redirect to file %s\n" STRING_CMD_ERROR3, "Can't redirect to file %s\n"
STRING_CMD_ERROR4, "Running %s...\n" STRING_CMD_ERROR4, "Running %s...\n"
STRING_CMD_ERROR5, "Running cmdexit.bat...\n" STRING_CMD_ERROR5, "Running cmdexit.bat...\n"
STRING_COLOR_ERROR1, "Same colors error! (Background and foreground can't be the same color)"
STRING_COLOR_ERROR2, "error in color specification"
STRING_COLOR_ERROR3, "Color %x\n"
STRING_COLOR_ERROR4, "same colors error!"
STRING_CONSOLE_ERROR, "Unknown error: %d\n" STRING_CONSOLE_ERROR, "Unknown error: %d\n"
STRING_COPY_ERROR1, "Error: Cannot open source - %s!\n" STRING_COPY_ERROR1, "Error: Cannot open source - %s!\n"
STRING_COPY_ERROR2, "Error: Can't copy onto itself!\n" STRING_COPY_ERROR2, "Error: Can't copy onto itself!\n"
STRING_COPY_ERROR3, "Error writing destination!\n" STRING_COPY_ERROR3, "Error writing destination!\n"
STRING_COPY_ERROR4, "Error: Not implemented yet!\n" STRING_COPY_ERROR4, "Error: Not implemented yet!\n"
STRING_DATE_ERROR, "Invalid date." STRING_DATE_ERROR, "Invalid date."
STRING_DEL_ERROR1, "Wildcards!\n\n"
STRING_DEL_ERROR2, "Full path: %s\n"
STRING_DEL_ERROR3, "File part: %s\n"
STRING_DEL_ERROR4, "Full filename: %s\n"
STRING_DEL_ERROR5, "The file %s will be deleted! "
STRING_DEL_ERROR6, "Are you sure (Y/N)?"
STRING_DEL_ERROR7, "Deleting: %s\n"
STRING_DEL_ERROR8, "No Wildcards!\n"
STRING_PARAM_ERROR, "Required parameter missing\n" STRING_PARAM_ERROR, "Required parameter missing\n"

View file

@ -41,10 +41,12 @@ VOID SetScreenColor (WORD wColor, BOOL bFill)
DWORD dwWritten; DWORD dwWritten;
CONSOLE_SCREEN_BUFFER_INFO csbi; CONSOLE_SCREEN_BUFFER_INFO csbi;
COORD coPos; COORD coPos;
WCHAR szMsg[RC_STRING_MAX_SIZE];
if ((wColor & 0xF) == (wColor &0xF0) >> 4) if ((wColor & 0xF) == (wColor &0xF0) >> 4)
{ {
ConErrPuts (_T("Same colors error! (Background and foreground can't be the same color)")); LoadString( GetModuleHandle(NULL), STRING_COLOR_ERROR1, (LPTSTR) szMsg,sizeof(szMsg));
ConErrPuts (_T((LPTSTR)szMsg));
} }
else else
{ {
@ -72,6 +74,8 @@ VOID SetScreenColor (WORD wColor, BOOL bFill)
*/ */
INT CommandColor (LPTSTR first, LPTSTR rest) INT CommandColor (LPTSTR first, LPTSTR rest)
{ {
WCHAR szMsg[RC_STRING_MAX_SIZE];
if (_tcsncmp (rest, _T("/?"), 2) == 0) if (_tcsncmp (rest, _T("/?"), 2) == 0)
{ {
ColorHelp (); ColorHelp ();
@ -88,15 +92,18 @@ INT CommandColor (LPTSTR first, LPTSTR rest)
if (StringToColor (&wColor, &rest) == FALSE) if (StringToColor (&wColor, &rest) == FALSE)
{ {
ConErrPuts(_T("error in color specification")); LoadString( GetModuleHandle(NULL), STRING_COLOR_ERROR2, (LPTSTR) szMsg,sizeof(szMsg));
ConErrPuts (_T((LPTSTR)szMsg));
return 1; return 1;
} }
ConErrPrintf (_T("Color %x\n"), wColor); LoadString( GetModuleHandle(NULL), STRING_COLOR_ERROR3, (LPTSTR) szMsg,sizeof(szMsg));
ConErrPrintf (_T((LPTSTR)szMsg), wColor);
if ((wColor & 0xF) == (wColor &0xF0) >> 4) if ((wColor & 0xF) == (wColor &0xF0) >> 4)
{ {
ConErrPuts (_T("same colors error!")); LoadString( GetModuleHandle(NULL), STRING_COLOR_ERROR4, (LPTSTR) szMsg,sizeof(szMsg));
ConErrPrintf (_T((LPTSTR)szMsg), wColor);
return 1; return 1;
} }

View file

@ -303,7 +303,7 @@ Overwrite (LPTSTR fn)
TCHAR Options[3]; TCHAR Options[3];
WCHAR szMsg[RC_STRING_MAX_SIZE]; WCHAR szMsg[RC_STRING_MAX_SIZE];
LoadString( GetModuleHandle(NULL), STRING_COPY_OPTION, (LPTSTR) Options,sizeof(lpOptions)); LoadString( GetModuleHandle(NULL), STRING_COPY_OPTION, (LPTSTR) Options,sizeof(Options)+sizeof(WCHAR));
lpOptions = _T(Options); lpOptions = _T(Options);
LoadString( GetModuleHandle(NULL), STRING_COPY_HELP1, (LPTSTR) szMsg,sizeof(szMsg)); LoadString( GetModuleHandle(NULL), STRING_COPY_HELP1, (LPTSTR) szMsg,sizeof(szMsg));

View file

@ -35,6 +35,7 @@
*/ */
#include "precomp.h" #include "precomp.h"
#include "resource.h"
#ifdef INCLUDE_CMD_DEL #ifdef INCLUDE_CMD_DEL
@ -108,29 +109,30 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param)
HANDLE hFile; HANDLE hFile;
WIN32_FIND_DATA f; WIN32_FIND_DATA f;
LPTSTR lpOptions;
TCHAR Options[11];
WCHAR szMsg[RC_STRING_MAX_SIZE];
LONG ch;
LoadString( GetModuleHandle(NULL), STRING_DEL_OPTION, (LPTSTR) Options,sizeof(Options)+sizeof(WCHAR));
lpOptions = _T(Options);
if (!_tcsncmp (param, _T("/?"), 2)) if (!_tcsncmp (param, _T("/?"), 2))
{ {
ConOutPuts (_T("Deletes one or more files.\n" LoadString( GetModuleHandle(NULL), STRING_DEL_HELP1, (LPTSTR) szMsg,sizeof(szMsg));
"\n" ConOutPrintf (_T((LPTSTR)szMsg),
"DEL [/N /P /T /Q /W /Y /Z] file ...\n" lpOptions[2],Options[3],lpOptions[6],lpOptions[4],lpOptions[7],lpOptions[9],lpOptions[10],
"DELETE [/N /P /T /Q /W /Y /Z] file ...\n" lpOptions[2],Options[3],lpOptions[6],lpOptions[4],lpOptions[7],lpOptions[9],lpOptions[10],
"ERASE [/N /P /T /Q /W /Y /Z] file ...\n" lpOptions[2],Options[3],lpOptions[6],lpOptions[4],lpOptions[7],lpOptions[9],lpOptions[10],
"\n" lpOptions[2],Options[3],lpOptions[6],lpOptions[4],lpOptions[7],lpOptions[9],lpOptions[10]
" file Specifies the file(s) to delete.\n" );
"\n"
" /N Nothing.\n"
" /P Prompt. Ask before deleting each file.\n"
" /T Total. Display total number of deleted files and freed disk space.\n"
" /Q Quiet.\n"
" /W Wipe. Overwrite the file with random numbers before deleting it.\n"
" /Y Yes. Kill even *.* without asking.\n"
" /Z Zap. Delete hidden, read-only and system files).\n"));
return 0; return 0;
} }
arg = split (param, &args, FALSE); arg = split (param, &args, FALSE);
if (args > 0) if (args > 0)
{ {
/* check for options anywhere in command line */ /* check for options anywhere in command line */
@ -140,38 +142,48 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param)
{ {
if (_tcslen (arg[i]) >= 2) if (_tcslen (arg[i]) >= 2)
{ {
switch (_totupper (arg[i][1]))
{ ch = _totupper (arg[i][1]);
case _T('N'):
dwFlags |= DEL_NOTHING; if (_totupper (lpOptions[2]) == ch)
break; {
dwFlags |= DEL_NOTHING;
}
case _T('P'): else if (_totupper (lpOptions[3]) == ch)
dwFlags |= DEL_PROMPT; {
break; dwFlags |= DEL_PROMPT;
}
else if (_totupper (lpOptions[4]) == ch)
{
dwFlags |= DEL_QUIET;
}
case _T('Q'): else if (_totupper (lpOptions[5]) == ch)
dwFlags |= DEL_QUIET; {
break; dwFlags |= DEL_SUBDIR;
}
case _T('S'): else if (_totupper (lpOptions[6]) == ch)
dwFlags |= DEL_SUBDIR; {
break; dwFlags |= DEL_TOTAL;
}
case _T('T'): else if (_totupper (lpOptions[7]) == ch)
dwFlags |= DEL_TOTAL; {
break; dwFlags |= DEL_WIPE;
}
case _T('W'): else if (_totupper (lpOptions[9]) == ch)
dwFlags |= DEL_WIPE; {
break; dwFlags |= DEL_YES;
case _T('Y'): }
dwFlags |= DEL_YES;
break; else if (_totupper (lpOptions[10]) == ch)
case _T('Z'): {
dwFlags |= DEL_ZAP; dwFlags |= DEL_ZAP;
break; }
}
} }
@ -199,8 +211,10 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param)
{ {
if (!((dwFlags & DEL_YES) || (dwFlags & DEL_QUIET) || (dwFlags & DEL_PROMPT))) if (!((dwFlags & DEL_YES) || (dwFlags & DEL_QUIET) || (dwFlags & DEL_PROMPT)))
{ {
res = FilePromptYN (_T("All files in the directory will be deleted!\n"
"Are you sure (Y/N)?")); LoadString( GetModuleHandle(NULL), STRING_DEL_HELP2, (LPTSTR) szMsg,sizeof(szMsg));
res = FilePromptYN (_T( (LPTSTR) szMsg));
if ((res == PROMPT_NO) || (res == PROMPT_BREAK)) if ((res == PROMPT_NO) || (res == PROMPT_BREAK))
break; break;
@ -217,7 +231,8 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param)
{ {
/* wildcards in filespec */ /* wildcards in filespec */
#ifdef _DEBUG #ifdef _DEBUG
ConErrPrintf (_T("Wildcards!\n\n")); LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR1, (LPTSTR) szMsg,sizeof(szMsg));
ConErrPrintf (_T((LPTSTR)szMsg));
#endif #endif
GetFullPathName (arg[i], GetFullPathName (arg[i],
@ -226,8 +241,12 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param)
&pFilePart); &pFilePart);
#ifdef _DEBUG #ifdef _DEBUG
ConErrPrintf (_T("Full path: %s\n"), szFullPath); LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR2, (LPTSTR) szMsg,sizeof(szMsg));
ConErrPrintf (_T("File part: %s\n"), pFilePart); ConErrPrintf (_T((LPTSTR)szMsg), szFullPath);
LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR3, (LPTSTR) szMsg,sizeof(szMsg));
ConErrPrintf (_T((LPTSTR)szMsg), pFilePart);
#endif #endif
hFile = FindFirstFile (szFullPath, &f); hFile = FindFirstFile (szFullPath, &f);
@ -249,13 +268,18 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param)
_tcscpy (pFilePart, f.cFileName); _tcscpy (pFilePart, f.cFileName);
#ifdef _DEBUG #ifdef _DEBUG
ConErrPrintf (_T("Full filename: %s\n"), szFullPath); LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR4, (LPTSTR) szMsg,sizeof(szMsg));
ConErrPrintf (_T((LPTSTR)szMsg));
#endif #endif
/* ask for deleting */ /* ask for deleting */
if (dwFlags & DEL_PROMPT) if (dwFlags & DEL_PROMPT)
{ {
ConErrPrintf (_T("The file %s will be deleted! "), szFullPath); LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR5, (LPTSTR) szMsg,sizeof(szMsg));
res = FilePromptYN (_T("Are you sure (Y/N)?")); ConErrPrintf (_T((LPTSTR)szMsg), szFullPath);
LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR6, (LPTSTR) szMsg,sizeof(szMsg));
res = FilePromptYN (_T((LPTSTR)szMsg));
if ((res == PROMPT_NO) || (res == PROMPT_BREAK)) if ((res == PROMPT_NO) || (res == PROMPT_BREAK))
{ {
@ -264,7 +288,10 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param)
} }
if (!(dwFlags & DEL_QUIET) && !(dwFlags & DEL_TOTAL)) if (!(dwFlags & DEL_QUIET) && !(dwFlags & DEL_TOTAL))
ConErrPrintf (_T("Deleting: %s\n"), szFullPath); {
LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR7, (LPTSTR) szMsg,sizeof(szMsg));
ConErrPrintf (_T((LPTSTR)szMsg), szFullPath);
}
/* delete the file */ /* delete the file */
if (!(dwFlags & DEL_NOTHING)) if (!(dwFlags & DEL_NOTHING))
@ -307,7 +334,8 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param)
{ {
/* no wildcards in filespec */ /* no wildcards in filespec */
#ifdef _DEBUG #ifdef _DEBUG
ConErrPrintf (_T("No Wildcards!\n")); LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR8, (LPTSTR) szMsg,sizeof(szMsg));
ConErrPrintf (_T((LPTSTR)szMsg));
#endif #endif
GetFullPathName (arg[i], GetFullPathName (arg[i],
MAX_PATH, MAX_PATH,
@ -317,8 +345,11 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param)
/*ask for deleting */ /*ask for deleting */
if((dwFlags & DEL_PROMPT) && (FindFirstFile(szFullPath, &f) != INVALID_HANDLE_VALUE)) //Don't ask if the file doesn't exist, the following code will make the error-msg if((dwFlags & DEL_PROMPT) && (FindFirstFile(szFullPath, &f) != INVALID_HANDLE_VALUE)) //Don't ask if the file doesn't exist, the following code will make the error-msg
{ {
ConErrPrintf (_T("The file %s will be deleted! "), szFullPath); LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR5, (LPTSTR) szMsg,sizeof(szMsg));
res = FilePromptYN (_T("Are you sure (Y/N)?")); ConErrPrintf (_T((LPTSTR)szMsg), szFullPath);
LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR6, (LPTSTR) szMsg,sizeof(szMsg));
res = FilePromptYN (_T((LPTSTR)szMsg));
if ((res == PROMPT_NO) || (res == PROMPT_BREAK)) if ((res == PROMPT_NO) || (res == PROMPT_BREAK))
{ {
@ -327,10 +358,14 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param)
} }
#ifdef _DEBUG #ifdef _DEBUG
ConErrPrintf (_T("Full path: %s\n"), szFullPath); LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR3, (LPTSTR) szMsg,sizeof(szMsg));
ConErrPrintf (_T((LPTSTR)szMsg), szFullPath);
#endif #endif
if (!(dwFlags & DEL_QUIET) && !(dwFlags & DEL_TOTAL)) if (!(dwFlags & DEL_QUIET) && !(dwFlags & DEL_TOTAL))
ConOutPrintf (_T("Deleting %s\n"), szFullPath); {
LoadString( GetModuleHandle(NULL), STRING_DEL_ERROR7, (LPTSTR) szMsg,sizeof(szMsg));
ConErrPrintf (_T((LPTSTR)szMsg), szFullPath);
}
if (!(dwFlags & DEL_NOTHING)) if (!(dwFlags & DEL_NOTHING))
{ {
@ -380,12 +415,16 @@ INT CommandDelete (LPTSTR cmd, LPTSTR param)
if (!(dwFlags & DEL_QUIET)) if (!(dwFlags & DEL_QUIET))
{ {
if (dwFiles == 0) if (dwFiles < 2)
ConOutPrintf (_T(" 0 files deleted\n")); {
LoadString( GetModuleHandle(NULL), STRING_DEL_HELP3, (LPTSTR) szMsg,sizeof(szMsg));
}
else else
ConOutPrintf (_T(" %lu file%s deleted\n"), {
dwFiles, LoadString( GetModuleHandle(NULL), STRING_DEL_HELP4, (LPTSTR) szMsg,sizeof(szMsg));
(dwFiles == 1) ? _T("") : _T("s")); }
ConOutPrintf (_T((LPTSTR)szMsg), dwFiles);
} }
return 0; return 0;

View file

@ -2,7 +2,7 @@
#define STRING_CHOICE_OPTION 200 #define STRING_CHOICE_OPTION 200
#define STRING_COPY_OPTION 201 #define STRING_COPY_OPTION 201
#define STRING_DEL_OPTION 202
#define STRING_ALIAS_ERROR 300 #define STRING_ALIAS_ERROR 300
#define STRING_BATCH_ERROR 301 #define STRING_BATCH_ERROR 301
@ -18,13 +18,25 @@
#define STRING_CMD_ERROR3 311 #define STRING_CMD_ERROR3 311
#define STRING_CMD_ERROR4 312 #define STRING_CMD_ERROR4 312
#define STRING_CMD_ERROR5 313 #define STRING_CMD_ERROR5 313
#define STRING_CONSOLE_ERROR 314 #define STRING_COLOR_ERROR1 314
#define STRING_COPY_ERROR1 315 #define STRING_COLOR_ERROR2 315
#define STRING_COPY_ERROR2 316 #define STRING_COLOR_ERROR3 316
#define STRING_COPY_ERROR3 317 #define STRING_COLOR_ERROR4 317
#define STRING_COPY_ERROR4 318 #define STRING_CONSOLE_ERROR 318
#define STRING_DATE_ERROR 319 #define STRING_COPY_ERROR1 319
#define STRING_PARAM_ERROR 320 #define STRING_COPY_ERROR2 320
#define STRING_COPY_ERROR3 321
#define STRING_COPY_ERROR4 322
#define STRING_DATE_ERROR 323
#define STRING_DEL_ERROR1 324
#define STRING_DEL_ERROR2 325
#define STRING_DEL_ERROR3 326
#define STRING_DEL_ERROR4 327
#define STRING_DEL_ERROR5 328
#define STRING_DEL_ERROR6 329
#define STRING_DEL_ERROR7 330
#define STRING_DEL_ERROR8 331
#define STRING_PARAM_ERROR 332
#define STRING_ATTRIB_HELP 400 #define STRING_ATTRIB_HELP 400
#define STRING_ALIAS_HELP 401 #define STRING_ALIAS_HELP 401
@ -49,10 +61,14 @@
#define STRING_DATE_HELP2 420 #define STRING_DATE_HELP2 420
#define STRING_DATE_HELP3 421 #define STRING_DATE_HELP3 421
#define STRING_DATE_HELP4 422 #define STRING_DATE_HELP4 422
#define STRING_EXIT_HELP 423 #define STRING_DEL_HELP1 423
#define STRING_MKDIR_HELP 424 #define STRING_DEL_HELP2 424
#define STRING_RMDIR_HELP 425 #define STRING_DEL_HELP3 425
#define STRING_REM_HELP 426 #define STRING_DEL_HELP4 426
#define STRING_EXIT_HELP 427
#define STRING_MKDIR_HELP 428
#define STRING_RMDIR_HELP 429
#define STRING_REM_HELP 430