ReactOS 0.4.15-dev-7705-g2320c37
chdir.c File Reference
#include <precomp.h>
#include <tchar.h>
#include <process.h>
Include dependency graph for chdir.c:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int _tchdir (const _TCHAR *_path)
 

Function Documentation

◆ _tchdir()

int _tchdir ( const _TCHAR _path)

Definition at line 8 of file chdir.c.

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 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:1042
#define SetCurrentDirectory
Definition: winbase.h:3838
__wchar_t WCHAR
Definition: xmlstorage.h:180