cmd.exe: Convert cmd to Unicode.

This commit is contained in:
Jason Edmeades 2007-06-03 22:07:42 +01:00 committed by Alexandre Julliard
parent 398e710376
commit b8aa5fc586
20 changed files with 1309 additions and 946 deletions

View File

@ -263,4 +263,8 @@ Zadejte HELP <p
WCMD_ARGERR, "Parameter error\n" WCMD_ARGERR, "Parameter error\n"
WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n" WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n"
WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?" WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?"
WCMD_NOPATH, "PATH not found\n"
WCMD_ANYKEY,"Press Return key to continue: "
WCMD_CONSTITLE,"Wine Command Prompt"
WCMD_VERSION,"CMD Version %s\n\n"
} }

View File

@ -287,4 +287,8 @@ obigen Befehle erhalten.\n"
WCMD_ARGERR, "Parameter error\n" WCMD_ARGERR, "Parameter error\n"
WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n" WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n"
WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?" WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?"
WCMD_NOPATH, "PATH not found\n"
WCMD_ANYKEY,"Press Return key to continue: "
WCMD_CONSTITLE,"Wine Command Prompt"
WCMD_VERSION,"CMD Version %s\n\n"
} }

View File

@ -267,4 +267,8 @@ Enter HELP <command> for further information on any of the above commands\n"
WCMD_ARGERR, "Parameter error\n" WCMD_ARGERR, "Parameter error\n"
WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n" WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n"
WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?" WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?"
WCMD_NOPATH, "PATH not found\n"
WCMD_ANYKEY,"Press Return key to continue: "
WCMD_CONSTITLE,"Wine Command Prompt"
WCMD_VERSION,"CMD Version %s\n\n"
} }

View File

@ -284,4 +284,8 @@ Introduzca HELP <comando> para m
WCMD_ARGERR, "Parameter error\n" WCMD_ARGERR, "Parameter error\n"
WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n" WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n"
WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?" WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?"
WCMD_NOPATH, "PATH not found\n"
WCMD_ANYKEY,"Press Return key to continue: "
WCMD_CONSTITLE,"Wine Command Prompt"
WCMD_VERSION,"CMD Version %s\n\n"
} }

View File

@ -257,4 +257,8 @@ Entrez HELP <commande> pour plus d'informations sur les commandes ci-dessus\n"
WCMD_ARGERR, "Parameter error\n" WCMD_ARGERR, "Parameter error\n"
WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n" WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n"
WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?" WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?"
WCMD_NOPATH, "PATH not found\n"
WCMD_ANYKEY,"Press Return key to continue: "
WCMD_CONSTITLE,"Wine Command Prompt"
WCMD_VERSION,"CMD Version %s\n\n"
} }

View File

@ -261,4 +261,8 @@ EXIT\t\tCMD
WCMD_ARGERR, "Parameter error\n" WCMD_ARGERR, "Parameter error\n"
WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n" WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n"
WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?" WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?"
WCMD_NOPATH, "PATH not found\n"
WCMD_ANYKEY,"Press Return key to continue: "
WCMD_CONSTITLE,"Wine Command Prompt"
WCMD_VERSION,"CMD Version %s\n\n"
} }

View File

@ -259,4 +259,8 @@ HELP <
WCMD_ARGERR, "Parameter error\n" WCMD_ARGERR, "Parameter error\n"
WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n" WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n"
WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?" WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?"
WCMD_NOPATH, "PATH not found\n"
WCMD_ANYKEY,"Press Return key to continue: "
WCMD_CONSTITLE,"Wine Command Prompt"
WCMD_VERSION,"CMD Version %s\n\n"
} }

View File

@ -4,6 +4,7 @@ SRCDIR = @srcdir@
VPATH = @srcdir@ VPATH = @srcdir@
MODULE = cmd.exe MODULE = cmd.exe
APPMODE = -mconsole APPMODE = -mconsole
EXTRADEFS = -DUNICODE
IMPORTS = shell32 user32 advapi32 kernel32 IMPORTS = shell32 user32 advapi32 kernel32
C_SRCS = \ C_SRCS = \

View File

@ -260,4 +260,8 @@ type HELP <opdracht> voor meer informatie over bovengenoemde opdrachten\n"
WCMD_ARGERR, "Parameter error\n" WCMD_ARGERR, "Parameter error\n"
WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n" WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n"
WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?" WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?"
WCMD_NOPATH, "PATH not found\n"
WCMD_ANYKEY,"Press Return key to continue: "
WCMD_CONSTITLE,"Wine Command Prompt"
WCMD_VERSION,"CMD Version %s\n\n"
} }

View File

@ -265,4 +265,8 @@ Skriv
WCMD_ARGERR, "Parameter error\n" WCMD_ARGERR, "Parameter error\n"
WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n" WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n"
WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?" WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?"
WCMD_NOPATH, "PATH not found\n"
WCMD_ANYKEY,"Press Return key to continue: "
WCMD_CONSTITLE,"Wine Command Prompt"
WCMD_VERSION,"CMD Version %s\n\n"
} }

View File

@ -262,4 +262,8 @@ Wpisz HELP <komenda> dla dok
WCMD_ARGERR, "Parameter error\n" WCMD_ARGERR, "Parameter error\n"
WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n" WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n"
WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?" WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?"
WCMD_NOPATH, "PATH not found\n"
WCMD_ANYKEY,"Press Return key to continue: "
WCMD_CONSTITLE,"Wine Command Prompt"
WCMD_VERSION,"CMD Version %s\n\n"
} }

View File

@ -470,4 +470,8 @@ Digite HELP <comando> para mais informa
WCMD_ARGERR, "Parameter error\n" WCMD_ARGERR, "Parameter error\n"
WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n" WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n"
WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?" WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?"
WCMD_NOPATH, "PATH not found\n"
WCMD_ANYKEY,"Press Return key to continue: "
WCMD_CONSTITLE,"Wine Command Prompt"
WCMD_VERSION,"CMD Version %s\n\n"
} }

View File

@ -273,4 +273,8 @@ EXIT\t\t
WCMD_ARGERR, "Parameter error\n" WCMD_ARGERR, "Parameter error\n"
WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n" WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n"
WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?" WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?"
WCMD_NOPATH, "PATH not found\n"
WCMD_ANYKEY,"Press Return key to continue: "
WCMD_CONSTITLE,"Wine Command Prompt"
WCMD_VERSION,"CMD Version %s\n\n"
} }

View File

@ -259,4 +259,8 @@ Enter HELP <command> for further information on any of the above commands\n"
WCMD_ARGERR, "Parameter error\n" WCMD_ARGERR, "Parameter error\n"
WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n" WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n"
WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?" WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?"
WCMD_NOPATH, "PATH not found\n"
WCMD_ANYKEY,"Press Return key to continue: "
WCMD_CONSTITLE,"Wine Command Prompt"
WCMD_VERSION,"CMD Version %s\n\n"
} }

View File

@ -261,4 +261,8 @@ Yukar
WCMD_ARGERR, "Parameter error\n" WCMD_ARGERR, "Parameter error\n"
WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n" WCMD_VOLUMEDETAIL, "Volume in drive %c is %s\nVolume Serial Number is %04x-%04x\n\n"
WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?" WCMD_VOLUMEPROMPT, "Volume label (11 characters, ENTER for none)?"
WCMD_NOPATH, "PATH not found\n"
WCMD_ANYKEY,"Press Return key to continue: "
WCMD_CONSTITLE,"Wine Command Prompt"
WCMD_VERSION,"CMD Version %s\n\n"
} }

View File

