fix a small bug in cd, it did make all char lower case. done by me and Brandon Turner. clean up CD source bit more. Bug fix GetRootPath. it did not accepted upper case as driver letter. done by me

svn path=/trunk/; revision=17051
This commit is contained in:
Magnus Olsen 2005-08-04 22:08:16 +00:00
parent b760d02f8f
commit 3f935aa835

View file

@ -170,13 +170,8 @@ INT GetRootPath(TCHAR *InPath,TCHAR *OutPath,INT size)
{ {
if (InPath[1]==_T(':')) if (InPath[1]==_T(':'))
{ {
TCHAR num[2];
INT t=0; INT t=0;
num[1] = _T('\0');
num[0] = InPath[0];
_tcslwr(num);
if ((InPath[0] >= _T('0')) && (InPath[0] <= _T('9'))) if ((InPath[0] >= _T('0')) && (InPath[0] <= _T('9')))
{ {
t = (InPath[0] - _T('0')) +28; t = (InPath[0] - _T('0')) +28;
@ -185,6 +180,12 @@ INT GetRootPath(TCHAR *InPath,TCHAR *OutPath,INT size)
if ((InPath[0] >= _T('a')) && (InPath[0] <= _T('z'))) if ((InPath[0] >= _T('a')) && (InPath[0] <= _T('z')))
{ {
t = (InPath[0] - _T('a')) +1; t = (InPath[0] - _T('a')) +1;
InPath[0] = t + _T('A') - 1;
}
if ((InPath[0] >= _T('A')) && (InPath[0] <= _T('Z')))
{
t = (InPath[0] - _T('A')) +1;
} }
if (_tgetdcwd(t,OutPath,size) != NULL) if (_tgetdcwd(t,OutPath,size) != NULL)
@ -214,8 +215,10 @@ BOOL SetRootPath(TCHAR *InPath)
{ {
TCHAR oldpath[MAX_PATH]; TCHAR oldpath[MAX_PATH];
TCHAR OutPath[MAX_PATH]; TCHAR OutPath[MAX_PATH];
TCHAR OutPathUpper[MAX_PATH];
BOOL fail; BOOL fail;
/* Get The current directory path and save it */ /* Get The current directory path and save it */
fail = GetCurrentDirectory(MAX_PATH,oldpath); fail = GetCurrentDirectory(MAX_PATH,oldpath);
if (!fail) if (!fail)
@ -225,18 +228,23 @@ BOOL SetRootPath(TCHAR *InPath)
if (_tcsncicmp(&InPath[1],_T(":\\"),2)!=0) if (_tcsncicmp(&InPath[1],_T(":\\"),2)!=0)
{ {
if (!GetRootPath(InPath,OutPath,MAX_PATH)) if (!GetRootPath(InPath,OutPathUpper,MAX_PATH))
_tcscpy(OutPath,InPath); _tcscpy(OutPathUpper,InPath);
} }
else else
{ {
_tcscpy(OutPath,InPath); _tcscpy(OutPathUpper,InPath);
} }
_tcsupr(OutPathUpper);
GetLongPathName(OutPathUpper, OutPath, MAX_PATH);
fail = SetCurrentDirectory(OutPath); fail = SetCurrentDirectory(OutPath);
if (!fail) if (!fail)
return 1; return 1;
SetCurrentDirectory(OutPath); SetCurrentDirectory(OutPath);
GetCurrentDirectory(MAX_PATH,OutPath); GetCurrentDirectory(MAX_PATH,OutPath);
_tchdir(OutPath); _tchdir(OutPath);
@ -302,7 +310,6 @@ INT cmd_chdir (LPTSTR cmd, LPTSTR param)
} }
ConOutPuts(szCurrent); ConOutPuts(szCurrent);
return 0; return 0;
} }
/* Get Current Directory */ /* Get Current Directory */
@ -376,17 +383,22 @@ INT cmd_chdir (LPTSTR cmd, LPTSTR param)
else else
break; break;
_tcscat(szFinalPath,f.cFileName); _tcscat(szFinalPath,f.cFileName);
if(IsExistingDirectory(szFinalPath)) if ((f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)
{ {
if(!SetRootPath(szFinalPath)) if(!SetRootPath(szFinalPath))
{ {
/* Change for /D */ /* Change for /D */
if(bChangeDrive) if(bChangeDrive)
SetCurrentDirectory(szFinalPath); {
_tcsupr(szFinalPath);
GetLongPathName(szFinalPath, szPath, MAX_PATH);
SetCurrentDirectory(szPath);
}
return 0; return 0;
} }
} }
}while(FindNextFile (hFile, &f)); }while(FindNextFile (hFile, &f));