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 } 30