Jason Edmeades : cmd.exe: Add support for working directories per
drive.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Mar 8 07:17:09 CST 2007
Module: wine
Branch: master
Commit: 2b03d7d75f5d6ff29796cfc51e625faf5ab8a4cb
URL: http://source.winehq.org/git/wine.git/?a=commit;h=2b03d7d75f5d6ff29796cfc51e625faf5ab8a4cb
Author: Jason Edmeades <us at edmeades.me.uk>
Date: Thu Mar 8 00:47:45 2007 +0000
cmd.exe: Add support for working directories per drive.
---
programs/cmd/builtins.c | 11 +++++++++++
programs/cmd/wcmdmain.c | 11 +++++++++++
2 files changed, 22 insertions(+), 0 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 4c80289..f38cd97 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -1108,12 +1108,23 @@ void WCMD_setshow_default (char *command) {
/* Change to that directory */
WINE_TRACE("Really changing to directory '%s'\n", string);
+
status = SetCurrentDirectory (string);
if (!status) {
errorlevel = 1;
WCMD_print_error ();
return;
}
+
+ /* Set special =C: type environment variable */
+ if ((string[1] == ':') && IsCharAlpha (string[0])) {
+ char env[4];
+ strcpy(env, "=");
+ strncpy(env+1, string, 2);
+ env[3] = 0x00;
+ SetEnvironmentVariable(env, string);
+ }
+
}
return;
}
diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index 1a093fa..de6aa6d 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -460,6 +460,17 @@ void WCMD_process_command (char *command)
*/
if ((cmd[1] == ':') && IsCharAlpha (cmd[0]) && (strlen(cmd) == 2)) {
+ char envvar[5];
+ char dir[MAX_PATH];
+
+ /* According to MSDN CreateProcess docs, special env vars record
+ the current directory on each drive, in the form =C:
+ so see if one specified, and if so go back to it */
+ strcpy(envvar, "=");
+ strcat(envvar, cmd);
+ if (GetEnvironmentVariable(envvar, dir, MAX_PATH) == 0) {
+ sprintf(cmd, "%s\\", cmd);
+ }
status = SetCurrentDirectory (cmd);
if (!status) WCMD_print_error ();
HeapFree( GetProcessHeap(), 0, cmd );
More information about the wine-cvs
mailing list