3 #include <internal/debug.h>
11 * Get the current working directory on a given disk.
14 * drive [I] Drive letter to get the current working directory from.
15 * buf [O] Destination for the current working directory.
16 * size [I] Length of drive in characters.
19 * Success: If drive is NULL, returns an allocated string containing the path.
20 * Otherwise populates drive with the path and returns it.
21 * Failure: NULL. errno indicates the error.
23 _TCHAR
* _tgetdcwd(int drive
, _TCHAR
* buf
, int size
)
27 TRACE(":drive %d(%c), size %d\n",drive
, drive
+ 'A' - 1, size
);
29 if (!drive
|| drive
== _getdrive())
30 return _tgetcwd(buf
,size
); /* current */
34 _TCHAR drivespec
[] = _T("A:");
37 drivespec
[0] += drive
- 1;
38 if (GetDriveType(drivespec
) < DRIVE_REMOVABLE
)
44 /* GetFullPathName for X: means "get working directory on drive X",
45 * just like passing X: to SetCurrentDirectory means "switch to working
46 * directory on drive X". -Gunnar */
47 dir_len
= GetFullPathName(drivespec
,MAX_PATH
,dir
,&dummy
);
48 if (dir_len
>= size
|| dir_len
< 1)
51 return NULL
; /* buf too small */
54 TRACE(":returning '%s'\n", dir
);
56 return _tcsdup(dir
); /* allocate */