1 #include <precomp.h> 2 #include <direct.h> 3 #include <process.h> 4 #include <tchar.h> 5 6 /* 7 * @implemented 8 */ 9 _TCHAR* _tgetcwd(_TCHAR* buf, int size) 10 { 11 _TCHAR dir[MAX_PATH]; 12 DWORD dir_len = GetCurrentDirectory(MAX_PATH,dir); 13 14 if (dir_len == 0) 15 { 16 _dosmaperr(GetLastError()); 17 return NULL; /* FIXME: Real return value untested */ 18 } 19 20 if (!buf) 21 { 22 return _tcsdup(dir); 23 } 24 25 if (dir_len >= (DWORD)size) 26 { 27 _set_errno(ERANGE); 28 return NULL; /* buf too small */ 29 } 30 31 _tcscpy(buf,dir); 32 return buf; 33 } 34