add a new interal function call GetRootPath(TCHAR *InPath,TCHAR *OutPath,INT size) it get the a driver current path without change the current driver directory, it is not in use yet, prep for copy, cd, rm, and all other commands. Modified: trunk/reactos/subsys/system/cmd/cmd.h Modified: trunk/reactos/subsys/system/cmd/internal.c Modified: trunk/reactos/subsys/system/cmd/precomp.h _____
Modified: trunk/reactos/subsys/system/cmd/cmd.h --- trunk/reactos/subsys/system/cmd/cmd.h 2005-07-18 19:50:23 UTC (rev 16635) +++ trunk/reactos/subsys/system/cmd/cmd.h 2005-07-18 22:44:13 UTC (rev 16636) @@ -291,6 +291,7 @@
/* Prototypes for MISC.C */ +INT GetRootPath(TCHAR *InPath,TCHAR *OutPath,INT size); TCHAR cgetchar (VOID); BOOL CheckCtrlBreak (INT); LPTSTR *split (LPTSTR, LPINT, BOOL); _____
Modified: trunk/reactos/subsys/system/cmd/internal.c --- trunk/reactos/subsys/system/cmd/internal.c 2005-07-18 19:50:23 UTC (rev 16635) +++ trunk/reactos/subsys/system/cmd/internal.c 2005-07-18 22:44:13 UTC (rev 16636) @@ -148,6 +148,46 @@
free (lpLastPath); }
+/* help functions for getting current path from driver + without changing driver. Return code 0 = ok, 1 = fail. + INT GetRootPath("C:",outbuffer,chater size of outbuffer); + the frist param can have any size, if the the two frist + letter are not a drive with : it will get Currentpath on + current drive exacly as GetCurrentDirectory does. + */ + +INT GetRootPath(TCHAR *InPath,TCHAR *OutPath,INT size) +{ + INT retcode = 1; + INT t; + + for (t=0;t<32;t++) + { + if (_tgetdcwd(t,OutPath,size) != NULL) + { + if (_tcsncicmp(InPath,OutPath,2)) + { + retcode = 0; + return retcode; + } + } + } + + /* fail to getting path devic did not exists */ + if (_tcslen(InPath)>1) + { + if (InPath[1]==_T(':')) + return 1; + } + + retcode = GetCurrentDirectory(size,OutPath); + if (retcode==0) + return 1; + + return 0; +} + + /* * CD / CHDIR * _____
Modified: trunk/reactos/subsys/system/cmd/precomp.h --- trunk/reactos/subsys/system/cmd/precomp.h 2005-07-18 19:50:23 UTC (rev 16635) +++ trunk/reactos/subsys/system/cmd/precomp.h 2005-07-18 22:44:13 UTC (rev 16636) @@ -4,6 +4,8 @@
#include <shellapi.h>
#include <tchar.h> +#include <direct.h> + #include <ctype.h> #include <string.h> #include <stdio.h> @@ -15,3 +17,4 @@ #include "cmd.h" #include "config.h" #include "batch.h" +