mirror of
https://github.com/reactos/reactos.git
synced 2025-06-10 04:14:53 +00:00
[CMD] CHDIR: Adjust ERROR_FILE_NOT_FOUND into ERROR_PATH_NOT_FOUND if _tchdir() fails.
This commit is contained in:
parent
9871becced
commit
f43ee81573
1 changed files with 10 additions and 1 deletions
|
@ -184,6 +184,7 @@ GetRootPath(
|
||||||
|
|
||||||
BOOL SetRootPath(TCHAR *oldpath, TCHAR *InPath)
|
BOOL SetRootPath(TCHAR *oldpath, TCHAR *InPath)
|
||||||
{
|
{
|
||||||
|
DWORD dwLastError;
|
||||||
TCHAR OutPath[MAX_PATH];
|
TCHAR OutPath[MAX_PATH];
|
||||||
TCHAR OutPathTemp[MAX_PATH];
|
TCHAR OutPathTemp[MAX_PATH];
|
||||||
|
|
||||||
|
@ -191,7 +192,10 @@ BOOL SetRootPath(TCHAR *oldpath, TCHAR *InPath)
|
||||||
|
|
||||||
/* Retrieve the full path name from the (possibly relative) InPath */
|
/* Retrieve the full path name from the (possibly relative) InPath */
|
||||||
if (GetFullPathName(InPath, ARRAYSIZE(OutPathTemp), OutPathTemp, NULL) == 0)
|
if (GetFullPathName(InPath, ARRAYSIZE(OutPathTemp), OutPathTemp, NULL) == 0)
|
||||||
|
{
|
||||||
|
dwLastError = GetLastError();
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
}
|
||||||
|
|
||||||
/* Convert the full path to its correct case.
|
/* Convert the full path to its correct case.
|
||||||
* Example: c:\windows\SYSTEM32 => C:\WINDOWS\System32 */
|
* Example: c:\windows\SYSTEM32 => C:\WINDOWS\System32 */
|
||||||
|
@ -200,7 +204,12 @@ BOOL SetRootPath(TCHAR *oldpath, TCHAR *InPath)
|
||||||
/* Use _tchdir(), since unlike SetCurrentDirectory() it updates
|
/* Use _tchdir(), since unlike SetCurrentDirectory() it updates
|
||||||
* the current-directory-on-drive environment variables. */
|
* the current-directory-on-drive environment variables. */
|
||||||
if (_tchdir(OutPath) != 0)
|
if (_tchdir(OutPath) != 0)
|
||||||
|
{
|
||||||
|
dwLastError = GetLastError();
|
||||||
|
if (dwLastError == ERROR_FILE_NOT_FOUND)
|
||||||
|
dwLastError = ERROR_PATH_NOT_FOUND;
|
||||||
goto Fail;
|
goto Fail;
|
||||||
|
}
|
||||||
|
|
||||||
/* Keep the original drive in ordinary CD/CHDIR (without /D switch) */
|
/* Keep the original drive in ordinary CD/CHDIR (without /D switch) */
|
||||||
if (oldpath != NULL && _tcsncicmp(OutPath, oldpath, 2) != 0)
|
if (oldpath != NULL && _tcsncicmp(OutPath, oldpath, 2) != 0)
|
||||||
|
@ -209,7 +218,7 @@ BOOL SetRootPath(TCHAR *oldpath, TCHAR *InPath)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
||||||
Fail:
|
Fail:
|
||||||
ConErrFormatMessage(GetLastError());
|
ConErrFormatMessage(dwLastError);
|
||||||
nErrorLevel = 1;
|
nErrorLevel = 1;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue