make GetRootPath bit smarter Modified: trunk/reactos/subsys/system/cmd/internal.c _____
Modified: trunk/reactos/subsys/system/cmd/internal.c --- trunk/reactos/subsys/system/cmd/internal.c 2005-07-18 23:04:39 UTC (rev 16637) +++ trunk/reactos/subsys/system/cmd/internal.c 2005-07-19 01:36:54 UTC (rev 16638) @@ -159,33 +159,44 @@
INT GetRootPath(TCHAR *InPath,TCHAR *OutPath,INT size) { INT retcode = 1; - INT t; +
if (_tcslen(InPath)>1) { - if (InPath[1]==_T(':')) + if (InPath[1]==_T(':')) { - for (t=0;t<32;t++) - { - if (_tgetdcwd(t,OutPath,size) != NULL) - { - if (_tcsncicmp(InPath,OutPath,2)) - { - retcode = 0; - return retcode; - } - } - } - } - } + TCHAR num[2]; + INT t=0; + + num[1] = _T('\0'); + num[0] = InPath[0]; + _tcslwr(num); + + if ((InPath[0] >= _T('0')) && (InPath[0] <= _T('9'))) + { + t = (InPath[0] - _T('0')) +28; + } + + if ((InPath[0] >= _T('a')) && (InPath[0] <= _T('z'))) + { + t = (InPath[0] - _T('a')) +1; + } + + if (_tgetdcwd(t,OutPath,size) != NULL) + { + return 0; + } + } + }
- /* fail to getting path devic did not exists */ + /* fail */ if (_tcslen(InPath)>1) { if (InPath[1]==_T(':')) return 1; }
+ /* Get current directory */ retcode = GetCurrentDirectory(size,OutPath); if (retcode==0) return 1; @@ -220,6 +231,7 @@
nErrorLevel = 0;
+ /* The whole param string is our parameter these days. The only thing we do is eliminating every quotation mark */ /* Is it safe to change the characters param is pointing to? I presume it is, as there doesn't seem to be any post-processing of it after the function call (what would that accomplish?) */