From 07a3a7ec8ea22f4069eed2ced54fead2843555dc Mon Sep 17 00:00:00 2001 From: Magnus Olsen Date: Mon, 18 Jul 2005 22:44:13 +0000 Subject: [PATCH] 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. svn path=/trunk/; revision=16636 --- reactos/subsys/system/cmd/cmd.h | 1 + reactos/subsys/system/cmd/internal.c | 40 ++++++++++++++++++++++++++++ reactos/subsys/system/cmd/precomp.h | 3 +++ 3 files changed, 44 insertions(+) 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" +