diff --git a/reactos/subsys/system/cmd/cmd.h b/reactos/subsys/system/cmd/cmd.h index 19f080c6458..1934b9b63ef 100644 --- a/reactos/subsys/system/cmd/cmd.h +++ b/reactos/subsys/system/cmd/cmd.h @@ -291,6 +291,7 @@ INT CommandMemory (LPTSTR, LPTSTR); /* Prototypes for MISC.C */ +INT GetRootPath(TCHAR *InPath,TCHAR *OutPath,INT size); TCHAR cgetchar (VOID); BOOL CheckCtrlBreak (INT); LPTSTR *split (LPTSTR, LPINT, BOOL); diff --git a/reactos/subsys/system/cmd/internal.c b/reactos/subsys/system/cmd/internal.c index 66e2044d296..7b1cb904896 100644 --- a/reactos/subsys/system/cmd/internal.c +++ b/reactos/subsys/system/cmd/internal.c @@ -148,6 +148,46 @@ VOID FreeLastPath (VOID) 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 * diff --git a/reactos/subsys/system/cmd/precomp.h b/reactos/subsys/system/cmd/precomp.h index 35c6a64b364..9ccc3eb2dcf 100644 --- a/reactos/subsys/system/cmd/precomp.h +++ b/reactos/subsys/system/cmd/precomp.h @@ -4,6 +4,8 @@ #include #include +#include + #include #include #include @@ -15,3 +17,4 @@ #include "cmd.h" #include "config.h" #include "batch.h" +