mirror of
https://github.com/reactos/reactos.git
synced 2024-12-26 17:14:41 +00:00
Add a new function to return a path with correct casing. Remove the get[short/long]pathname hack that was there before to do it.
svn path=/trunk/; revision=18889
This commit is contained in:
parent
23d5494796
commit
7aebf134dc
3 changed files with 50 additions and 9 deletions
|
@ -300,6 +300,7 @@ BOOL IsValidPathName (LPCTSTR);
|
|||
BOOL IsExistingFile (LPCTSTR);
|
||||
BOOL IsExistingDirectory (LPCTSTR);
|
||||
BOOL FileGetString (HANDLE, LPTSTR, INT);
|
||||
VOID GetPathCase(TCHAR *, TCHAR *);
|
||||
|
||||
#define PROMPT_NO 0
|
||||
#define PROMPT_YES 1
|
||||
|
|
|
@ -241,8 +241,8 @@ BOOL SetRootPath(TCHAR *InPath)
|
|||
/* The use of both of these together will correct the case of a path
|
||||
where as one alone or GetFullPath will not. Exameple:
|
||||
c:\windows\SYSTEM32 => C:\WINDOWS\system32 */
|
||||
GetShortPathName(OutPathTemp, OutPathTemp2, MAX_PATH);
|
||||
GetLongPathName(OutPathTemp2, OutPath, MAX_PATH);
|
||||
GetFullPathName(OutPathTemp, MAX_PATH, OutPathTemp2, NULL);
|
||||
GetPathCase(OutPathTemp2, OutPath);
|
||||
|
||||
fail = SetCurrentDirectory(OutPath);
|
||||
if (!fail)
|
||||
|
@ -395,19 +395,19 @@ INT cmd_chdir (LPTSTR cmd, LPTSTR param)
|
|||
_tcscat(szFinalPath,f.cFileName);
|
||||
|
||||
if ((f.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)
|
||||
{
|
||||
{
|
||||
if(!SetRootPath(szFinalPath))
|
||||
{
|
||||
/* Change for /D */
|
||||
if(bChangeDrive)
|
||||
{
|
||||
_tcsupr(szFinalPath);
|
||||
GetLongPathName(szFinalPath, szPath, MAX_PATH);
|
||||
SetCurrentDirectory(szPath);
|
||||
}
|
||||
{
|
||||
_tcsupr(szFinalPath);
|
||||
GetPathCase(szFinalPath, szPath);
|
||||
SetCurrentDirectory(szPath);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}while(FindNextFile (hFile, &f));
|
||||
|
||||
|
|
|
@ -68,6 +68,46 @@ TCHAR cgetchar (VOID)
|
|||
#endif /* _UNICODE */
|
||||
}
|
||||
|
||||
/*
|
||||
* Takes a path in and returns it with the correct case of the letters
|
||||
*/
|
||||
VOID GetPathCase( TCHAR * Path, TCHAR * OutPath)
|
||||
{
|
||||
INT i = 0;
|
||||
_tcscpy(OutPath, _T(""));
|
||||
TCHAR TempPath[MAX_PATH];
|
||||
WIN32_FIND_DATA FindFileData;
|
||||
HANDLE hFind;
|
||||
_tcscpy(TempPath, _T(""));
|
||||
|
||||
|
||||
for(i = 0; i < _tcslen(Path); i++)
|
||||
{
|
||||
if(Path[i] != _T('\\'))
|
||||
{
|
||||
_tcsncat(TempPath, &Path[i], 1);
|
||||
if(i != _tcslen(Path) - 1)
|
||||
continue;
|
||||
}
|
||||
/* Handle the base part of the path different.
|
||||
Because if you put it into findfirstfile, it will
|
||||
return your current folder */
|
||||
if(_tcslen(TempPath) == 2 && TempPath[1] == _T(':'))
|
||||
{
|
||||
_tcscat(OutPath, TempPath);
|
||||
_tcscat(OutPath, _T("\\"));
|
||||
_tcscat(TempPath, _T("\\"));
|
||||
}
|
||||
else
|
||||
{
|
||||
hFind = FindFirstFile(TempPath,&FindFileData);
|
||||
_tcscat(TempPath, _T("\\"));
|
||||
_tcscat(OutPath, FindFileData.cFileName);
|
||||
_tcscat(OutPath, _T("\\"));
|
||||
CloseHandle(hFind);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Check if Ctrl-Break was pressed during the last calls
|
||||
|
|
Loading…
Reference in a new issue