Write "Mac OS X" instead of "MacOS X".
[gnulib.git] / doc / posix-functions / getcwd.texi
1 @node getcwd
2 @section @code{getcwd}
3 @findex getcwd
4
5 POSIX specification:@* @url{http://www.opengroup.org/onlinepubs/9699919799/functions/getcwd.html}
6
7 Gnulib module: getcwd or getcwd-lgpl
8
9 Portability problems fixed by either Gnulib module @code{getcwd} or
10 @code{getcwd-lgpl}:
11 @itemize
12 @item
13 This function is declared in different header files (namely, @code{<io.h>} or
14 @code{<direct.h>}) on some platforms:
15 mingw, MSVC 9.
16 @item
17 On glibc platforms, @code{getcwd (NULL, n)} allocates memory for the result.
18 On some other platforms, this call is not allowed.
19 @item
20 On some platforms, the prototype for @code{getcwd} uses @code{int}
21 instead of @code{size_t} for the size argument when using non-standard
22 headers, and the declaration is missing from @code{<unistd.h>}:
23 mingw, MSVC 9.
24 @item
25 On some platforms, @code{getcwd (buf, 0)} fails with @code{ERANGE}
26 instead of the required @code{EINVAL}:
27 mingw, MSVC 9.
28 @end itemize
29
30 Portability problems fixed by Gnulib module @code{getcwd}:
31 @itemize
32 @item
33 This function is missing on some older platforms.
34 @item
35 This function does not handle long file names (greater than @code{PATH_MAX})
36 correctly on some platforms:
37 glibc on Linux 2.4.20, Mac OS X 10.5, FreeBSD 6.4, NetBSD 5.1, OpenBSD 4.9, AIX 7.1.
38 @end itemize
39
40 Portability problems not fixed by Gnulib:
41 @itemize
42 @item
43 When using @code{getcwd(NULL, nonzero)}, some platforms, such as glibc
44 or cygwin, allocate exactly @code{nonzero} bytes and fail with
45 @code{ERANGE} if it was not big enough, while other platforms, such as
46 FreeBSD, mingw, or MSVC 9, ignore the size argument and allocate whatever size
47 is necessary.  If this call succeeds, an application cannot portably
48 access beyond the string length of the result.
49 @end itemize