ReactOS  0.4.14-dev-50-g13bb5e2
chdir.c
Go to the documentation of this file.
1 #include <precomp.h>
2 #include <tchar.h>
3 #include <process.h>
4 
5 /*
6  * @implemented
7  */
8 int _tchdir(const _TCHAR* _path)
9 {
10  WCHAR newdir[MAX_PATH];
11 
12  if (!SetCurrentDirectory(_path))
13  {
14  _dosmaperr(_path ? GetLastError() : 0);
15  return -1;
16  }
17 
18  /* Update the drive-specific current directory variable */
19  if (GetCurrentDirectoryW(MAX_PATH, newdir) >= 2)
20  {
21  if (newdir[1] == L':')
22  {
23  WCHAR envvar[4] = { L'=', towupper(newdir[0]), L':', L'\0' };
24  SetEnvironmentVariableW(envvar, newdir);
25  }
26  }
27 
28  return 0;
29 }
#define GetCurrentDirectoryW(x, y)
Definition: compat.h:413
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
char _TCHAR
Definition: tchar.h:1392
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableW(IN LPCWSTR lpName, IN LPCWSTR lpValue)
Definition: environ.c:259
static const WCHAR L[]
Definition: oid.c:1250
void _dosmaperr(unsigned long oserrcode)
Definition: errno.c:81
#define towupper(c)
Definition: wctype.h:99
int _tchdir(const _TCHAR *_path)
Definition: chdir.c:8
#define SetCurrentDirectory
Definition: winbase.h:3720