]> git.saurik.com Git - apple/libc.git/blame - gen/FreeBSD/dirname.3
Libc-763.12.tar.gz
[apple/libc.git] / gen / FreeBSD / dirname.3
CommitLineData
1f2f436a 1.\" $OpenBSD: dirname.3,v 1.17 2007/05/31 19:19:28 jmc Exp $
5b2abdfb
A
2.\"
3.\" Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
5b2abdfb 4.\"
1f2f436a
A
5.\" Permission to use, copy, modify, and distribute this software for any
6.\" purpose with or without fee is hereby granted, provided that the above
7.\" copyright notice and this permission notice appear in all copies.
5b2abdfb 8.\"
1f2f436a
A
9.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
5b2abdfb 16.\"
1f2f436a 17.\" $FreeBSD: src/lib/libc/gen/dirname.3,v 1.10 2008/11/03 05:19:45 delphij Exp $
5b2abdfb 18.\"
1f2f436a 19.Dd October 12, 2006
5b2abdfb
A
20.Dt DIRNAME 3
21.Os
22.Sh NAME
23.Nm dirname
9385eb3d 24.Nd extract the directory part of a pathname
5b2abdfb
A
25.Sh SYNOPSIS
26.In libgen.h
27.Ft char *
28.Fn dirname "const char *path"
29.Sh DESCRIPTION
30The
31.Fn dirname
1f2f436a 32function is the converse of
5b2abdfb
A
33.Xr basename 3 ;
34it returns a pointer to the parent directory of the pathname pointed to by
9385eb3d 35.Fa path .
5b2abdfb
A
36Any trailing
37.Sq \&/
38characters are not counted as part of the directory
39name.
40If
9385eb3d 41.Fa path
5b2abdfb
A
42is a null pointer, the empty string, or contains no
43.Sq \&/
44characters,
45.Fn dirname
46returns a pointer to the string
47.Qq \&. ,
48signifying the current directory.
1f2f436a
A
49.Sh IMPLEMENTATION NOTES
50The
51.Fn dirname
52function
53returns a pointer to internal storage space allocated on the first call
54that will be overwritten
55by subsequent calls.
56.Pp
57Other vendor implementations of
58.Fn dirname
59may modify the contents of the string passed to
60.Fn dirname ;
61this should be taken into account when writing code which calls this function
62if portability is desired.
5b2abdfb
A
63.Sh RETURN VALUES
64On successful completion,
65.Fn dirname
66returns a pointer to the parent directory of
9385eb3d 67.Fa path .
5b2abdfb
A
68.Pp
69If
70.Fn dirname
71fails, a null pointer is returned and the global variable
72.Va errno
73is set to indicate the error.
74.Sh ERRORS
75The following error codes may be set in
76.Va errno :
77.Bl -tag -width Er
78.It Bq Er ENAMETOOLONG
79The path component to be returned was larger than
80.Dv MAXPATHLEN .
81.El
5b2abdfb
A
82.Sh SEE ALSO
83.Xr basename 1 ,
84.Xr dirname 1 ,
85.Xr basename 3
86.Sh STANDARDS
87The
88.Fn dirname
89function conforms to
90.St -xpg4.2 .
91.Sh HISTORY
92The
93.Fn dirname
94function first appeared in
95.Ox 2.2
96and
97.Fx 4.2 .
98.Sh AUTHORS
1f2f436a 99.An "Todd C. Miller"