1 .\" $OpenBSD: dirname.3,v 1.17 2007/05/31 19:19:28 jmc Exp $
3 .\" Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com>
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.
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.
17 .\" $FreeBSD: src/lib/libc/gen/dirname.3,v 1.10 2008/11/03 05:19:45 delphij Exp $
24 .Nd extract the directory part of a pathname
33 .Fa "const char *path" "char *dname"
38 function is the converse of
40 it returns a pointer to the parent directory of the pathname pointed to by
44 characters are not counted as part of the directory
48 is a null pointer, the empty string, or contains no
52 returns a pointer to the string
54 signifying the current directory.
55 .Sh IMPLEMENTATION NOTES
59 returns a pointer to internal storage space allocated on the first call
60 that will be overwritten
63 is therefore preferred for threaded applications.
65 Other vendor implementations of
67 may modify the contents of the string passed to
69 if portability is desired,
70 this should be taken into account when writing code which calls this function.
72 .Fd #include <libgen.h>
77 .Fa "const char *path"
84 On successful completion,
86 returns a pointer to the parent directory of
91 fails, a null pointer is returned and the global variable
93 is set to indicate the error.
95 The following error codes may be set in
98 .It Bq Er ENAMETOOLONG
99 The path component to be returned was larger than
102 The static buffer used for storing the path in
104 could not be allocated.
119 function first appeared in
125 function first appeared in OS X 10.12.