Loading...
--- Libc/Libc-391/stdio/FreeBSD/fopen.3
+++ Libc/Libc-997.90.3/stdio/FreeBSD/fopen.3
@@ -13,10 +13,6 @@
.\" 2. Redistributions in binary form must reproduce the above copyright
.\" notice, this list of conditions and the following disclaimer in the
.\" documentation and/or other materials provided with the distribution.
-.\" 3. All advertising materials mentioning features or use of this software
-.\" must display the following acknowledgement:
-.\" This product includes software developed by the University of
-.\" California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\" may be used to endorse or promote products derived from this software
.\" without specific prior written permission.
@@ -34,14 +30,14 @@
.\" SUCH DAMAGE.
.\"
.\" @(#)fopen.3 8.1 (Berkeley) 6/4/93
-.\" $FreeBSD: src/lib/libc/stdio/fopen.3,v 1.18 2003/01/26 10:01:59 tjr Exp $
+.\" $FreeBSD: src/lib/libc/stdio/fopen.3,v 1.21 2009/09/09 19:38:19 ed Exp $
.\"
.Dd January 26, 2003
.Dt FOPEN 3
.Os
.Sh NAME
+.Nm fdopen ,
.Nm fopen ,
-.Nm fdopen ,
.Nm freopen
.Nd stream open functions
.Sh LIBRARY
@@ -49,17 +45,27 @@
.Sh SYNOPSIS
.In stdio.h
.Ft FILE *
-.Fn fopen "const char * restrict path" "const char * restrict mode"
+.Fo fdopen
+.Fa "int fildes"
+.Fa "const char *mode"
+.Fc
.Ft FILE *
-.Fn fdopen "int fildes" "const char *mode"
+.Fo fopen
+.Fa "const char *restrict filename"
+.Fa "const char *restrict mode"
+.Fc
.Ft FILE *
-.Fn freopen "const char *path" "const char *mode" "FILE *stream"
+.Fo freopen
+.Fa "const char *restrict filename"
+.Fa "const char *restrict mode"
+.Fa "FILE *restrict stream"
+.Fc
.Sh DESCRIPTION
The
.Fn fopen
function
opens the file whose name is the string pointed to by
-.Fa path
+.Fa filename
and associates a stream with it.
.Pp
The argument
@@ -74,7 +80,7 @@
Open for reading and writing.
The stream is positioned at the beginning of the file.
.It Dq Li w
-Truncate file to zero length or create text file for writing.
+Truncate to zero length or create text file for writing.
The stream is positioned at the beginning of the file.
.It Dq Li w+
Open for reading and writing.
@@ -100,12 +106,23 @@
.Pp
The
.Fa mode
-string can also include the letter ``b'' either as a third character or
+string can also include the letter ``b'' either as last character or
as a character between the characters in any of the two-character strings
described above.
This is strictly for compatibility with
.St -isoC
and has no effect; the ``b'' is ignored.
+.Pp
+Finally, as an extension to the standards (and thus may not be portable),
+.Fa mode
+string may end with the letter ``x'', which insists on creating a new file
+when used with ``w'' or ``a''.
+If
+.Fa path
+exists, then an error is returned (this is the equivalent of specifying
+.Dv O_EXCL
+with
+.Xr open 2 ) .
.Pp
Any created files will have mode
.Pf \\*q Dv S_IRUSR
@@ -148,7 +165,7 @@
.Fn freopen
function
opens the file whose name is the string pointed to by
-.Fa path
+.Fa filename
and associates the stream pointed to by
.Fa stream
with it.
@@ -160,7 +177,7 @@
function.
.Pp
If the
-.Fa path
+.Fa filename
argument is
.Dv NULL ,
.Fn freopen
@@ -204,7 +221,7 @@
.Sh RETURN VALUES
Upon successful completion
.Fn fopen ,
-.Fn fdopen
+.Fn fdopen ,
and
.Fn freopen
return a