ReactOS 0.4.15-dev-5667-ged97270
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 */
8int _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:756
#define MAX_PATH
Definition: compat.h:34
BOOL WINAPI DECLSPEC_HOTPATCH SetEnvironmentVariableW(IN LPCWSTR lpName, IN LPCWSTR lpValue)
Definition: environ.c:259
#define _tchdir
Definition: tchar.h:672
char _TCHAR
Definition: tchar.h:1392
#define L(x)
Definition: ntvdm.h:50
void _dosmaperr(unsigned long oserrcode)
Definition: errno.c:81
#define towupper(c)
Definition: wctype.h:99
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
#define SetCurrentDirectory
Definition: winbase.h:3774
__wchar_t WCHAR
Definition: xmlstorage.h:180