2007-03-14 20:24:57 +00:00
|
|
|
#include <precomp.h>
|
|
|
|
#include <direct.h>
|
|
|
|
#include <tchar.h>
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*
|
|
|
|
* _getdcwd (MSVCRT.@)
|
|
|
|
*
|
|
|
|
* Get the current working directory on a given disk.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* drive [I] Drive letter to get the current working directory from.
|
|
|
|
* buf [O] Destination for the current working directory.
|
|
|
|
* size [I] Length of drive in characters.
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: If drive is NULL, returns an allocated string containing the path.
|
|
|
|
* Otherwise populates drive with the path and returns it.
|
|
|
|
* Failure: NULL. errno indicates the error.
|
|
|
|
*/
|
|
|
|
_TCHAR* _tgetdcwd(int drive, _TCHAR * buf, int size)
|
|
|
|
{
|
|
|
|
static _TCHAR* dummy;
|
|
|
|
|
|
|
|
TRACE(":drive %d(%c), size %d\n",drive, drive + 'A' - 1, size);
|
|
|
|
|
|
|
|
if (!drive || drive == _getdrive())
|
|
|
|
return _tgetcwd(buf,size); /* current */
|
|
|
|
else
|
|
|
|
{
|
|
|
|
_TCHAR dir[MAX_PATH];
|
|
|
|
_TCHAR drivespec[] = _T("A:");
|
|
|
|
int dir_len;
|
|
|
|
|
|
|
|
drivespec[0] += drive - 1;
|
|
|
|
if (GetDriveType(drivespec) < DRIVE_REMOVABLE)
|
|
|
|
{
|
[CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.
Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.
svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00
|
|
|
_set_errno(EACCES);
|
2007-03-14 20:24:57 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* GetFullPathName for X: means "get working directory on drive X",
|
|
|
|
* just like passing X: to SetCurrentDirectory means "switch to working
|
|
|
|
* directory on drive X". -Gunnar */
|
|
|
|
dir_len = GetFullPathName(drivespec,MAX_PATH,dir,&dummy);
|
|
|
|
if (dir_len >= size || dir_len < 1)
|
|
|
|
{
|
[CRT]
- Update file.c to recent wine. (now with locking!)
- implement/enable __wcserror, __wcserror_s, _access_s, _ctime32_s, _ctime64_s,
_cwprintf, _fseeki64, _ftelli64, _get_osplatform, _get_output_format,
_get_pgmptr, _get_wpgmptr, _get_terminate, _get_tzname, _get_unexpected,
_gmtime64_s, _i64toa_s, _i64tow_s, _initterm_e, _itoa_s, _itow_s,
_localtime32_s, _localtime64_s, _ltoa_s, _ltow_s, _putwch, _searchenv_s,
_sopen_s, _ui64toa_s, _ui64tow_s, _vcwprintf, _vsprintf_p, _waccess_s,
_wcserror, _wcserror_s, _wfopen_s, _wsopen_s, fopen_s, fprintf_s, fwprintf_s,
printf_s, strerror_s, strncpy_s, strtok_s, vfprintf_s, vfwprintf_s, vprintf_s,
vwprintf_s, wcscat_s, wcsncat_s, wcstok_s, wprintf_s. Most code comes from
wine.
- Fix __set_errno -> _set_errno and export it.
- Remove unneeded files.
[CRT_HEADERS]
- add threadmbcinfo struct.
- update some sec_api headers from mingw64 due to missing or incorrect
functions.
Patch by Samuel Serapion.
Changes to msvcrt spec by me due to winebuild.
CRLF/LF fixes.
svn path=/trunk/; revision=54651
2011-12-14 22:09:24 +00:00
|
|
|
_set_errno(ERANGE);
|
2007-03-14 20:24:57 +00:00
|
|
|
return NULL; /* buf too small */
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE(":returning '%s'\n", dir);
|
|
|
|
if (!buf)
|
|
|
|
return _tcsdup(dir); /* allocate */
|
|
|
|
|
|
|
|
_tcscpy(buf,dir);
|
|
|
|
}
|
|
|
|
return buf;
|
|
|
|
}
|
|
|
|
|
2008-06-06 17:49:24 +00:00
|
|
|
|