ReactOS  0.4.14-dev-376-gaedba84
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:421
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
__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
#define SetCurrentDirectory
Definition: winbase.h:3727

Referenced by _tmain(), CommandPopd(), and SetRootPath().