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_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_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_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_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_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_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_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_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_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_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_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_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_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_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@
MODULE = cmd.exe
APPMODE = -mconsole
EXTRADEFS = -DUNICODE
IMPORTS = shell32 user32 advapi32 kernel32
C_SRCS = \

View File

@ -260,4 +260,8 @@ type HELP <opdracht> voor meer informatie over bovengenoemde opdrachten\n"
WCMD_ARGERR, "Parameter error\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_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_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_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_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_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_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_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_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_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_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_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_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_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"
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 DWORD errorlevel;
@ -41,30 +41,31 @@ extern DWORD errorlevel;
* 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
HANDLE h = INVALID_HANDLE_VALUE;
char string[MAXSTRING];
char extension_batch[][WCMD_BATCH_EXT_SIZE] = {".bat",".cmd"};
char extension_exe[WCMD_BATCH_EXT_SIZE] = ".exe";
WCHAR string[MAXSTRING];
static const WCHAR extension_batch[][WCMD_BATCH_EXT_SIZE] = {{'.','b','a','t','\0'},
{'.','c','m','d','\0'}};
static const WCHAR extension_exe[WCMD_BATCH_EXT_SIZE] = {'.','e','x','e','\0'};
unsigned int i;
BATCH_CONTEXT *prev_context;
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++) {
strcpy (string, file);
CharLower (string);
if (strstr (string, extension_batch[i]) == NULL) strcat (string, extension_batch[i]);
h = CreateFile (string, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
strcpyW (string, file);
CharLower (string);
if (strstrW (string, extension_batch[i]) == NULL) strcatW (string, extension_batch[i]);
h = CreateFile (string, GENERIC_READ, FILE_SHARE_READ,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
}
if (h == INVALID_HANDLE_VALUE) {
strcpy (string, file);
strcpyW (string, file);
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,
NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
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 (startLabel) {
strcpy(param1, startLabel);
strcpyW(param1, startLabel);
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)) {
if (strlen(string) == MAXSTRING -1) {
if (strlenW(string) == MAXSTRING -1) {
WCMD_output_asis( WCMD_LoadMessage(WCMD_TRUNCATEDLINE));
WCMD_output_asis( string);
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.
*/
char *WCMD_parameter (char *s, int n, char **where) {
WCHAR *WCMD_parameter (WCHAR *s, int n, WCHAR **where) {
int i = 0;
static char param[MAX_PATH];
char *p;
static WCHAR param[MAX_PATH];
WCHAR *p;
if (where != NULL) *where = NULL;
p = param;
@ -211,32 +212,32 @@ char *WCMD_parameter (char *s, int n, char **where) {
* 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;
BOOL status;
char *p;
WCHAR *p;
p = s;
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 (*s == '\n') bytes = 0;
else if (*s != '\r') {
s++;
n--;
noChars--;
}
*s = '\0';
} while ((bytes == 1) && (n > 1));
} while ((bytes == 1) && (noChars > 1));
return p;
}
/* 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 CHAR* p; /* search pointer */
const CHAR* s; /* copy pointer */
const WCHAR* end; /* end of processed string */
const WCHAR* p; /* search pointer */
const WCHAR* s; /* copy pointer */
/* extract drive name */
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:
*
* 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
* where XXX = %~a (just ~)
* %~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
* 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
const char validmodifiers[NUMMODIFIERS] = {
static const WCHAR validmodifiers[NUMMODIFIERS] = {
'~', 'f', 'd', 'p', 'n', 'x', 's', 'a', 't', 'z', '$'
};
const char space[] = " ";
static const WCHAR space[] = {' ', '\0'};
WIN32_FILE_ATTRIBUTE_DATA fileInfo;
char outputparam[MAX_PATH];
char finaloutput[MAX_PATH];
char fullfilename[MAX_PATH];
char thisoutput[MAX_PATH];
char *pos = *start+1;
char *firstModifier = pos;
char *lastModifier = NULL;
WCHAR outputparam[MAX_PATH];
WCHAR finaloutput[MAX_PATH];
WCHAR fullfilename[MAX_PATH];
WCHAR thisoutput[MAX_PATH];
WCHAR *pos = *start+1;
WCHAR *firstModifier = pos;
WCHAR *lastModifier = NULL;
int modifierLen = 0;
BOOL finished = FALSE;
int i = 0;
@ -340,10 +341,10 @@ void WCMD_HandleTildaModifiers(char **start, char *forVariable) {
BOOL skipFileParsing = FALSE;
BOOL doneModifier = FALSE;
/* Search forwards until find invalid character modifier */
/* Search forwards until find invalid WCHARacter modifier */
while (!finished) {
/* Work on the previous character */
/* Work on the previous WCHARacter */
if (lastModifier != NULL) {
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 */
if (!(*lastModifier >= '0' || *lastModifier <= '9') &&
(forVariable != NULL) &&
(toupper(*lastModifier) != toupper(*forVariable))) {
(toupperW(*lastModifier) != toupperW(*forVariable))) {
/* 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--;
}
@ -386,7 +387,7 @@ void WCMD_HandleTildaModifiers(char **start, char *forVariable) {
/* Extract the parameter to play with */
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));
} else {
/* FIXME: Retrieve 'for' variable %c\n", *lastModifier); */
@ -407,26 +408,26 @@ void WCMD_HandleTildaModifiers(char **start, char *forVariable) {
/* 1. Handle '~' : Strip surrounding quotes */
if (outputparam[0]=='"' &&
memchr(firstModifier, '~', modifierLen) != NULL) {
int len = strlen(outputparam);
memchrW(firstModifier, '~', modifierLen) != NULL) {
int len = strlenW(outputparam);
if (outputparam[len-1] == '"') {
outputparam[len-1]=0x00;
len = len - 1;
}
memmove(outputparam, &outputparam[1], len-1);
memmove(outputparam, &outputparam[1], (len * sizeof(WCHAR))-1);
}
/* 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
Note both $ and : are guaranteed otherwise check above would fail */
char *start = strchr(firstModifier, '$') + 1;
char *end = strchr(firstModifier, ':');
char env[MAX_PATH];
char fullpath[MAX_PATH];
WCHAR *start = strchrW(firstModifier, '$') + 1;
WCHAR *end = strchrW(firstModifier, ':');
WCHAR env[MAX_PATH];
WCHAR fullpath[MAX_PATH];
/* Extract the env var */
strncpy(env, start, (end-start));
memcpy(env, start, (end-start) * sizeof(WCHAR));
env[(end-start)] = 0x00;
/* 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)
return;
exists = GetFileAttributesExA(fullfilename, GetFileExInfoStandard,
exists = GetFileAttributesExW(fullfilename, GetFileExInfoStandard,
&fileInfo);
/* 2. Handle 'a' : Output attributes */
if (exists &&
memchr(firstModifier, 'a', modifierLen) != NULL) {
memchrW(firstModifier, 'a', modifierLen) != NULL) {
WCHAR defaults[] = {'-','-','-','-','-','-','-','-','-','\0'};
doneModifier = TRUE;
strcpy(thisoutput, "---------");
strcpyW(thisoutput, defaults);
if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
thisoutput[0]='d';
if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
@ -469,114 +471,115 @@ void WCMD_HandleTildaModifiers(char **start, char *forVariable) {
/* FIXME: What are 6 and 7? */
if (fileInfo.dwFileAttributes & FILE_ATTRIBUTE_REPARSE_POINT)
thisoutput[8]='l';
strcat(finaloutput, thisoutput);
strcatW(finaloutput, thisoutput);
}
/* 3. Handle 't' : Date+time */
if (exists &&
memchr(firstModifier, 't', modifierLen) != NULL) {
memchrW(firstModifier, 't', modifierLen) != NULL) {
SYSTEMTIME systime;
int datelen;
doneModifier = TRUE;
if (finaloutput[0] != 0x00) strcat(finaloutput, space);
if (finaloutput[0] != 0x00) strcatW(finaloutput, space);
/* Format the time */
FileTimeToSystemTime(&fileInfo.ftLastWriteTime, &systime);
GetDateFormat(LOCALE_USER_DEFAULT, DATE_SHORTDATE, &systime,
NULL, thisoutput, MAX_PATH);
strcat(thisoutput, space);
datelen = strlen(thisoutput);
strcatW(thisoutput, space);
datelen = strlenW(thisoutput);
GetTimeFormat(LOCALE_USER_DEFAULT, TIME_NOSECONDS, &systime,
NULL, (thisoutput+datelen), MAX_PATH-datelen);
strcat(finaloutput, thisoutput);
strcatW(finaloutput, thisoutput);
}
/* 4. Handle 'z' : File length */
if (exists &&
memchr(firstModifier, 'z', modifierLen) != NULL) {
memchrW(firstModifier, 'z', modifierLen) != NULL) {
/* FIXME: Output full 64 bit size (sprintf does not support I64 here) */
ULONG/*64*/ fullsize = /*(fileInfo.nFileSizeHigh << 32) +*/
fileInfo.nFileSizeLow;
static const WCHAR fmt[] = {'%','u','\0'};
doneModifier = TRUE;
if (finaloutput[0] != 0x00) strcat(finaloutput, space);
sprintf(thisoutput, "%u", fullsize);
strcat(finaloutput, thisoutput);
if (finaloutput[0] != 0x00) strcatW(finaloutput, space);
wsprintf(thisoutput, fmt, fullsize);
strcatW(finaloutput, thisoutput);
}
/* 4. Handle 's' : Use short paths (File doesn't have to exist) */
if (memchr(firstModifier, 's', modifierLen) != NULL) {
if (finaloutput[0] != 0x00) strcat(finaloutput, space);
if (memchrW(firstModifier, 's', modifierLen) != NULL) {
if (finaloutput[0] != 0x00) strcatW(finaloutput, space);
/* Don't flag as doneModifier - %~s on its own is processed later */
GetShortPathName(outputparam, outputparam, sizeof(outputparam));
}
/* 5. Handle 'f' : Fully qualified path (File doesn't have to exist) */
/* Note this overrides d,p,n,x */
if (memchr(firstModifier, 'f', modifierLen) != NULL) {
if (memchrW(firstModifier, 'f', modifierLen) != NULL) {
doneModifier = TRUE;
if (finaloutput[0] != 0x00) strcat(finaloutput, space);
strcat(finaloutput, fullfilename);
if (finaloutput[0] != 0x00) strcatW(finaloutput, space);
strcatW(finaloutput, fullfilename);
} else {
char drive[10];
char dir[MAX_PATH];
char fname[MAX_PATH];
char ext[MAX_PATH];
WCHAR drive[10];
WCHAR dir[MAX_PATH];
WCHAR fname[MAX_PATH];
WCHAR ext[MAX_PATH];
BOOL doneFileModifier = FALSE;
if (finaloutput[0] != 0x00) strcat(finaloutput, space);
if (finaloutput[0] != 0x00) strcatW(finaloutput, space);
/* Split into components */
WCMD_splitpath(fullfilename, drive, dir, fname, ext);
/* 5. Handle 'd' : Drive Letter */
if (memchr(firstModifier, 'd', modifierLen) != NULL) {
strcat(finaloutput, drive);
if (memchrW(firstModifier, 'd', modifierLen) != NULL) {
strcatW(finaloutput, drive);
doneModifier = TRUE;
doneFileModifier = TRUE;
}
/* 6. Handle 'p' : Path */
if (memchr(firstModifier, 'p', modifierLen) != NULL) {
strcat(finaloutput, dir);
if (memchrW(firstModifier, 'p', modifierLen) != NULL) {
strcatW(finaloutput, dir);
doneModifier = TRUE;
doneFileModifier = TRUE;
}
/* 7. Handle 'n' : Name */
if (memchr(firstModifier, 'n', modifierLen) != NULL) {
strcat(finaloutput, fname);
if (memchrW(firstModifier, 'n', modifierLen) != NULL) {
strcatW(finaloutput, fname);
doneModifier = TRUE;
doneFileModifier = TRUE;
}
/* 8. Handle 'x' : Ext */
if (memchr(firstModifier, 'x', modifierLen) != NULL) {
strcat(finaloutput, ext);
if (memchrW(firstModifier, 'x', modifierLen) != NULL) {
strcatW(finaloutput, ext);
doneModifier = TRUE;
doneFileModifier = TRUE;
}
/* If 's' but no other parameter, dump the whole thing */
if (!doneFileModifier &&
memchr(firstModifier, 's', modifierLen) != NULL) {
memchrW(firstModifier, 's', modifierLen) != NULL) {
doneModifier = TRUE;
if (finaloutput[0] != 0x00) strcat(finaloutput, space);
strcat(finaloutput, outputparam);
if (finaloutput[0] != 0x00) strcatW(finaloutput, space);
strcatW(finaloutput, outputparam);
}
}
}
/* 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 */
pos = strdup (lastModifier+1);
strcpy(*start, finaloutput);
strcat(*start, pos);
pos = WCMD_strdupW(lastModifier+1);
strcpyW(*start, finaloutput);
strcatW(*start, pos);
free(pos);
}
@ -586,16 +589,16 @@ void WCMD_HandleTildaModifiers(char **start, char *forVariable) {
* If there is a leading ':', calls within this batch program
* otherwise launches another program.
*/
void WCMD_call (char *command) {
void WCMD_call (WCHAR *command) {
/* Run other program if no leading ':' */
if (*command != ':') {
WCMD_run_program(command, 1);
} else {
char gotoLabel[MAX_PATH];
WCHAR gotoLabel[MAX_PATH];
strcpy(gotoLabel, param1);
strcpyW(gotoLabel, param1);
if (context) {

File diff suppressed because it is too large Load Diff

View File

@ -33,13 +33,13 @@
WINE_DEFAULT_DEBUG_CHANNEL(cmd);
int WCMD_dir_sort (const void *a, const void *b);
char * WCMD_filesize64 (ULONGLONG free);
char * WCMD_strrev (char *buff);
static void WCMD_getfileowner(char *filename, char *owner, int ownerlen);
static void WCMD_dir_trailer(char drive);
WCHAR * WCMD_filesize64 (ULONGLONG free);
WCHAR * WCMD_strrev (WCHAR *buff);
static void WCMD_getfileowner(WCHAR *filename, WCHAR *owner, int ownerlen);
static void WCMD_dir_trailer(WCHAR drive);
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;
typedef enum _DISPLAYTIME
@ -67,6 +67,12 @@ static BOOL orderReverse, orderGroupDirs, orderGroupDirsReverse, orderByCol;
static BOOL separator;
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
*
@ -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;
CONSOLE_SCREEN_BUFFER_INFO consoleInfo;
char *p;
char string[MAXSTRING];
WCHAR *p;
WCHAR string[MAXSTRING];
int argno = 0;
int argsProcessed = 0;
char *argN = cmd;
char lastDrive;
WCHAR *argN = cmd;
WCHAR lastDrive;
BOOL trailerReqd = FALSE;
DIRECTORY_STACK *fullParms = NULL;
DIRECTORY_STACK *prevEntry = NULL;
DIRECTORY_STACK *thisEntry = NULL;
char drive[10];
char dir[MAX_PATH];
char fname[MAX_PATH];
char ext[MAX_PATH];
WCHAR drive[10];
WCHAR dir[MAX_PATH];
WCHAR fname[MAX_PATH];
WCHAR ext[MAX_PATH];
static const WCHAR dircmdW[] = {'D','I','R','C','M','D','\0'};
errorlevel = 0;
/* Prefill Quals with (uppercased) DIRCMD env var */
if (GetEnvironmentVariable ("DIRCMD", string, sizeof(string))) {
if (GetEnvironmentVariable (dircmdW, string, sizeof(string)/sizeof(WCHAR))) {
p = string;
while ( (*p = toupper(*p)) ) ++p;
strcat(string,quals);
strcpy(quals, string);
strcatW(string,quals);
strcpyW(quals, string);
}
byte_total = 0;
@ -138,7 +145,7 @@ void WCMD_directory (char *cmd) {
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) {
case 'P': if (negate) paged_mode = !paged_mode;
else paged_mode = TRUE;
@ -188,7 +195,7 @@ void WCMD_directory (char *cmd) {
case 'O': p = p + 1;
if (*p==':') p++; /* Skip optional : */
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) {
case 'N': dirOrder = Name; break;
case 'E': dirOrder = Extension; break;
@ -222,7 +229,7 @@ void WCMD_directory (char *cmd) {
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) {
case 'D': mask = FILE_ATTRIBUTE_DIRECTORY; break;
case 'H': mask = FILE_ATTRIBUTE_HIDDEN; break;
@ -276,62 +283,64 @@ void WCMD_directory (char *cmd) {
argno = 0;
argsProcessed = 0;
argN = cmd;
GetCurrentDirectory (1024, cwd);
strcat(cwd, "\\");
GetCurrentDirectory (MAX_PATH, cwd);
strcatW(cwd, slashW);
/* Loop through all args, calculating full effective directory */
fullParms = NULL;
prevEntry = NULL;
while (argN) {
char fullname[MAXSTRING];
char *thisArg = WCMD_parameter (cmd, argno++, &argN);
WCHAR fullname[MAXSTRING];
WCHAR *thisArg = WCMD_parameter (cmd, argno++, &argN);
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] == '\\') {
strcpy(fullname, thisArg);
strcpyW(fullname, thisArg);
} else if (thisArg[1] == ':' && thisArg[2] != '\\') {
char envvar[4];
sprintf(envvar, "=%c:", thisArg[0]);
WCHAR envvar[4];
static const WCHAR envFmt[] = {'=','%','c',':','\0'};
wsprintf(envvar, envFmt, thisArg[0]);
if (!GetEnvironmentVariable(envvar, fullname, MAX_PATH)) {
sprintf(fullname, "%c:", thisArg[0]);
static const WCHAR noEnvFmt[] = {'%','c',':','\0'};
wsprintf(fullname, noEnvFmt, thisArg[0]);
}
strcat(fullname, "\\");
strcat(fullname, &thisArg[2]);
strcatW(fullname, slashW);
strcatW(fullname, &thisArg[2]);
} else if (thisArg[0] == '\\') {
strncpy(fullname, cwd, 2);
fullname[2] = 0x00;
strcat((fullname+2), thisArg);
memcpy(fullname, cwd, 2 * sizeof(WCHAR));
strcpyW(fullname+2, thisArg);
} else {
strcpy(fullname, cwd);
strcat(fullname, thisArg);
strcpyW(fullname, cwd);
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
* path references a directory, we need to list the *contents* of that
* directory not the directory file itself.
*/
if ((strchr(path, '*') == NULL) && (strchr(path, '%') == NULL)) {
if ((strchrW(path, '*') == NULL) && (strchrW(path, '%') == NULL)) {
status = GetFileAttributes (path);
if ((status != INVALID_FILE_ATTRIBUTES) && (status & FILE_ATTRIBUTE_DIRECTORY)) {
if (path[strlen(path)-1] == '\\') {
strcat (path, "*");
if (path[strlenW(path)-1] == '\\') {
strcatW (path, starW);
}
else {
strcat (path, "\\*");
const WCHAR slashStarW[] = {'\\','*','\0'};
strcatW (path, slashStarW);
}
}
} else {
/* Special case wildcard search with no extension (ie parameters ending in '.') as
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));
if (fullParms == NULL) fullParms = thisEntry;
if (prevEntry != NULL) prevEntry->next = thisEntry;
@ -341,15 +350,18 @@ void WCMD_directory (char *cmd) {
/* Split into components */
WCMD_splitpath(path, drive, dir, fname, ext);
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);
strcpy(thisEntry->dirName, drive);
strcat(thisEntry->dirName, dir);
thisEntry->dirName = HeapAlloc(GetProcessHeap(),0,
sizeof(WCHAR) * (strlenW(drive)+strlenW(dir)+1));
strcpyW(thisEntry->dirName, drive);
strcatW(thisEntry->dirName, dir);
thisEntry->fileName = HeapAlloc(GetProcessHeap(),0,strlen(fname)+strlen(ext)+1);
strcpy(thisEntry->fileName, fname);
strcat(thisEntry->fileName, ext);
thisEntry->fileName = HeapAlloc(GetProcessHeap(),0,
sizeof(WCHAR) * (strlenW(fname)+strlenW(ext)+1));
strcpyW(thisEntry->fileName, fname);
strcatW(thisEntry->fileName, ext);
}
}
@ -359,10 +371,10 @@ void WCMD_directory (char *cmd) {
WINE_TRACE("Inserting default '*'\n");
fullParms = (DIRECTORY_STACK *) HeapAlloc(GetProcessHeap(),0, sizeof(DIRECTORY_STACK));
fullParms->next = NULL;
fullParms->dirName = HeapAlloc(GetProcessHeap(),0,(strlen(cwd)+1));
strcpy(fullParms->dirName, cwd);
fullParms->fileName = HeapAlloc(GetProcessHeap(),0,2);
strcpy(fullParms->fileName, "*");
fullParms->dirName = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR) * (strlenW(cwd)+1));
strcpyW(fullParms->dirName, cwd);
fullParms->fileName = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR) * 2);
strcpyW(fullParms->fileName, starW);
}
lastDrive = '?';
@ -385,10 +397,10 @@ void WCMD_directory (char *cmd) {
lastDrive = toupper(thisEntry->dirName[0]);
if (!bare) {
char drive[3];
WCHAR drive[3];
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;
status = WCMD_volume (0, drive);
trailerReqd = TRUE;
@ -398,7 +410,8 @@ void WCMD_directory (char *cmd) {
}
}
} 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 */
@ -436,8 +449,8 @@ exit:
static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int level) {
char string[1024], datestring[32], timestring[32];
char real_path[MAX_PATH];
WCHAR string[1024], datestring[32], timestring[32];
WCHAR real_path[MAX_PATH];
WIN32_FIND_DATA *fd;
FILETIME ft;
SYSTEMTIME st;
@ -450,6 +463,14 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
int concurrentDirs = 0;
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;
file_count = 0;
@ -463,15 +484,15 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
mirrors what windows does */
parms = inputparms;
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++;
/* Work out the full path + filename */
strcpy(real_path, parms->dirName);
strcat(real_path, parms->fileName);
strcpyW(real_path, parms->dirName);
strcatW(real_path, parms->fileName);
/* 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));
if (hff != INVALID_HANDLE_VALUE) {
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 */
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 (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 \ */
strcpy(real_path, parms->dirName);
real_path[strlen(parms->dirName)-1] = 0x00;
strcpyW(real_path, parms->dirName);
real_path[strlenW(parms->dirName)-1] = 0x00;
/* Output the results */
if (!bare) {
if (level != 0 && (entry_count > 0)) WCMD_output (newline);
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;
}
}
@ -536,7 +559,7 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
for (rows=0; rows<numRows; rows++) {
BOOL addNewLine = TRUE;
for (cols=0; cols<numCols; cols++) {
char username[24];
WCHAR username[24];
/* Work out the index of the entry being pointed to */
if (orderByCol) {
@ -549,15 +572,15 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
/* /L convers all names to lower case */
if (lower) {
char *p = (fd+i)->cFileName;
WCHAR *p = (fd+i)->cFileName;
while ( (*p = tolower(*p)) ) ++p;
}
/* /Q gets file ownership information */
if (usernames) {
lstrcpy (string, inputparms->dirName);
lstrcat (string, (fd+i)->cFileName);
WCMD_getfileowner(string, username, sizeof(username));
strcpyW (string, inputparms->dirName);
strcatW (string, (fd+i)->cFileName);
WCMD_getfileowner(string, username, sizeof(username)/sizeof(WCHAR));
}
if (dirTime == Written) {
@ -569,20 +592,22 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
}
FileTimeToSystemTime (&ft, &st);
GetDateFormat (0, DATE_SHORTDATE, &st, NULL, datestring,
sizeof(datestring));
sizeof(datestring)/sizeof(WCHAR));
GetTimeFormat (0, TIME_NOSECONDS, &st,
NULL, timestring, sizeof(timestring));
NULL, timestring, sizeof(timestring)/sizeof(WCHAR));
if (wide) {
tmp_width = cur_width;
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++;
tmp_width = tmp_width + strlen((fd+i)->cFileName) + 2;
tmp_width = tmp_width + strlenW((fd+i)->cFileName) + 2;
} else {
WCMD_output ("%s", (fd+i)->cFileName);
tmp_width = tmp_width + strlen((fd+i)->cFileName) ;
static const WCHAR fmt[] = {'%','s','\0'};
WCMD_output (fmt, (fd+i)->cFileName);
tmp_width = tmp_width + strlenW((fd+i)->cFileName) ;
file_count++;
file_size.u.LowPart = (fd+i)->nFileSizeLow;
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) {
cur_width = 0;
} 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) {
dir_count++;
if (!bare) {
WCMD_output ("%10s %8s <DIR> ", datestring, timestring);
if (shortname) WCMD_output ("%-13s", (fd+i)->cAlternateFileName);
if (usernames) WCMD_output ("%-23s", username);
WCMD_output("%s",(fd+i)->cFileName);
WCMD_output (fmtDir, datestring, timestring);
if (shortname) WCMD_output (fmt2, (fd+i)->cAlternateFileName);
if (usernames) WCMD_output (fmt3, username);
WCMD_output(fmt4,(fd+i)->cFileName);
} else {
if (!((strcmp((fd+i)->cFileName, ".") == 0) ||
(strcmp((fd+i)->cFileName, "..") == 0))) {
WCMD_output ("%s%s", recurse?inputparms->dirName:"", (fd+i)->cFileName);
if (!((strcmpW((fd+i)->cFileName, dotW) == 0) ||
(strcmpW((fd+i)->cFileName, dotdotW) == 0))) {
WCMD_output (fmt5, recurse?inputparms->dirName:emptyW, (fd+i)->cFileName);
} else {
addNewLine = FALSE;
}
@ -619,13 +645,13 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
file_size.u.HighPart = (fd+i)->nFileSizeHigh;
byte_count.QuadPart += file_size.QuadPart;
if (!bare) {
WCMD_output ("%10s %8s %10s ", datestring, timestring,
WCMD_output (fmtFile, datestring, timestring,
WCMD_filesize64(file_size.QuadPart));
if (shortname) WCMD_output ("%-13s", (fd+i)->cAlternateFileName);
if (usernames) WCMD_output ("%-23s", username);
WCMD_output("%s",(fd+i)->cFileName);
if (shortname) WCMD_output (fmt2, (fd+i)->cAlternateFileName);
if (usernames) WCMD_output (fmt3, username);
WCMD_output(fmt4,(fd+i)->cFileName);
} 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 (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 {
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;
@ -646,8 +676,15 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
dir_total = dir_total + dir_count;
if (!bare && !recurse) {
if (dir_count == 1) WCMD_output ("%8d directory ", 1);
else WCMD_output ("%8d directories", dir_count);
if (dir_count == 1) {
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);
@ -659,16 +696,16 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
WIN32_FIND_DATA finddata;
/* Build path to search */
strcpy(string, inputparms->dirName);
strcat(string, "*");
strcpyW(string, inputparms->dirName);
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);
if (hff != INVALID_HANDLE_VALUE) {
do {
if ((finddata.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) &&
(strcmp(finddata.cFileName, "..") != 0) &&
(strcmp(finddata.cFileName, ".") != 0)) {
(strcmpW(finddata.cFileName, dotdotW) != 0) &&
(strcmpW(finddata.cFileName, dotW) != 0)) {
DIRECTORY_STACK *thisDir;
int dirsToCopy = concurrentDirs;
@ -679,10 +716,10 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
dirsToCopy--;
/* Work out search parameter in sub dir */
strcpy (string, inputparms->dirName);
strcat (string, finddata.cFileName);
strcat (string, "\\");
WINE_TRACE("Recursive, Adding to search list '%s'\n", string);
strcpyW (string, inputparms->dirName);
strcatW (string, finddata.cFileName);
strcatW (string, slashW);
WINE_TRACE("Recursive, Adding to search list '%s'\n", wine_dbgstr_w(string));
/* Allocate memory, add to list */
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;
lastEntry = thisDir;
thisDir->next = NULL;
thisDir->dirName = HeapAlloc(GetProcessHeap(),0,(strlen(string)+1));
strcpy(thisDir->dirName, string);
thisDir->fileName = HeapAlloc(GetProcessHeap(),0,(strlen(parms->fileName)+1));
strcpy(thisDir->fileName, parms->fileName);
thisDir->dirName = HeapAlloc(GetProcessHeap(),0,
sizeof(WCHAR) * (strlenW(string)+1));
strcpyW(thisDir->dirName, string);
thisDir->fileName = HeapAlloc(GetProcessHeap(),0,
sizeof(WCHAR) * (strlenW(parms->fileName)+1));
strcpyW(thisDir->fileName, parms->fileName);
parms = parms->next;
}
}
@ -727,17 +766,17 @@ static DIRECTORY_STACK *WCMD_list_directory (DIRECTORY_STACK *inputparms, int le
/*****************************************************************************
* 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.
* FIXME: There must be a better algorithm!
*/
char * WCMD_filesize64 (ULONGLONG n) {
WCHAR * WCMD_filesize64 (ULONGLONG n) {
ULONGLONG q;
unsigned int r, i;
char *p;
static char buff[32];
WCHAR *p;
static WCHAR buff[32];
p = buff;
i = -3;
@ -756,15 +795,15 @@ char * WCMD_filesize64 (ULONGLONG n) {
/*****************************************************************************
* 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;
char b;
WCHAR b;
r = lstrlen (buff);
r = strlenW (buff);
for (i=0; i<r/2; i++) {
b = buff[i];
buff[i] = buff[r-i-1];
@ -799,7 +838,7 @@ int WCMD_dir_sort (const void *a, const void *b)
/* Order by Name: */
} else if (dirOrder == Name) {
result = lstrcmpi(filea->cFileName, fileb->cFileName);
result = lstrcmpiW(filea->cFileName, fileb->cFileName);
/* Order by 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) */
} else if (dirOrder == Extension) {
char drive[10];
char dir[MAX_PATH];
char fname[MAX_PATH];
char extA[MAX_PATH];
char extB[MAX_PATH];
WCHAR drive[10];
WCHAR dir[MAX_PATH];
WCHAR fname[MAX_PATH];
WCHAR extA[MAX_PATH];
WCHAR extB[MAX_PATH];
/* Split into components */
WCMD_splitpath(filea->cFileName, drive, dir, fname, extA);
WCMD_splitpath(fileb->cFileName, drive, dir, fname, extB);
result = lstrcmpi(extA, extB);
result = lstrcmpiW(extA, extB);
}
if (orderReverse) result = -result;
@ -856,14 +895,14 @@ int WCMD_dir_sort (const void *a, const void *b)
/*****************************************************************************
* 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;
DWORD rc;
char name[MAXSTRING];
char domain[MAXSTRING];
WCHAR name[MAXSTRING];
WCHAR domain[MAXSTRING];
/* In case of error, return empty string */
*owner = 0x00;
@ -899,7 +938,8 @@ void WCMD_getfileowner(char *filename, char *owner, int ownerlen) {
/* Convert to a username */
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);
}
@ -911,23 +951,30 @@ void WCMD_getfileowner(char *filename, char *owner, int ownerlen) {
*
* 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;
DWORD status;
char driveName[4] = "c:\\";
WCHAR driveName[4] = {'c',':','\\','\0'};
driveName[0] = drive;
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 (recurse) {
WCMD_output ("\n Total files listed:\n%8d files%25s bytes\n",
file_total, WCMD_filesize64 (byte_total));
WCMD_output ("%8d directories %18s bytes free\n\n",
dir_total, WCMD_filesize64 (freebytes.QuadPart));
static const WCHAR fmt1[] = {'\n',' ',' ',' ',' ',' ','T','o','t','a','l',' ','f','i','l','e','s',
' ','l','i','s','t','e','d',':','\n','%','8','d',' ','f','i','l','e',
's','%','2','5','s',' ','b','y','t','e','s','\n','\0'};
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 {
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 <wine/unicode.h>
void WCMD_assoc (char *, BOOL);
void WCMD_batch (char *, char *, int, char *, HANDLE);
void WCMD_call (char *command);
void WCMD_assoc (WCHAR *, BOOL);
void WCMD_batch (WCHAR *, WCHAR *, int, WCHAR *, HANDLE);
void WCMD_call (WCHAR *command);
void WCMD_change_tty (void);
void WCMD_clear_screen (void);
void WCMD_color (void);
void WCMD_copy (void);
void WCMD_create_dir (void);
BOOL WCMD_delete (char *, BOOL);
void WCMD_directory (char *);
void WCMD_echo (const char *);
BOOL WCMD_delete (WCHAR *, BOOL);
void WCMD_directory (WCHAR *);
void WCMD_echo (const WCHAR *);
void WCMD_endlocal (void);
void WCMD_enter_paged_mode(const char *);
void WCMD_enter_paged_mode(const WCHAR *);
void WCMD_exit (void);
void WCMD_for (char *);
void WCMD_give_help (char *command);
void WCMD_for (WCHAR *);
void WCMD_give_help (WCHAR *command);
void WCMD_goto (void);
void WCMD_if (char *);
void WCMD_if (WCHAR *);
void WCMD_leave_paged_mode(void);
void WCMD_more (char *);
void WCMD_more (WCHAR *);
void WCMD_move (void);
void WCMD_output (const char *format, ...);
void WCMD_output_asis (const char *message);
void WCMD_parse (char *s, char *q, char *p1, char *p2);
void WCMD_output (const WCHAR *format, ...);
void WCMD_output_asis (const WCHAR *message);
void WCMD_parse (WCHAR *s, WCHAR *q, WCHAR *p1, WCHAR *p2);
void WCMD_pause (void);
void WCMD_pipe (char *command);
void WCMD_pipe (WCHAR *command);
void WCMD_popd (void);
void WCMD_print_error (void);
void WCMD_process_command (char *command);
void WCMD_pushd (char *);
int WCMD_read_console (char *string, int str_len);
void WCMD_remove_dir (char *command);
void WCMD_process_command (WCHAR *command);
void WCMD_pushd (WCHAR *);
int WCMD_read_console (WCHAR *string, int str_len);
void WCMD_remove_dir (WCHAR *command);
void WCMD_rename (void);
void WCMD_run_program (char *command, int called);
void WCMD_setlocal (const char *command);
void WCMD_run_program (WCHAR *command, int called);
void WCMD_setlocal (const WCHAR *command);
void WCMD_setshow_attrib (void);
void WCMD_setshow_date (void);
void WCMD_setshow_default (char *command);
void WCMD_setshow_env (char *command);
void WCMD_setshow_path (char *command);
void WCMD_setshow_default (WCHAR *command);
void WCMD_setshow_env (WCHAR *command);
void WCMD_setshow_path (WCHAR *command);
void WCMD_setshow_prompt (void);
void WCMD_setshow_time (void);
void WCMD_shift (char *command);
void WCMD_shift (WCHAR *command);
void WCMD_show_prompt (void);
void WCMD_title (char *);
void WCMD_type (char *);
void WCMD_verify (char *command);
void WCMD_title (WCHAR *);
void WCMD_type (WCHAR *);
void WCMD_verify (WCHAR *command);
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);
char *WCMD_parameter (char *s, int n, char **where);
char *WCMD_strtrim_leading_spaces (char *string);
void WCMD_strtrim_trailing_spaces (char *string);
void WCMD_opt_s_strip_quotes(char *cmd);
void WCMD_HandleTildaModifiers(char **start, char *forVariable);
BOOL WCMD_ask_confirm (char *message, BOOL showSureText, BOOL *optionAll);
WCHAR *WCMD_fgets (WCHAR *s, int n, HANDLE stream);
WCHAR *WCMD_parameter (WCHAR *s, int n, WCHAR **where);
WCHAR *WCMD_strtrim_leading_spaces (WCHAR *string);
void WCMD_strtrim_trailing_spaces (WCHAR *string);
void WCMD_opt_s_strip_quotes(WCHAR *cmd);
void WCMD_HandleTildaModifiers(WCHAR **start, WCHAR *forVariable);
BOOL WCMD_ask_confirm (WCHAR *message, BOOL showSureText, BOOL *optionAll);
void WCMD_splitpath(const CHAR* path, CHAR* drv, CHAR* dir, CHAR* name, CHAR* ext);
char *WCMD_LoadMessage(UINT id);
void WCMD_splitpath(const WCHAR* path, WCHAR* drv, WCHAR* dir, WCHAR* name, WCHAR* ext);
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 */
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 */
int shift_count[10]; /* Offset in terms of shifts for %0 - %9 */
void *prev_context; /* Pointer to the previous context block */
@ -106,7 +109,7 @@ struct env_stack
struct env_stack *next;
union {
int stackdepth; /* Only used for pushd and popd */
char cwd; /* Only used for set/endlocal */
WCHAR cwd; /* Only used for set/endlocal */
} u;
WCHAR *strings;
};
@ -116,8 +119,8 @@ struct env_stack
typedef struct _DIRECTORY_STACK
{
struct _DIRECTORY_STACK *next;
char *dirName;
char *fileName;
WCHAR *dirName;
WCHAR *fileName;
} DIRECTORY_STACK;
#endif /* !RC_INVOKED */
@ -181,9 +184,9 @@ typedef struct _DIRECTORY_STACK
#define WCMD_EXIT 44
/* Some standard messages */
extern const char newline[];
extern const char version_string[];
extern const char anykey[];
extern const WCHAR newline[];
extern WCHAR anykey[];
extern WCHAR version_string[];
/* Translated messages */
#define WCMD_CONFIRM 1001
@ -215,6 +218,11 @@ extern const char anykey[];
#define WCMD_ARGERR 1027
#define WCMD_VOLUMEDETAIL 1028
#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 */
#define MAXSTRING 8192

File diff suppressed because it is too large Load Diff