Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygengetdcwd.c
Go to the documentation of this file.
00001 #include <precomp.h> 00002 #include <direct.h> 00003 #include <tchar.h> 00004 00005 /* 00006 * @implemented 00007 * 00008 * _getdcwd (MSVCRT.@) 00009 * 00010 * Get the current working directory on a given disk. 00011 * 00012 * PARAMS 00013 * drive [I] Drive letter to get the current working directory from. 00014 * buf [O] Destination for the current working directory. 00015 * size [I] Length of drive in characters. 00016 * 00017 * RETURNS 00018 * Success: If drive is NULL, returns an allocated string containing the path. 00019 * Otherwise populates drive with the path and returns it. 00020 * Failure: NULL. errno indicates the error. 00021 */ 00022 _TCHAR* _tgetdcwd(int drive, _TCHAR * buf, int size) 00023 { 00024 static _TCHAR* dummy; 00025 00026 TRACE(":drive %d(%c), size %d\n",drive, drive + 'A' - 1, size); 00027 00028 if (!drive || drive == _getdrive()) 00029 return _tgetcwd(buf,size); /* current */ 00030 else 00031 { 00032 _TCHAR dir[MAX_PATH]; 00033 _TCHAR drivespec[] = _T("A:"); 00034 int dir_len; 00035 00036 drivespec[0] += drive - 1; 00037 if (GetDriveType(drivespec) < DRIVE_REMOVABLE) 00038 { 00039 _set_errno(EACCES); 00040 return NULL; 00041 } 00042 00043 /* GetFullPathName for X: means "get working directory on drive X", 00044 * just like passing X: to SetCurrentDirectory means "switch to working 00045 * directory on drive X". -Gunnar */ 00046 dir_len = GetFullPathName(drivespec,MAX_PATH,dir,&dummy); 00047 if (dir_len >= size || dir_len < 1) 00048 { 00049 _set_errno(ERANGE); 00050 return NULL; /* buf too small */ 00051 } 00052 00053 TRACE(":returning '%s'\n", dir); 00054 if (!buf) 00055 return _tcsdup(dir); /* allocate */ 00056 00057 _tcscpy(buf,dir); 00058 } 00059 return buf; 00060 } 00061 00062 Generated on Sun May 27 2012 04:36:27 for ReactOS by
1.7.6.1
|