@ -21,7 +21,7 @@
#include "wcmd.h" #include "wcmd.h"
extern int echo_mode; extern int echo_mode;
extern char quals[MAX_PATH], param1[MAX_PATH], param2[MAX_PATH]; extern WCHAR quals[MAX_PATH], param1[MAX_PATH], param2[MAX_PATH];
extern BATCH_CONTEXT *context; extern BATCH_CONTEXT *context;
extern DWORD errorlevel; extern DWORD errorlevel;
@ -41,30 +41,31 @@ extern DWORD errorlevel;
* a label to goto once opened. * a label to goto once opened.
*/ */
void WCMD_batch (char *file, char *command, int called, char *startLabel, HANDLE pgmHandle) { void WCMD_batch (WCHAR *file, WCHAR *command, int called, WCHAR *startLabel, HANDLE pgmHandle) {
#define WCMD_BATCH_EXT_SIZE 5 #define WCMD_BATCH_EXT_SIZE 5
HANDLE h = INVALID_HANDLE_VALUE; HANDLE h = INVALID_HANDLE_VALUE;
char string[MAXSTRING]; WCHAR string[MAXSTRING];
char extension_batch[][WCMD_BATCH_EXT_SIZE] = {".bat",".cmd"}; static const WCHAR extension_batch[][WCMD_BATCH_EXT_SIZE] = {{'.','b','a','t','\0'},
char extension_exe[WCMD_BATCH_EXT_SIZE] = ".exe"; {'.','c','m','d','\0'}};
static const WCHAR extension_exe[WCMD_BATCH_EXT_SIZE] = {'.','e','x','e','\0'};
unsigned int i; unsigned int i;
BATCH_CONTEXT *prev_context; BATCH_CONTEXT *prev_context;
if (startLabel == NULL) { if (startLabel == NULL) {
for(i=0; (i<(sizeof(extension_batch)/WCMD_BATCH_EXT_SIZE)) && for(i=0; (i<((sizeof(extension_batch) * sizeof(WCHAR))/WCMD_BATCH_EXT_SIZE)) &&
(h == INVALID_HANDLE_VALUE); i++) { (h == INVALID_HANDLE_VALUE); i++) {
strcpy (string, file); strcpyW (string, file);
CharLower (string); CharLower (string);
if (strstr (string, extension_batch[i]) == NULL) strcat (string, extension_batch[i]); if (strstrW (string, extension_batch[i]) == NULL) strcatW (string, extension_batch[i]);
h = CreateFile (string, GENERIC_READ, FILE_SHARE_READ, h = CreateFile (string, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
} }
if (h == INVALID_HANDLE_VALUE) { if (h == INVALID_HANDLE_VALUE) {
strcpy (string, file); strcpyW (string, file);
CharLower (string); CharLower (string);
if (strstr (string, extension_exe) == NULL) strcat (string, extension_exe); if (strstrW (string, extension_exe) == NULL) strcatW (string, extension_exe);
h = CreateFile (string, GENERIC_READ, FILE_SHARE_READ, h = CreateFile (string, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (h != INVALID_HANDLE_VALUE) { if (h != INVALID_HANDLE_VALUE) {
@ -95,7 +96,7 @@ void WCMD_batch (char *file, char *command, int called, char *startLabel, HANDLE
/* If processing a call :label, 'goto' the label in question */ /* If processing a call :label, 'goto' the label in question */
if (startLabel) { if (startLabel) {
strcpy(param1, startLabel); strcpyW(param1, startLabel);
WCMD_goto(); WCMD_goto();
} }
@ -105,7 +106,7 @@ void WCMD_batch (char *file, char *command, int called, char *startLabel, HANDLE
*/ */
while (context -> skip_rest == FALSE && WCMD_fgets (string, sizeof(string), h)) { while (context -> skip_rest == FALSE && WCMD_fgets (string, sizeof(string), h)) {
if (strlen(string) == MAXSTRING -1) { if (strlenW(string) == MAXSTRING -1) {
WCMD_output_asis( WCMD_LoadMessage(WCMD_TRUNCATEDLINE)); WCMD_output_asis( WCMD_LoadMessage(WCMD_TRUNCATEDLINE));
WCMD_output_asis( string); WCMD_output_asis( string);
WCMD_output_asis( newline); WCMD_output_asis( newline);
@ -141,11 +142,11 @@ void WCMD_batch (char *file, char *command, int called, char *startLabel, HANDLE
* Also returns a pointer to the location of the parameter in the command line. * Also returns a pointer to the location of the parameter in the command line.
*/ */
char *WCMD_parameter (char *s, int n, char **where) { WCHAR *WCMD_parameter (WCHAR *s, int n, WCHAR **where) {
int i = 0; int i = 0;
static char param[MAX_PATH]; static WCHAR param[MAX_PATH];
char *p; WCHAR *p;
if (where != NULL) *where = NULL; if (where != NULL) *where = NULL;
p = param; p = param;
@ -211,32 +212,32 @@ char *WCMD_parameter (char *s, int n, char **where) {
* the LF (or CRLF) from the line. * the LF (or CRLF) from the line.
*/ */
char *WCMD_fgets (char *s, int n, HANDLE h) { WCHAR *WCMD_fgets (WCHAR *s, int noChars, HANDLE h) {
DWORD bytes; DWORD bytes;
BOOL status; BOOL status;
char *p; WCHAR *p;
p = s; p = s;
do { do {
status = ReadFile (h, s, 1, &bytes, NULL); status = WCMD_ReadFile (h, s, 1, &bytes, NULL);
if ((status == 0) || ((bytes == 0) && (s == p))) return NULL; if ((status == 0) || ((bytes == 0) && (s == p))) return NULL;
if (*s == '\n') bytes = 0; if (*s == '\n') bytes = 0;
else if (*s != '\r') { else if (*s != '\r') {
s++; s++;
n--; noChars--;
} }
*s = '\0'; *s = '\0';
} while ((bytes == 1) && (n > 1)); } while ((bytes == 1) && (noChars > 1));
return p; return p;
} }
/* WCMD_splitpath - copied from winefile as no obvious way to use it otherwise */ /* WCMD_splitpath - copied from winefile as no obvious way to use it otherwise */
void WCMD_splitpath(const CHAR* path, CHAR* drv, CHAR* dir, CHAR* name, CHAR* ext) void WCMD_splitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext)
{ {
const CHAR* end; /* end of processed string */ const WCHAR* end; /* end of processed string */
const CHAR* p; /* search pointer */ const WCHAR* p; /* search pointer */
const CHAR* s; /* copy pointer */ const WCHAR* s; /* copy pointer */
/* extract drive name */ /* extract drive name */
if (path[0] && path[1]==':') { if (path[0] && path[1]==':') {
@ -307,7 +308,7 @@ void WCMD_splitpath(const CHAR* path, CHAR* drv, CHAR* dir, CHAR* name, CHAR* ex
* To work out the length of the modifier: * To work out the length of the modifier:
* *
* Note: In the case of %0-9 knowing the end of the modifier is easy, * Note: In the case of %0-9 knowing the end of the modifier is easy,
* but in a for loop, the for end character may also be a modifier * but in a for loop, the for end WCHARacter may also be a modifier
* eg. for %a in (c:\a.a) do echo XXX * eg. for %a in (c:\a.a) do echo XXX
* where XXX = %~a (just ~) * where XXX = %~a (just ~)
* %~aa (~ and attributes) * %~aa (~ and attributes)
@ -317,22 +318,22 @@ void WCMD_splitpath(const CHAR* path, CHAR* drv, CHAR* dir, CHAR* name, CHAR* ex
* Hence search forwards until find an invalid modifier, and then * Hence search forwards until find an invalid modifier, and then
* backwards until find for variable or 0-9 * backwards until find for variable or 0-9
*/ */
void WCMD_HandleTildaModifiers(char **start, char *forVariable) { void WCMD_HandleTildaModifiers(WCHAR **start, WCHAR *forVariable) {
#define NUMMODIFIERS 11 #define NUMMODIFIERS 11
const char validmodifiers[NUMMODIFIERS] = { static const WCHAR validmodifiers[NUMMODIFIERS] = {
'~', 'f', 'd', 'p', 'n', 'x', 's', 'a', 't', 'z', '$' '~', 'f', 'd', 'p', 'n', 'x', 's', 'a', 't', 'z', '$'
}; };
const char space[] = " "; static const WCHAR space[] = {' ', '\0'};
WIN32_FILE_ATTRIBUTE_DATA fileInfo; WIN32_FILE_ATTRIBUTE_DATA fileInfo;
char outputparam[MAX_PATH]; WCHAR outputparam[MAX_PATH];
char finaloutput[MAX_PATH]; WCHAR finaloutput[MAX_PATH];
char fullfilename[MAX_PATH]; WCHAR fullfilename[MAX_PATH];
char thisoutput[MAX_PATH]; WCHAR thisoutput[MAX_PATH];
char *pos = *start+1; WCHAR *pos = *start+1;
char *firstModifier = pos; WCHAR *firstModifier = pos;
char *lastModifier = NULL; WCHAR *lastModifier = NULL;
int modifierLen = 0; int modifierLen = 0;
BOOL finished = FALSE; BOOL finished = FALSE;
int i = 0; int i = 0;
@ -340,10 +341,10 @@ void WCMD_HandleTildaModifiers(char **start, char *forVariable) {
BOOL skipFileParsing = FALSE; BOOL skipFileParsing = FALSE;
BOOL doneModifier = FALSE; BOOL doneModifier = FALSE;
/* Search forwards until find invalid character modifier */ /* Search forwards until find invalid WCHARacter modifier */
while (!finished) { while (!finished) {
/* Work on the previous character */ /* Work on the previous WCHARacter */
if (lastModifier != NULL) { if (lastModifier != NULL) {
for (i=0; i<NUMMODIFIERS; i++) { for (i=0; i<NUMMODIFIERS; i++) {
@ -374,10 +375,10 @@ void WCMD_HandleTildaModifiers(char **start, char *forVariable) {
/* Now make sure the position we stopped at is a valid parameter */ /* Now make sure the position we stopped at is a valid parameter */
if (!(*lastModifier >= '0' || *lastModifier <= '9') && if (!(*lastModifier >= '0' || *lastModifier <= '9') &&
(forVariable != NULL) && (forVariable != NULL) &&
(toupper(*lastModifier) != toupper(*forVariable))) { (toupperW(*lastModifier) != toupperW(*forVariable))) {
/* Its not... Step backwards until it matches or we get to the start */ /* Its not... Step backwards until it matches or we get to the start */
while (toupper(*lastModifier) != toupper(*forVariable) && while (toupperW(*lastModifier) != toupperW(*forVariable) &&
lastModifier > firstModifier) { lastModifier > firstModifier) {
lastModifier--; lastModifier--;
} }
@ -386,7 +387,7 @@ void WCMD_HandleTildaModifiers(char **start, char *forVariable) {
/* Extract the parameter to play with */ /* Extract the parameter to play with */
if ((*lastModifier >= '0' && *lastModifier <= '9')) { if ((*lastModifier >= '0' && *lastModifier <= '9')) {
strcpy(outputparam, WCMD_parameter (context -> command, strcpyW(outputparam, WCMD_parameter (context -> command,
*lastModifier-'0' + context -> shift_count[*lastModifier-'0'], NULL)); *lastModifier-'0' + context -> shift_count[*lastModifier-'0'], NULL));
} else { } else {
/* FIXME: Retrieve 'for' variable %c\n", *lastModifier); */ /* FIXME: Retrieve 'for' variable %c\n", *lastModifier); */
@ -407,26 +408,26 @@ void WCMD_HandleTildaModifiers(char **start, char *forVariable) {
/* 1. Handle '~' : Strip surrounding quotes */ /* 1. Handle '~' : Strip surrounding quotes */
if (outputparam[0]=='"' && if (outputparam[0]=='"' &&
memchr(firstModifier, '~', modifierLen) != NULL) { memchrW(firstModifier, '~', modifierLen) != NULL) {
int len = strlen(outputparam); int len = strlenW(outputparam);
if (outputparam[len-1] == '"') { if (outputparam[len-1] == '"') {
outputparam[len-1]=0x00; outputparam[len-1]=0x00;
len = len - 1; len = len - 1;
} }
memmove(outputparam, &outputparam[1], len-1); memmove(outputparam, &outputparam[1], (len * sizeof(WCHAR))-1);
} }
/* 2. Handle the special case of a $ */ /* 2. Handle the special case of a $ */
if (memchr(firstModifier, '$', modifierLen) != NULL) { if (memchrW(firstModifier, '$', modifierLen) != NULL) {
/* Special Case: Search envar specified in $[envvar] for outputparam /* Special Case: Search envar specified in $[envvar] for outputparam
Note both $ and : are guaranteed otherwise check above would fail */ Note both $ and : are guaranteed otherwise check above would fail */
char *start = strchr(firstModifier, '$') + 1; WCHAR *start = strchrW(firstModifier, '$') + 1;
char *end = strchr(firstModifier, ':'); WCHAR *end = strchrW(firstModifier, ':');
char env[MAX_PATH]; WCHAR env[MAX_PATH];
char fullpath[MAX_PATH]; WCHAR fullpath[MAX_PATH];
/* Extract the env var */ /* Extract the env var */
strncpy(env, start, (end-start)); memcpy(env, start, (end-start) * sizeof(WCHAR));
env[(end-start)] = 0x00; env[(end-start)] = 0x00;
/* If env var not found, return emptry string */ /* If env var not found, return emptry string */
@ -445,15 +446,16 @@ void WCMD_HandleTildaModifiers(char **start, char *forVariable) {
if (GetFullPathName(outputparam, MAX_PATH, fullfilename, NULL) == 0) if (GetFullPathName(outputparam, MAX_PATH, fullfilename, NULL) == 0)
return; return;
exists = GetFileAttributesExA(fullfilename, GetFileExInfoStandard, exists = GetFileAttributesExW(fullfilename, GetFileExInfoStandard,
&fileInfo); &fileInfo);
/* 2. Handle 'a' : Output attributes */ /* 2. Handle 'a' : Output attributes */
if (exists && if (exists &&
memchr(firstModifier, 'a', modifierLen) != NULL) { memchrW(firstModifier, 'a', modifierLen) != NULL) {
WCHAR defaults[] = {'-','-','-','-','-','-','-','-','-','\0'};
doneModifier = TRUE; doneModifier = TRUE;
strcpy(thisoutput, "---------"); strcpyW(thisoutput, defaults);
if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
thisoutput[0]='d'; thisoutput[0]='d';
if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY) if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
@ -469,114 +471,115 @@ void WCMD_HandleTildaModifiers(char **start, char *forVariable) {
/* FIXME: What are 6 and 7? */ /* FIXME: What are 6 and 7? */
if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT) if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
thisoutput[8]='l'; thisoutput[8]='l';
strcat(finaloutput, thisoutput); strcatW(finaloutput, thisoutput);
} }
/* 3. Handle 't' : Date+time */ /* 3. Handle 't' : Date+time */
if (exists && if (exists &&
memchr(firstModifier, 't', modifierLen) != NULL) { memchrW(firstModifier, 't', modifierLen) != NULL) {
SYSTEMTIME systime; SYSTEMTIME systime;
int datelen; int datelen;
doneModifier = TRUE; doneModifier = TRUE;
if (finaloutput[0] != 0x00) strcat(finaloutput, space); if (finaloutput[0] != 0x00) strcatW(finaloutput, space);
/* Format the time */ /* Format the time */
FileTimeToSystemTime(&fileInfo.ftLastWriteTime, &systime); FileTimeToSystemTime(&fileInfo.ftLastWriteTime, &systime);
GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &systime, GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &systime,
NULL, thisoutput, MAX_PATH); NULL, thisoutput, MAX_PATH);
strcat(thisoutput, space); strcatW(thisoutput, space);
datelen = strlen(thisoutput); datelen = strlenW(thisoutput);
GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &systime, GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &systime,
NULL, (thisoutput+datelen), MAX_PATH-datelen); NULL, (thisoutput+datelen), MAX_PATH-datelen);
strcat(finaloutput, thisoutput); strcatW(finaloutput, thisoutput);
} }
/* 4. Handle 'z' : File length */ /* 4. Handle 'z' : File length */
if (exists && if (exists &&
memchr(firstModifier, 'z', modifierLen) != NULL) { memchrW(firstModifier, 'z', modifierLen) != NULL) {
/* FIXME: Output full 64 bit size (sprintf does not support I64 here) */ /* FIXME: Output full 64 bit size (sprintf does not support I64 here) */
ULONG/*64*/ fullsize = /*(fileInfo.nFileSizeHigh << 32) +*/ ULONG/*64*/ fullsize = /*(fileInfo.nFileSizeHigh << 32) +*/
fileInfo.nFileSizeLow; fileInfo.nFileSizeLow;
static const WCHAR fmt[] = {'%','u','\0'};
doneModifier = TRUE; doneModifier = TRUE;
if (finaloutput[0] != 0x00) strcat(finaloutput, space); if (finaloutput[0] != 0x00) strcatW(finaloutput, space);
sprintf(thisoutput, "%u", fullsize); wsprintf(thisoutput, fmt, fullsize);
strcat(finaloutput, thisoutput); strcatW(finaloutput, thisoutput);
} }
/* 4. Handle 's' : Use short paths (File doesn't have to exist) */ /* 4. Handle 's' : Use short paths (File doesn't have to exist) */
if (memchr(firstModifier, 's', modifierLen) != NULL) { if (memchrW(firstModifier, 's', modifierLen) != NULL) {
if (finaloutput[0] != 0x00) strcat(finaloutput, space); if (finaloutput[0] != 0x00) strcatW(finaloutput, space);
/* Don't flag as doneModifier - %~s on its own is processed later */ /* Don't flag as doneModifier - %~s on its own is processed later */
GetShortPathName(outputparam, outputparam, sizeof(outputparam)); GetShortPathName(outputparam, outputparam, sizeof(outputparam));
} }
/* 5. Handle 'f' : Fully qualified path (File doesn't have to exist) */ /* 5. Handle 'f' : Fully qualified path (File doesn't have to exist) */
/* Note this overrides d,p,n,x */ /* Note this overrides d,p,n,x */
if (memchr(firstModifier, 'f', modifierLen) != NULL) { if (memchrW(firstModifier, 'f', modifierLen) != NULL) {
doneModifier = TRUE; doneModifier = TRUE;
if (finaloutput[0] != 0x00) strcat(finaloutput, space); if (finaloutput[0] != 0x00) strcatW(finaloutput, space);
strcat(finaloutput, fullfilename); strcatW(finaloutput, fullfilename);
} else { } else {
char drive[10]; WCHAR drive[10];
char dir[MAX_PATH]; WCHAR dir[MAX_PATH];
char fname[MAX_PATH]; WCHAR fname[MAX_PATH];
char ext[MAX_PATH]; WCHAR ext[MAX_PATH];
BOOL doneFileModifier = FALSE; BOOL doneFileModifier = FALSE;
if (finaloutput[0] != 0x00) strcat(finaloutput, space); if (finaloutput[0] != 0x00) strcatW(finaloutput, space);
/* Split into components */ /* Split into components */
WCMD_splitpath(fullfilename, drive, dir, fname, ext); WCMD_splitpath(fullfilename, drive, dir, fname, ext);
/* 5. Handle 'd' : Drive Letter */ /* 5. Handle 'd' : Drive Letter */
if (memchr(firstModifier, 'd', modifierLen) != NULL) { if (memchrW(firstModifier, 'd', modifierLen) != NULL) {
strcat(finaloutput, drive); strcatW(finaloutput, drive);
doneModifier = TRUE; doneModifier = TRUE;
doneFileModifier = TRUE; doneFileModifier = TRUE;
} }
/* 6. Handle 'p' : Path */ /* 6. Handle 'p' : Path */
if (memchr(firstModifier, 'p', modifierLen) != NULL) { if (memchrW(firstModifier, 'p', modifierLen) != NULL) {
strcat(finaloutput, dir); strcatW(finaloutput, dir);
doneModifier = TRUE; doneModifier = TRUE;
doneFileModifier = TRUE; doneFileModifier = TRUE;
} }
/* 7. Handle 'n' : Name */ /* 7. Handle 'n' : Name */
if (memchr(firstModifier, 'n', modifierLen) != NULL) { if (memchrW(firstModifier, 'n', modifierLen) != NULL) {
strcat(finaloutput, fname); strcatW(finaloutput, fname);
doneModifier = TRUE; doneModifier = TRUE;
doneFileModifier = TRUE; doneFileModifier = TRUE;
} }
/* 8. Handle 'x' : Ext */ /* 8. Handle 'x' : Ext */
if (memchr(firstModifier, 'x', modifierLen) != NULL) { if (memchrW(firstModifier, 'x', modifierLen) != NULL) {
strcat(finaloutput, ext); strcatW(finaloutput, ext);
doneModifier = TRUE; doneModifier = TRUE;
doneFileModifier = TRUE; doneFileModifier = TRUE;
} }
/* If 's' but no other parameter, dump the whole thing */ /* If 's' but no other parameter, dump the whole thing */
if (!doneFileModifier && if (!doneFileModifier &&
memchr(firstModifier, 's', modifierLen) != NULL) { memchrW(firstModifier, 's', modifierLen) != NULL) {
doneModifier = TRUE; doneModifier = TRUE;
if (finaloutput[0] != 0x00) strcat(finaloutput, space); if (finaloutput[0] != 0x00) strcatW(finaloutput, space);
strcat(finaloutput, outputparam); strcatW(finaloutput, outputparam);
} }
} }
} }
/* If No other modifier processed, just add in parameter */ /* If No other modifier processed, just add in parameter */
if (!doneModifier) strcpy(finaloutput, outputparam); if (!doneModifier) strcpyW(finaloutput, outputparam);
/* Finish by inserting the replacement into the string */ /* Finish by inserting the replacement into the string */
pos = strdup (lastModifier+1); pos = WCMD_strdupW(lastModifier+1);
strcpy(*start, finaloutput); strcpyW(*start, finaloutput);
strcat(*start, pos); strcatW(*start, pos);
free(pos); free(pos);
} }
@ -586,16 +589,16 @@ void WCMD_HandleTildaModifiers(char **start, char *forVariable) {
* If there is a leading ':', calls within this batch program * If there is a leading ':', calls within this batch program
* otherwise launches another program. * otherwise launches another program.
*/ */
void WCMD_call (char *command) { void WCMD_call (WCHAR *command) {
/* Run other program if no leading ':' */ /* Run other program if no leading ':' */
if (*command != ':') { if (*command != ':') {
WCMD_run_program(command, 1); WCMD_run_program(command, 1);
} else { } else {
char gotoLabel[MAX_PATH]; WCHAR gotoLabel[MAX_PATH];
strcpy(gotoLabel, param1); strcpyW(gotoLabel, param1);
if (context) { if (context) {

File diff suppressed because it is too large Load Diff

View File

@ -33,13 +33,13 @@
WINE_DEFAULT_DEBUG_CHANNEL(cmd); WINE_DEFAULT_DEBUG_CHANNEL(cmd);
int WCMD_dir_sort (const void *a, const void *b); int WCMD_dir_sort (const void *a, const void *b);
char * WCMD_filesize64 (ULONGLONG free); WCHAR * WCMD_filesize64 (ULONGLONG free);
char * WCMD_strrev (char *buff); WCHAR * WCMD_strrev (WCHAR *buff);
static void WCMD_getfileowner(char *filename, char *owner, int ownerlen); static void WCMD_getfileowner(WCHAR *filename, WCHAR *owner, int ownerlen);
static void WCMD_dir_trailer(char drive); static void WCMD_dir_trailer(WCHAR drive);
extern int echo_mode; extern int echo_mode;
extern char quals[MAX_PATH], param1[MAX_PATH], param2[MAX_PATH]; extern WCHAR quals[MAX_PATH], param1[MAX_PATH], param2[MAX_PATH];
extern DWORD errorlevel; extern DWORD errorlevel;
typedef enum _DISPLAYTIME typedef enum _DISPLAYTIME
@ -67,6 +67,12 @@ static BOOL orderReverse, orderGroupDirs, orderGroupDirsReverse, orderByCol;
static BOOL separator; static BOOL separator;
static ULONG showattrs, attrsbits; static ULONG showattrs, attrsbits;
static const WCHAR dotW[] = {'.','\0'};
static const WCHAR dotdotW[] = {'.','.','\0'};
static const WCHAR starW[] = {'*','\0'};
static const WCHAR slashW[] = {'\\','\0'};
static const WCHAR emptyW[] = {'\0'};
/***************************************************************************** /*****************************************************************************
* WCMD_directory * WCMD_directory
* *
@ -74,34 +80,35 @@ static ULONG showattrs, attrsbits;
* *
*/ */
void WCMD_directory (char *cmd) { void WCMD_directory (WCHAR *cmd) {
char path[MAX_PATH], cwd[MAX_PATH]; WCHAR path[MAX_PATH], cwd[MAX_PATH];
int status, paged_mode; int status, paged_mode;
CONSOLE_SCREEN_BUFFER_INFO consoleInfo; CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
char *p; WCHAR *p;
char string[MAXSTRING]; WCHAR string[MAXSTRING];
int argno = 0; int argno = 0;
int argsProcessed = 0; int argsProcessed = 0;
char *argN = cmd; WCHAR *argN = cmd;
char lastDrive; WCHAR lastDrive;
BOOL trailerReqd = FALSE; BOOL trailerReqd = FALSE;
DIRECTORY_STACK *fullParms = NULL; DIRECTORY_STACK *fullParms = NULL;
DIRECTORY_STACK *prevEntry = NULL; DIRECTORY_STACK *prevEntry = NULL;
DIRECTORY_STACK *thisEntry = NULL; DIRECTORY_STACK *thisEntry = NULL;
char drive[10]; WCHAR drive[10];
char dir[MAX_PATH]; WCHAR dir[MAX_PATH];
char fname[MAX_PATH]; WCHAR fname[MAX_PATH];
char ext[MAX_PATH]; WCHAR ext[MAX_PATH];
static const WCHAR dircmdW[] = {'D','I','R','C','M','D','\0'};
errorlevel = 0; errorlevel = 0;
/* Prefill Quals with (uppercased) DIRCMD env var */ /* Prefill Quals with (uppercased) DIRCMD env var */
if (GetEnvironmentVariable ("DIRCMD", string, sizeof(string))) { if (GetEnvironmentVariable (dircmdW, string, sizeof(string)/sizeof(WCHAR))) {
p = string; p = string;
while ( (*p = toupper(*p)) ) ++p; while ( (*p = toupper(*p)) ) ++p;
strcat(string,quals); strcatW(string,quals);
strcpy(quals, string); strcpyW(quals, string);
} }
byte_total = 0; byte_total = 0;
@ -138,7 +145,7 @@ void WCMD_directory (char *cmd) {
p++; p++;
} }
WINE_TRACE("Processing arg '%c' (in %s)\n", *p, quals); WINE_TRACE("Processing arg '%c' (in %s)\n", *p, wine_dbgstr_w(quals));
switch (*p) { switch (*p) {
case 'P': if (negate) paged_mode = !paged_mode; case 'P': if (negate) paged_mode = !paged_mode;
else paged_mode = TRUE; else paged_mode = TRUE;
@ -188,7 +195,7 @@ void WCMD_directory (char *cmd) {
case 'O': p = p + 1; case 'O': p = p + 1;
if (*p==':') p++; /* Skip optional : */ if (*p==':') p++; /* Skip optional : */
while (*p && *p != '/') { while (*p && *p != '/') {
WINE_TRACE("Processing subparm '%c' (in %s)\n", *p, quals); WINE_TRACE("Processing subparm '%c' (in %s)\n", *p, wine_dbgstr_w(quals));
switch (*p) { switch (*p) {
case 'N': dirOrder = Name; break; case 'N': dirOrder = Name; break;
case 'E': dirOrder = Extension; break; case 'E': dirOrder = Extension; break;
@ -222,7 +229,7 @@ void WCMD_directory (char *cmd) {
p++; p++;
} }
WINE_TRACE("Processing subparm '%c' (in %s)\n", *p, quals); WINE_TRACE("Processing subparm '%c' (in %s)\n", *p, wine_dbgstr_w(quals));
switch (*p) { switch (*p) {
case 'D': mask = FILE_ATTRIBUTE_DIRECTORY; break; case 'D': mask = FILE_ATTRIBUTE_DIRECTORY; break;
case 'H': mask = FILE_ATTRIBUTE_HIDDEN; break; case 'H': mask = FILE_ATTRIBUTE_HIDDEN; break;
@ -276,62 +283,64 @@ void WCMD_directory (char *cmd) {
argno = 0; argno = 0;
argsProcessed = 0; argsProcessed = 0;
argN = cmd; argN = cmd;
GetCurrentDirectory (1024, cwd); GetCurrentDirectory (MAX_PATH, cwd);
strcat(cwd, "\\"); strcatW(cwd, slashW);
/* Loop through all args, calculating full effective directory */ /* Loop through all args, calculating full effective directory */
fullParms = NULL; fullParms = NULL;
prevEntry = NULL; prevEntry = NULL;
while (argN) { while (argN) {
char fullname[MAXSTRING]; WCHAR fullname[MAXSTRING];
char *thisArg = WCMD_parameter (cmd, argno++, &argN); WCHAR *thisArg = WCMD_parameter (cmd, argno++, &argN);
if (argN && argN[0] != '/') { if (argN && argN[0] != '/') {
WINE_TRACE("Found parm '%s'\n", thisArg); WINE_TRACE("Found parm '%s'\n", wine_dbgstr_w(thisArg));
if (thisArg[1] == ':' && thisArg[2] == '\\') { if (thisArg[1] == ':' && thisArg[2] == '\\') {
strcpy(fullname, thisArg); strcpyW(fullname, thisArg);
} else if (thisArg[1] == ':' && thisArg[2] != '\\') { } else if (thisArg[1] == ':' && thisArg[2] != '\\') {
char envvar[4]; WCHAR envvar[4];
sprintf(envvar, "=%c:", thisArg[0]); static const WCHAR envFmt[] = {'=','%','c',':','\0'};
wsprintf(envvar, envFmt, thisArg[0]);
if (!GetEnvironmentVariable(envvar, fullname, MAX_PATH)) { if (!GetEnvironmentVariable(envvar, fullname, MAX_PATH)) {
sprintf(fullname, "%c:", thisArg[0]); static const WCHAR noEnvFmt[] = {'%','c',':','\0'};
wsprintf(fullname, noEnvFmt, thisArg[0]);
} }
strcat(fullname, "\\"); strcatW(fullname, slashW);
strcat(fullname, &thisArg[2]); strcatW(fullname, &thisArg[2]);
} else if (thisArg[0] == '\\') { } else if (thisArg[0] == '\\') {
strncpy(fullname, cwd, 2); memcpy(fullname, cwd, 2 * sizeof(WCHAR));
fullname[2] = 0x00; strcpyW(fullname+2, thisArg);
strcat((fullname+2), thisArg);
} else { } else {
strcpy(fullname, cwd); strcpyW(fullname, cwd);
strcat(fullname, thisArg); strcatW(fullname, thisArg);
} }
WINE_TRACE("Using location '%s'\n", fullname); WINE_TRACE("Using location '%s'\n", wine_dbgstr_w(fullname));
status = GetFullPathName (fullname, sizeof(path), path, NULL); status = GetFullPathName (fullname, sizeof(path)/sizeof(WCHAR), path, NULL);
/* /*
* If the path supplied does not include a wildcard, and the endpoint of the * If the path supplied does not include a wildcard, and the endpoint of the
* path references a directory, we need to list the *contents* of that * path references a directory, we need to list the *contents* of that
* directory not the directory file itself. * directory not the directory file itself.
*/ */
if ((strchr(path, '*') == NULL) && (strchr(path, '%') == NULL)) { if ((strchrW(path, '*') == NULL) && (strchrW(path, '%') == NULL)) {
status = GetFileAttributes (path); status = GetFileAttributes (path);
if ((status != INVALID_FILE_ATTRIBUTES) && (status & FILE_ATTRIBUTE_DIRECTORY)) { if ((status != INVALID_FILE_ATTRIBUTES) && (status & FILE_ATTRIBUTE_DIRECTORY)) {
if (path[strlen(path)-1] == '\\') { if (path[strlenW(path)-1] == '\\') {
strcat (path, "*"); strcatW (path, starW);
} }
else { else {
strcat (path, "\\*"); const WCHAR slashStarW[] = {'\\','*','\0'};
strcatW (path, slashStarW);
} }
} }
} else { } else {
/* Special case wildcard search with no extension (ie parameters ending in '.') as /* Special case wildcard search with no extension (ie parameters ending in '.') as
GetFullPathName strips off the additional '.' */ GetFullPathName strips off the additional '.' */
if (fullname[strlen(fullname)-1] == '.') strcat(path, "."); if (fullname[strlenW(fullname)-1] == '.') strcatW(path, dotW);
} }
WINE_TRACE("Using path '%s'\n", path); WINE_TRACE("Using path '%s'\n", wine_dbgstr_w(path));
thisEntry = (DIRECTORY_STACK *) HeapAlloc(GetProcessHeap(),0,sizeof(DIRECTORY_STACK)); thisEntry = (DIRECTORY_STACK *) HeapAlloc(GetProcessHeap(),0,sizeof(DIRECTORY_STACK));
if (fullParms == NULL) fullParms = thisEntry; if (fullParms == NULL) fullParms = thisEntry;
if (prevEntry != NULL) prevEntry->next = thisEntry; if (prevEntry != NULL) prevEntry->next = thisEntry;
@ -341,15 +350,18 @@ void WCMD_directory (char *cmd) {
/* Split into components */ /* Split into components */
WCMD_splitpath(path, drive, dir, fname, ext); WCMD_splitpath(path, drive, dir, fname, ext);
WINE_TRACE("Path Parts: drive: '%s' dir: '%s' name: '%s' ext:'%s'\n", WINE_TRACE("Path Parts: drive: '%s' dir: '%s' name: '%s' ext:'%s'\n",
drive, dir, fname, ext); wine_dbgstr_w(drive), wine_dbgstr_w(dir),
wine_dbgstr_w(fname), wine_dbgstr_w(ext));
thisEntry->dirName = HeapAlloc(GetProcessHeap(),0,strlen(drive)+strlen(dir)+1); thisEntry->dirName = HeapAlloc(GetProcessHeap(),0,
strcpy(thisEntry->dirName, drive); sizeof(WCHAR) * (strlenW(drive)+strlenW(dir)+1));
strcat(thisEntry->dirName, dir); strcpyW(thisEntry->dirName, drive);
strcatW(thisEntry->dirName, dir);
thisEntry->fileName = HeapAlloc(GetProcessHeap(),0,strlen(fname)+strlen(ext)+1); thisEntry->fileName = HeapAlloc(GetProcessHeap(),0,
strcpy(thisEntry->fileName, fname); sizeof(WCHAR) * (strlenW(fname)+strlenW(ext)+1));
strcat(thisEntry->fileName, ext); strcpyW(thisEntry->fileName, fname);
strcatW(thisEntry->fileName, ext);
} }
} }
@ -359,10 +371,10 @@ void WCMD_directory (char *cmd) {
WINE_TRACE("Inserting default '*'\n"); WINE_TRACE("Inserting default '*'\n");
fullParms = (DIRECTORY_STACK *) HeapAlloc(GetProcessHeap(),0, sizeof(DIRECTORY_STACK)); fullParms = (DIRECTORY_STACK *) HeapAlloc(GetProcessHeap(),0, sizeof(DIRECTORY_STACK));
fullParms->next = NULL; fullParms->next = NULL;
fullParms->dirName = HeapAlloc(GetProcessHeap(),0,(strlen(cwd)+1)); fullParms->dirName = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR) * (strlenW(cwd)+1));
strcpy(fullParms->dirName, cwd); strcpyW(fullParms->dirName, cwd);
fullParms->fileName = HeapAlloc(GetProcessHeap(),0,2); fullParms->fileName = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR) * 2);
strcpy(fullParms->fileName, "*"); strcpyW(fullParms->fileName, starW);
} }
lastDrive = '?'; lastDrive = '?';
@ -385,10 +397,10 @@ void WCMD_directory (char *cmd) {
lastDrive = toupper(thisEntry->dirName[0]); lastDrive = toupper(thisEntry->dirName[0]);
if (!bare) { if (!bare) {
char drive[3]; WCHAR drive[3];
WINE_TRACE("Writing volume for '%c:'\n", thisEntry->dirName[0]); WINE_TRACE("Writing volume for '%c:'\n", thisEntry->dirName[0]);
strncpy(drive, thisEntry->dirName, 2); memcpy(drive, thisEntry->dirName, 2 * sizeof(WCHAR));
drive[2] = 0x00; drive[2] = 0x00;
status = WCMD_volume (0, drive); status = WCMD_volume (0, drive);
trailerReqd = TRUE; trailerReqd = TRUE;
@ -398,7 +410,8 @@ void WCMD_directory (char *cmd) {
} }
} }
} else { } else {
if (!bare) WCMD_output ("\n\n"); static const WCHAR newLine2[] = {'\n','\n','\0'};
if (!bare) WCMD_output (newLine2);
} }
/* Clear any errors from previous invocations, and process it */ /* Clear any errors from previous invocations, and process it */
@ -436,8 +449,8 @@ exit:
static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int level) { static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int level) {
char string[1024], datestring[32], timestring[32]; WCHAR string[1024], datestring[32], timestring[32];
char real_path[MAX_PATH]; WCHAR real_path[MAX_PATH];
WIN32_FIND_DATA *fd; WIN32_FIND_DATA *fd;
FILETIME ft; FILETIME ft;
SYSTEMTIME st; SYSTEMTIME st;
@ -450,6 +463,14 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
int concurrentDirs = 0; int concurrentDirs = 0;
BOOL done_header = FALSE; BOOL done_header = FALSE;
static const WCHAR fmtDir[] = {'%','1','0','s',' ',' ','%','8','s',' ',' ',
'<','D','I','R','>',' ',' ',' ',' ',' ',' ',' ',' ',' ','\0'};
static const WCHAR fmtFile[] = {'%','1','0','s',' ',' ','%','8','s',' ',' ',
' ',' ','%','1','0','s',' ',' ','\0'};
static const WCHAR fmt2[] = {'%','-','1','3','s','\0'};
static const WCHAR fmt3[] = {'%','-','2','3','s','\0'};
static const WCHAR fmt4[] = {'%','s','\0'};
static const WCHAR fmt5[] = {'%','s','%','s','\0'};
dir_count = 0; dir_count = 0;
file_count = 0; file_count = 0;
@ -463,15 +484,15 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
mirrors what windows does */ mirrors what windows does */
parms = inputparms; parms = inputparms;
fd = HeapAlloc(GetProcessHeap(),0,sizeof(WIN32_FIND_DATA)); fd = HeapAlloc(GetProcessHeap(),0,sizeof(WIN32_FIND_DATA));
while (parms && strcmp(inputparms->dirName, parms->dirName) == 0) { while (parms && strcmpW(inputparms->dirName, parms->dirName) == 0) {
concurrentDirs++; concurrentDirs++;
/* Work out the full path + filename */ /* Work out the full path + filename */
strcpy(real_path, parms->dirName); strcpyW(real_path, parms->dirName);
strcat(real_path, parms->fileName); strcatW(real_path, parms->fileName);
/* Load all files into an in memory structure */ /* Load all files into an in memory structure */
WINE_TRACE("Looking for matches to '%s'\n", real_path); WINE_TRACE("Looking for matches to '%s'\n", wine_dbgstr_w(real_path));
hff = FindFirstFile (real_path, (fd+entry_count)); hff = FindFirstFile (real_path, (fd+entry_count));
if (hff != INVALID_HANDLE_VALUE) { if (hff != INVALID_HANDLE_VALUE) {
do { do {
@ -482,7 +503,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
/* Keep running track of longest filename for wide output */ /* Keep running track of longest filename for wide output */
if (wide || orderByCol) { if (wide || orderByCol) {
int tmpLen = strlen((fd+(entry_count-1))->cFileName) + 3; int tmpLen = strlenW((fd+(entry_count-1))->cFileName) + 3;
if ((fd+(entry_count-1))->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) tmpLen = tmpLen + 2; if ((fd+(entry_count-1))->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) tmpLen = tmpLen + 2;
if (tmpLen > widest) widest = tmpLen; if (tmpLen > widest) widest = tmpLen;
} }
@ -499,14 +520,16 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
} }
/* Work out the actual current directory name without a trailing \ */ /* Work out the actual current directory name without a trailing \ */
strcpy(real_path, parms->dirName); strcpyW(real_path, parms->dirName);
real_path[strlen(parms->dirName)-1] = 0x00; real_path[strlenW(parms->dirName)-1] = 0x00;
/* Output the results */ /* Output the results */
if (!bare) { if (!bare) {
if (level != 0 && (entry_count > 0)) WCMD_output (newline); if (level != 0 && (entry_count > 0)) WCMD_output (newline);
if (!recurse || ((entry_count > 0) && done_header==FALSE)) { if (!recurse || ((entry_count > 0) && done_header==FALSE)) {
WCMD_output ("Directory of %s\n\n", real_path); static const WCHAR headerW[] = {'D','i','r','e','c','t','o','r','y',' ','o','f',
' ','%','s','\n','\n','\0'};
WCMD_output (headerW, real_path);
done_header = TRUE; done_header = TRUE;
} }
} }
@ -536,7 +559,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
for (rows=0; rows<numRows; rows++) { for (rows=0; rows<numRows; rows++) {
BOOL addNewLine = TRUE; BOOL addNewLine = TRUE;
for (cols=0; cols<numCols; cols++) { for (cols=0; cols<numCols; cols++) {
char username[24]; WCHAR username[24];
/* Work out the index of the entry being pointed to */ /* Work out the index of the entry being pointed to */
if (orderByCol) { if (orderByCol) {
@ -549,15 +572,15 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
/* /L convers all names to lower case */ /* /L convers all names to lower case */
if (lower) { if (lower) {
char *p = (fd+i)->cFileName; WCHAR *p = (fd+i)->cFileName;
while ( (*p = tolower(*p)) ) ++p; while ( (*p = tolower(*p)) ) ++p;
} }
/* /Q gets file ownership information */ /* /Q gets file ownership information */
if (usernames) { if (usernames) {
lstrcpy (string, inputparms->dirName); strcpyW (string, inputparms->dirName);
lstrcat (string, (fd+i)->cFileName); strcatW (string, (fd+i)->cFileName);
WCMD_getfileowner(string, username, sizeof(username)); WCMD_getfileowner(string, username, sizeof(username)/sizeof(WCHAR));
} }
if (dirTime == Written) { if (dirTime == Written) {
@ -569,20 +592,22 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
} }
FileTimeToSystemTime (&ft, &st); FileTimeToSystemTime (&ft, &st);
GetDateFormat (0, DATE_SHORTDATE, &st, NULL, datestring, GetDateFormat (0, DATE_SHORTDATE, &st, NULL, datestring,
sizeof(datestring)); sizeof(datestring)/sizeof(WCHAR));
GetTimeFormat (0, TIME_NOSECONDS, &st, GetTimeFormat (0, TIME_NOSECONDS, &st,
NULL, timestring, sizeof(timestring)); NULL, timestring, sizeof(timestring)/sizeof(WCHAR));
if (wide) { if (wide) {
tmp_width = cur_width; tmp_width = cur_width;
if ((fd+i)->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if ((fd+i)->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
WCMD_output ("[%s]", (fd+i)->cFileName); static const WCHAR fmt[] = {'[','%','s',']','\0'};
WCMD_output (fmt, (fd+i)->cFileName);
dir_count++; dir_count++;
tmp_width = tmp_width + strlen((fd+i)->cFileName) + 2; tmp_width = tmp_width + strlenW((fd+i)->cFileName) + 2;
} else { } else {
WCMD_output ("%s", (fd+i)->cFileName); static const WCHAR fmt[] = {'%','s','\0'};
tmp_width = tmp_width + strlen((fd+i)->cFileName) ; WCMD_output (fmt, (fd+i)->cFileName);
tmp_width = tmp_width + strlenW((fd+i)->cFileName) ;
file_count++; file_count++;
file_size.u.LowPart = (fd+i)->nFileSizeLow; file_size.u.LowPart = (fd+i)->nFileSizeLow;
file_size.u.HighPart = (fd+i)->nFileSizeHigh; file_size.u.HighPart = (fd+i)->nFileSizeHigh;
@ -593,21 +618,22 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
if ((cur_width + widest) > max_width) { if ((cur_width + widest) > max_width) {
cur_width = 0; cur_width = 0;
} else { } else {
WCMD_output ("%*.s", (tmp_width - cur_width) ,""); static const WCHAR fmt[] = {'%','*','.','s','\0'};
WCMD_output (fmt, (tmp_width - cur_width), emptyW);
} }
} else if ((fd+i)->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { } else if ((fd+i)->dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
dir_count++; dir_count++;
if (!bare) { if (!bare) {
WCMD_output ("%10s %8s <DIR> ", datestring, timestring); WCMD_output (fmtDir, datestring, timestring);
if (shortname) WCMD_output ("%-13s", (fd+i)->cAlternateFileName); if (shortname) WCMD_output (fmt2, (fd+i)->cAlternateFileName);
if (usernames) WCMD_output ("%-23s", username); if (usernames) WCMD_output (fmt3, username);
WCMD_output("%s",(fd+i)->cFileName); WCMD_output(fmt4,(fd+i)->cFileName);
} else { } else {
if (!((strcmp((fd+i)->cFileName, ".") == 0) || if (!((strcmpW((fd+i)->cFileName, dotW) == 0) ||
(strcmp((fd+i)->cFileName, "..") == 0))) { (strcmpW((fd+i)->cFileName, dotdotW) == 0))) {
WCMD_output ("%s%s", recurse?inputparms->dirName:"", (fd+i)->cFileName); WCMD_output (fmt5, recurse?inputparms->dirName:emptyW, (fd+i)->cFileName);
} else { } else {
addNewLine = FALSE; addNewLine = FALSE;
} }
@ -619,13 +645,13 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
file_size.u.HighPart = (fd+i)->nFileSizeHigh; file_size.u.HighPart = (fd+i)->nFileSizeHigh;
byte_count.QuadPart += file_size.QuadPart; byte_count.QuadPart += file_size.QuadPart;
if (!bare) { if (!bare) {
WCMD_output ("%10s %8s %10s ", datestring, timestring, WCMD_output (fmtFile, datestring, timestring,
WCMD_filesize64(file_size.QuadPart)); WCMD_filesize64(file_size.QuadPart));
if (shortname) WCMD_output ("%-13s", (fd+i)->cAlternateFileName); if (shortname) WCMD_output (fmt2, (fd+i)->cAlternateFileName);
if (usernames) WCMD_output ("%-23s", username); if (usernames) WCMD_output (fmt3, username);
WCMD_output("%s",(fd+i)->cFileName); WCMD_output(fmt4,(fd+i)->cFileName);
} else { } else {
WCMD_output ("%s%s", recurse?inputparms->dirName:"", (fd+i)->cFileName); WCMD_output (fmt5, recurse?inputparms->dirName:emptyW, (fd+i)->cFileName);
} }
} }
} }
@ -635,10 +661,14 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
if (!bare) { if (!bare) {
if (file_count == 1) { if (file_count == 1) {
WCMD_output (" 1 file %25s bytes\n", WCMD_filesize64 (byte_count.QuadPart)); static const WCHAR fmt[] = {' ',' ',' ',' ',' ',' ',' ','1',' ','f','i','l','e',' ',
'%','2','5','s',' ','b','y','t','e','s','\n','\0'};
WCMD_output (fmt, WCMD_filesize64 (byte_count.QuadPart));
} }
else { else {
WCMD_output ("%8d files %24s bytes\n", file_count, WCMD_filesize64 (byte_count.QuadPart)); static const WCHAR fmt[] = {'%','8','d',' ','f','i','l','e','s',' ','%','2','4','s',
' ','b','y','t','e','s','\n','\0'};
WCMD_output (fmt, file_count, WCMD_filesize64 (byte_count.QuadPart));
} }
} }
byte_total = byte_total + byte_count.QuadPart; byte_total = byte_total + byte_count.QuadPart;
@ -646,8 +676,15 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
dir_total = dir_total + dir_count; dir_total = dir_total + dir_count;
if (!bare && !recurse) { if (!bare && !recurse) {
if (dir_count == 1) WCMD_output ("%8d directory ", 1); if (dir_count == 1) {
else WCMD_output ("%8d directories", dir_count); static const WCHAR fmt[] = {'%','8','d',' ','d','i','r','e','c','t','o','r','y',
' ',' ',' ',' ',' ',' ',' ',' ',' ','\0'};
WCMD_output (fmt, 1);
} else {
static const WCHAR fmt[] = {'%','8','d',' ','d','i','r','e','c','t','o','r','i',
'e','s','\0'};
WCMD_output (fmt, dir_count);
}
} }
} }
HeapFree(GetProcessHeap(),0,fd); HeapFree(GetProcessHeap(),0,fd);
@ -659,16 +696,16 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
WIN32_FIND_DATA finddata; WIN32_FIND_DATA finddata;
/* Build path to search */ /* Build path to search */
strcpy(string, inputparms->dirName); strcpyW(string, inputparms->dirName);
strcat(string, "*"); strcatW(string, starW);
WINE_TRACE("Recursive, looking for '%s'\n", string); WINE_TRACE("Recursive, looking for '%s'\n", wine_dbgstr_w(string));
hff = FindFirstFile (string, &finddata); hff = FindFirstFile (string, &finddata);
if (hff != INVALID_HANDLE_VALUE) { if (hff != INVALID_HANDLE_VALUE) {
do { do {
if ((finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) && if ((finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
(strcmp(finddata.cFileName, "..") != 0) && (strcmpW(finddata.cFileName, dotdotW) != 0) &&
(strcmp(finddata.cFileName, ".") != 0)) { (strcmpW(finddata.cFileName, dotW) != 0)) {
DIRECTORY_STACK *thisDir; DIRECTORY_STACK *thisDir;
int dirsToCopy = concurrentDirs; int dirsToCopy = concurrentDirs;
@ -679,10 +716,10 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
dirsToCopy--; dirsToCopy--;
/* Work out search parameter in sub dir */ /* Work out search parameter in sub dir */
strcpy (string, inputparms->dirName); strcpyW (string, inputparms->dirName);
strcat (string, finddata.cFileName); strcatW (string, finddata.cFileName);
strcat (string, "\\"); strcatW (string, slashW);
WINE_TRACE("Recursive, Adding to search list '%s'\n", string); WINE_TRACE("Recursive, Adding to search list '%s'\n", wine_dbgstr_w(string));
/* Allocate memory, add to list */ /* Allocate memory, add to list */
thisDir = (DIRECTORY_STACK *) HeapAlloc(GetProcessHeap(),0,sizeof(DIRECTORY_STACK)); thisDir = (DIRECTORY_STACK *) HeapAlloc(GetProcessHeap(),0,sizeof(DIRECTORY_STACK));
@ -690,10 +727,12 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
if (lastEntry != NULL) lastEntry->next = thisDir; if (lastEntry != NULL) lastEntry->next = thisDir;
lastEntry = thisDir; lastEntry = thisDir;
thisDir->next = NULL; thisDir->next = NULL;
thisDir->dirName = HeapAlloc(GetProcessHeap(),0,(strlen(string)+1)); thisDir->dirName = HeapAlloc(GetProcessHeap(),0,
strcpy(thisDir->dirName, string); sizeof(WCHAR) * (strlenW(string)+1));
thisDir->fileName = HeapAlloc(GetProcessHeap(),0,(strlen(parms->fileName)+1)); strcpyW(thisDir->dirName, string);
strcpy(thisDir->fileName, parms->fileName); thisDir->fileName = HeapAlloc(GetProcessHeap(),0,
sizeof(WCHAR) * (strlenW(parms->fileName)+1));
strcpyW(thisDir->fileName, parms->fileName);
parms = parms->next; parms = parms->next;
} }
} }
@ -727,17 +766,17 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
/***************************************************************************** /*****************************************************************************
* WCMD_filesize64 * WCMD_filesize64
* *
* Convert a 64-bit number into a character string, with commas every three digits. * Convert a 64-bit number into a WCHARacter string, with commas every three digits.
* Result is returned in a static string overwritten with each call. * Result is returned in a static string overwritten with each call.
* FIXME: There must be a better algorithm! * FIXME: There must be a better algorithm!
*/ */
char * WCMD_filesize64 (ULONGLONG n) { WCHAR * WCMD_filesize64 (ULONGLONG n) {
ULONGLONG q; ULONGLONG q;
unsigned int r, i; unsigned int r, i;
char *p; WCHAR *p;
static char buff[32]; static WCHAR buff[32];
p = buff; p = buff;
i = -3; i = -3;
@ -756,15 +795,15 @@ char * WCMD_filesize64 (ULONGLONG n) {
/***************************************************************************** /*****************************************************************************
* WCMD_strrev * WCMD_strrev
* *
* Reverse a character string in-place (strrev() is not available under unixen :-( ). * Reverse a WCHARacter string in-place (strrev() is not available under unixen :-( ).
*/ */
char * WCMD_strrev (char *buff) { WCHAR * WCMD_strrev (WCHAR *buff) {
int r, i; int r, i;
char b; WCHAR b;
r = lstrlen (buff); r = strlenW (buff);
for (i=0; i<r/2; i++) { for (i=0; i<r/2; i++) {
b = buff[i]; b = buff[i];
buff[i] = buff[r-i-1]; buff[i] = buff[r-i-1];
@ -799,7 +838,7 @@ int WCMD_dir_sort (const void *a, const void *b)
/* Order by Name: */ /* Order by Name: */
} else if (dirOrder == Name) { } else if (dirOrder == Name) {
result = lstrcmpi(filea->cFileName, fileb->cFileName); result = lstrcmpiW(filea->cFileName, fileb->cFileName);
/* Order by Size: */ /* Order by Size: */
} else if (dirOrder == Size) { } else if (dirOrder == Size) {
@ -837,16 +876,16 @@ int WCMD_dir_sort (const void *a, const void *b)
/* Order by Extension: (Takes into account which date (/T option) */ /* Order by Extension: (Takes into account which date (/T option) */
} else if (dirOrder == Extension) { } else if (dirOrder == Extension) {
char drive[10]; WCHAR drive[10];
char dir[MAX_PATH]; WCHAR dir[MAX_PATH];
char fname[MAX_PATH]; WCHAR fname[MAX_PATH];
char extA[MAX_PATH]; WCHAR extA[MAX_PATH];
char extB[MAX_PATH]; WCHAR extB[MAX_PATH];
/* Split into components */ /* Split into components */
WCMD_splitpath(filea->cFileName, drive, dir, fname, extA); WCMD_splitpath(filea->cFileName, drive, dir, fname, extA);
WCMD_splitpath(fileb->cFileName, drive, dir, fname, extB); WCMD_splitpath(fileb->cFileName, drive, dir, fname, extB);
result = lstrcmpi(extA, extB); result = lstrcmpiW(extA, extB);
} }
if (orderReverse) result = -result; if (orderReverse) result = -result;
@ -856,14 +895,14 @@ int WCMD_dir_sort (const void *a, const void *b)
/***************************************************************************** /*****************************************************************************
* WCMD_getfileowner * WCMD_getfileowner
* *
* Reverse a character string in-place (strrev() is not available under unixen :-( ). * Reverse a WCHARacter string in-place (strrev() is not available under unixen :-( ).
*/ */
void WCMD_getfileowner(char *filename, char *owner, int ownerlen) { void WCMD_getfileowner(WCHAR *filename, WCHAR *owner, int ownerlen) {
ULONG sizeNeeded = 0; ULONG sizeNeeded = 0;
DWORD rc; DWORD rc;
char name[MAXSTRING]; WCHAR name[MAXSTRING];
char domain[MAXSTRING]; WCHAR domain[MAXSTRING];
/* In case of error, return empty string */ /* In case of error, return empty string */
*owner = 0x00; *owner = 0x00;
@ -899,7 +938,8 @@ void WCMD_getfileowner(char *filename, char *owner, int ownerlen) {
/* Convert to a username */ /* Convert to a username */
if (LookupAccountSid(NULL, pSID, name, &nameLen, domain, &domainLen, &nameuse)) { if (LookupAccountSid(NULL, pSID, name, &nameLen, domain, &domainLen, &nameuse)) {
snprintf(owner, ownerlen, "%s%c%s", domain, '\\', name); static const WCHAR fmt[] = {'%','s','%','c','%','s','\0'};
snprintfW(owner, ownerlen, fmt, domain, '\\', name);
} }
HeapFree(GetProcessHeap(),0,secBuffer); HeapFree(GetProcessHeap(),0,secBuffer);
} }
@ -911,23 +951,30 @@ void WCMD_getfileowner(char *filename, char *owner, int ownerlen) {
* *
* Print out the trailer for the supplied drive letter * Print out the trailer for the supplied drive letter
*/ */
static void WCMD_dir_trailer(char drive) { static void WCMD_dir_trailer(WCHAR drive) {
ULARGE_INTEGER avail, total, freebytes; ULARGE_INTEGER avail, total, freebytes;
DWORD status; DWORD status;
char driveName[4] = "c:\\"; WCHAR driveName[4] = {'c',':','\\','\0'};
driveName[0] = drive; driveName[0] = drive;
status = GetDiskFreeSpaceEx (driveName, &avail, &total, &freebytes); status = GetDiskFreeSpaceEx (driveName, &avail, &total, &freebytes);
WINE_TRACE("Writing trailer for '%s' gave %d(%d)\n", driveName, status, GetLastError()); WINE_TRACE("Writing trailer for '%s' gave %d(%d)\n", wine_dbgstr_w(driveName),
status, GetLastError());
if (errorlevel==0 && !bare) { if (errorlevel==0 && !bare) {
if (recurse) { if (recurse) {
WCMD_output ("\n Total files listed:\n%8d files%25s bytes\n", static const WCHAR fmt1[] = {'\n',' ',' ',' ',' ',' ','T','o','t','a','l',' ','f','i','l','e','s',
file_total, WCMD_filesize64 (byte_total)); ' ','l','i','s','t','e','d',':','\n','%','8','d',' ','f','i','l','e',
WCMD_output ("%8d directories %18s bytes free\n\n", 's','%','2','5','s',' ','b','y','t','e','s','\n','\0'};
dir_total, WCMD_filesize64 (freebytes.QuadPart)); static const WCHAR fmt2[] = {'%','8','d',' ','d','i','r','e','c','t','o','r','i','e','s',' ','%',
'1','8','s',' ','b','y','t','e','s',' ','f','r','e','e','\n','\n',
'\0'};
WCMD_output (fmt1, file_total, WCMD_filesize64 (byte_total));
WCMD_output (fmt2, dir_total, WCMD_filesize64 (freebytes.QuadPart));
} else { } else {
WCMD_output (" %18s bytes free\n\n", WCMD_filesize64 (freebytes.QuadPart)); static const WCHAR fmt[] = {' ','%','1','8','s',' ','b','y','t','e','s',' ','f','r','e','e',
'\n','\n','\0'};
WCMD_output (fmt, WCMD_filesize64 (freebytes.QuadPart));
} }
} }
} }

View File

@ -28,71 +28,74 @@
#include <ctype.h> #include <ctype.h>
#include <wine/unicode.h> #include <wine/unicode.h>
void WCMD_assoc (char *, BOOL); void WCMD_assoc (WCHAR *, BOOL);
void WCMD_batch (char *, char *, int, char *, HANDLE); void WCMD_batch (WCHAR *, WCHAR *, int, WCHAR *, HANDLE);
void WCMD_call (char *command); void WCMD_call (WCHAR *command);
void WCMD_change_tty (void); void WCMD_change_tty (void);
void WCMD_clear_screen (void); void WCMD_clear_screen (void);
void WCMD_color (void); void WCMD_color (void);
void WCMD_copy (void); void WCMD_copy (void);
void WCMD_create_dir (void); void WCMD_create_dir (void);
BOOL WCMD_delete (char *, BOOL); BOOL WCMD_delete (WCHAR *, BOOL);
void WCMD_directory (char *); void WCMD_directory (WCHAR *);
void WCMD_echo (const char *); void WCMD_echo (const WCHAR *);
void WCMD_endlocal (void); void WCMD_endlocal (void);
void WCMD_enter_paged_mode(const char *); void WCMD_enter_paged_mode(const WCHAR *);
void WCMD_exit (void); void WCMD_exit (void);
void WCMD_for (char *); void WCMD_for (WCHAR *);
void WCMD_give_help (char *command); void WCMD_give_help (WCHAR *command);
void WCMD_goto (void); void WCMD_goto (void);
void WCMD_if (char *); void WCMD_if (WCHAR *);
void WCMD_leave_paged_mode(void); void WCMD_leave_paged_mode(void);
void WCMD_more (char *); void WCMD_more (WCHAR *);
void WCMD_move (void); void WCMD_move (void);
void WCMD_output (const char *format, ...); void WCMD_output (const WCHAR *format, ...);
void WCMD_output_asis (const char *message); void WCMD_output_asis (const WCHAR *message);
void WCMD_parse (char *s, char *q, char *p1, char *p2); void WCMD_parse (WCHAR *s, WCHAR *q, WCHAR *p1, WCHAR *p2);
void WCMD_pause (void); void WCMD_pause (void);
void WCMD_pipe (char *command); void WCMD_pipe (WCHAR *command);
void WCMD_popd (void); void WCMD_popd (void);
void WCMD_print_error (void); void WCMD_print_error (void);
void WCMD_process_command (char *command); void WCMD_process_command (WCHAR *command);
void WCMD_pushd (char *); void WCMD_pushd (WCHAR *);
int WCMD_read_console (char *string, int str_len); int WCMD_read_console (WCHAR *string, int str_len);
void WCMD_remove_dir (char *command); void WCMD_remove_dir (WCHAR *command);
void WCMD_rename (void); void WCMD_rename (void);
void WCMD_run_program (char *command, int called); void WCMD_run_program (WCHAR *command, int called);
void WCMD_setlocal (const char *command); void WCMD_setlocal (const WCHAR *command);
void WCMD_setshow_attrib (void); void WCMD_setshow_attrib (void);
void WCMD_setshow_date (void); void WCMD_setshow_date (void);
void WCMD_setshow_default (char *command); void WCMD_setshow_default (WCHAR *command);
void WCMD_setshow_env (char *command); void WCMD_setshow_env (WCHAR *command);
void WCMD_setshow_path (char *command); void WCMD_setshow_path (WCHAR *command);
void WCMD_setshow_prompt (void); void WCMD_setshow_prompt (void);
void WCMD_setshow_time (void); void WCMD_setshow_time (void);
void WCMD_shift (char *command); void WCMD_shift (WCHAR *command);
void WCMD_show_prompt (void); void WCMD_show_prompt (void);
void WCMD_title (char *); void WCMD_title (WCHAR *);
void WCMD_type (char *); void WCMD_type (WCHAR *);
void WCMD_verify (char *command); void WCMD_verify (WCHAR *command);
void WCMD_version (void); void WCMD_version (void);
int WCMD_volume (int mode, char *command); int WCMD_volume (int mode, WCHAR *command);
char *WCMD_fgets (char *s, int n, HANDLE stream); WCHAR *WCMD_fgets (WCHAR *s, int n, HANDLE stream);
char *WCMD_parameter (char *s, int n, char **where); WCHAR *WCMD_parameter (WCHAR *s, int n, WCHAR **where);
char *WCMD_strtrim_leading_spaces (char *string); WCHAR *WCMD_strtrim_leading_spaces (WCHAR *string);
void WCMD_strtrim_trailing_spaces (char *string); void WCMD_strtrim_trailing_spaces (WCHAR *string);
void WCMD_opt_s_strip_quotes(char *cmd); void WCMD_opt_s_strip_quotes(WCHAR *cmd);
void WCMD_HandleTildaModifiers(char **start, char *forVariable); void WCMD_HandleTildaModifiers(WCHAR **start, WCHAR *forVariable);
BOOL WCMD_ask_confirm (char *message, BOOL showSureText, BOOL *optionAll); BOOL WCMD_ask_confirm (WCHAR *message, BOOL showSureText, BOOL *optionAll);
void WCMD_splitpath(const CHAR* path, CHAR* drv, CHAR* dir, CHAR* name, CHAR* ext); void WCMD_splitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext);
char *WCMD_LoadMessage(UINT id); WCHAR *WCMD_LoadMessage(UINT id);
WCHAR *WCMD_strdupW(WCHAR *input);
BOOL WCMD_ReadFile(const HANDLE hIn, WCHAR *intoBuf, const DWORD maxChars,
LPDWORD charsRead, const LPOVERLAPPED unused);
/* Data structure to hold context when executing batch files */ /* Data structure to hold context when executing batch files */
typedef struct { typedef struct {
char *command; /* The command which invoked the batch file */ WCHAR *command; /* The command which invoked the batch file */
HANDLE h; /* Handle to the open batch file */ HANDLE h; /* Handle to the open batch file */
int shift_count[10]; /* Offset in terms of shifts for %0 - %9 */ int shift_count[10]; /* Offset in terms of shifts for %0 - %9 */
void *prev_context; /* Pointer to the previous context block */ void *prev_context; /* Pointer to the previous context block */
@ -106,7 +109,7 @@ struct env_stack
struct env_stack *next; struct env_stack *next;
union { union {
int stackdepth; /* Only used for pushd and popd */ int stackdepth; /* Only used for pushd and popd */
char cwd; /* Only used for set/endlocal */ WCHAR cwd; /* Only used for set/endlocal */
} u; } u;
WCHAR *strings; WCHAR *strings;
}; };
@ -116,8 +119,8 @@ struct env_stack
typedef struct _DIRECTORY_STACK typedef struct _DIRECTORY_STACK
{ {
struct _DIRECTORY_STACK *next; struct _DIRECTORY_STACK *next;
char *dirName; WCHAR *dirName;
char *fileName; WCHAR *fileName;
} DIRECTORY_STACK; } DIRECTORY_STACK;
#endif /* !RC_INVOKED */ #endif /* !RC_INVOKED */
@ -181,9 +184,9 @@ typedef struct _DIRECTORY_STACK
#define WCMD_EXIT 44 #define WCMD_EXIT 44
/* Some standard messages */ /* Some standard messages */
extern const char newline[]; extern const WCHAR newline[];
extern const char version_string[]; extern WCHAR anykey[];
extern const char anykey[]; extern WCHAR version_string[];
/* Translated messages */ /* Translated messages */
#define WCMD_CONFIRM 1001 #define WCMD_CONFIRM 1001
@ -215,6 +218,11 @@ extern const char anykey[];
#define WCMD_ARGERR 1027 #define WCMD_ARGERR 1027
#define WCMD_VOLUMEDETAIL 1028 #define WCMD_VOLUMEDETAIL 1028
#define WCMD_VOLUMEPROMPT 1029 #define WCMD_VOLUMEPROMPT 1029
#define WCMD_NOPATH 1030
#define WCMD_ANYKEY 1031
#define WCMD_CONSTITLE 1032
#define WCMD_VERSION 1033
/* msdn specified max for Win XP */ /* msdn specified max for Win XP */
#define MAXSTRING 8192 #define MAXSTRING 8192

File diff suppressed because it is too large Load Diff