https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f43ee81573273dde924f6c...
commit f43ee81573273dde924f6cbbcad5e7e424e8f27c Author: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org AuthorDate: Sun Jul 12 16:23:01 2020 +0200 Commit: Hermès Bélusca-Maïto hermes.belusca-maito@reactos.org CommitDate: Wed Aug 19 20:36:08 2020 +0200
[CMD] CHDIR: Adjust ERROR_FILE_NOT_FOUND into ERROR_PATH_NOT_FOUND if _tchdir() fails. --- base/shell/cmd/internal.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/base/shell/cmd/internal.c b/base/shell/cmd/internal.c index 3f2c1b6b233..0dc3eaba2bd 100644 --- a/base/shell/cmd/internal.c +++ b/base/shell/cmd/internal.c @@ -184,6 +184,7 @@ GetRootPath(
BOOL SetRootPath(TCHAR *oldpath, TCHAR *InPath) { + DWORD dwLastError; TCHAR OutPath[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 */ if (GetFullPathName(InPath, ARRAYSIZE(OutPathTemp), OutPathTemp, NULL) == 0) + { + dwLastError = GetLastError(); goto Fail; + }
/* Convert the full path to its correct case. * Example: c:\windows\SYSTEM32 => C:\WINDOWS\System32 */ @@ -200,7 +204,12 @@ BOOL SetRootPath(TCHAR *oldpath, TCHAR *InPath) /* Use _tchdir(), since unlike SetCurrentDirectory() it updates * the current-directory-on-drive environment variables. */ if (_tchdir(OutPath) != 0) + { + dwLastError = GetLastError(); + if (dwLastError == ERROR_FILE_NOT_FOUND) + dwLastError = ERROR_PATH_NOT_FOUND; goto Fail; + }
/* Keep the original drive in ordinary CD/CHDIR (without /D switch) */ if (oldpath != NULL && _tcsncicmp(OutPath, oldpath, 2) != 0) @@ -209,7 +218,7 @@ BOOL SetRootPath(TCHAR *oldpath, TCHAR *InPath) return TRUE;
Fail: - ConErrFormatMessage(GetLastError()); + ConErrFormatMessage(dwLastError); nErrorLevel = 1; return FALSE; }