File and Path Function
char *getcwd(char *buffer, int maxlen);
char *_getcwd(char *buffer, int maxlen);
wchar_t *_wgetcwd(wchar_t *buffer, int maxlen);
TCHAR *_tgetcwd(TCHAR *buffer, int maxlen);
Internationalization (I18n) Function Overview
The getcwd and _getcwd functions copy an absolute pathname of the
current working directory to the array pointed to by buffer , which is of
maxlen byte size, and returns a pointer to the result.
On Windows platforms and when using the GNU C Library version of getcwd , buffer can be NULL , in which case, an array is allocated using
malloc to store the path. This buffer can later be freed by calling free and passing it the _getcwd
return value (a pointer to the allocated buffer).
In the event of an error,
NULL is returned, and the global error errno is set either to
ENOMEM , indicating that there is insufficient memory to allocate maxlen
bytes (when a NULL is given as buffer ), or to ERANGE ,
indicating that the path (including the terminating null character) is longer than maxlen bytes.
On Windows platforms, _wgetcwd is the wide-character version of _getcwd ;
its argument and return are wide-character strings, and maxlen is the number of
wide-characters. There is no ANSI wide-character equivalent.
_tgetcwd is the Windows-only Generic version of the function; with the _MBCS or _UNICODE compiler flags determining its mapping to either _getcwd or _wgetcwd .
I18n Issues
Use the appropriate version of the function as required for internationalization support,
ensuring that maxlen is correct for the chosen platform. See
Locale-Sensitive Length Functions for a discussion on single-byte and wide
character sizes.
On ANSI UTF-16 platforms, use a conversion function to convert the
the return from the call to getcwd to a wide-character string.
See Pathnames for a discussion of path and filename considerations in
an internationalized application.
Recommended Replacements*
*If you're already using the recommended function, see I18n Issues for other reasons why Globalyzer is detecting the function.
File and Path Functions
|