17b1fac00SXin LI.\" $OpenBSD: dirname.3,v 1.17 2007/05/31 19:19:28 jmc Exp $ 21250db81SDag-Erling Smørgrav.\" 31250db81SDag-Erling Smørgrav.\" Copyright (c) 1997 Todd C. Miller <Todd.Miller@courtesan.com> 41250db81SDag-Erling Smørgrav.\" 57b1fac00SXin LI.\" Permission to use, copy, modify, and distribute this software for any 67b1fac00SXin LI.\" purpose with or without fee is hereby granted, provided that the above 77b1fac00SXin LI.\" copyright notice and this permission notice appear in all copies. 81250db81SDag-Erling Smørgrav.\" 97b1fac00SXin LI.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES 107b1fac00SXin LI.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF 117b1fac00SXin LI.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR 127b1fac00SXin LI.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES 137b1fac00SXin LI.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN 147b1fac00SXin LI.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF 157b1fac00SXin LI.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 161250db81SDag-Erling Smørgrav.\" 17fd85bff5SEd Schouten.Dd September 5, 2016 181250db81SDag-Erling Smørgrav.Dt DIRNAME 3 191250db81SDag-Erling Smørgrav.Os 201250db81SDag-Erling Smørgrav.Sh NAME 211250db81SDag-Erling Smørgrav.Nm dirname 2257bd0fc6SJens Schweikhardt.Nd extract the directory part of a pathname 231250db81SDag-Erling Smørgrav.Sh SYNOPSIS 2432eef9aeSRuslan Ermilov.In libgen.h 251250db81SDag-Erling Smørgrav.Ft char * 26938809f9SEd Schouten.Fn dirname "char *path" 271250db81SDag-Erling Smørgrav.Sh DESCRIPTION 281250db81SDag-Erling SmørgravThe 291250db81SDag-Erling Smørgrav.Fn dirname 307b1fac00SXin LIfunction is the converse of 311250db81SDag-Erling Smørgrav.Xr basename 3 ; 321250db81SDag-Erling Smørgravit returns a pointer to the parent directory of the pathname pointed to by 335c564baeSRuslan Ermilov.Fa path . 341250db81SDag-Erling SmørgravAny trailing 351250db81SDag-Erling Smørgrav.Sq \&/ 361250db81SDag-Erling Smørgravcharacters are not counted as part of the directory 371250db81SDag-Erling Smørgravname. 38*3d54bd22SEnji Cooper.Sh IMPLEMENTATION NOTES 39*3d54bd22SEnji CooperThis implementation of 40*3d54bd22SEnji Cooper.Fn dirname 41*3d54bd22SEnji Cooperuses the buffer provided by the caller to store the resulting parent 42*3d54bd22SEnji Cooperdirectory. 43*3d54bd22SEnji CooperOther vendor implementations may return a pointer to internal storage 44*3d54bd22SEnji Cooperspace instead. 45*3d54bd22SEnji CooperThe advantage of the former approach is that it ensures thread-safety, 46*3d54bd22SEnji Cooperwhile also placing no upper limit on the supported length of the 47*3d54bd22SEnji Cooperpathname. 48e2f68161SEd Schouten.Sh RETURN VALUES 491250db81SDag-Erling SmørgravIf 505c564baeSRuslan Ermilov.Fa path 511250db81SDag-Erling Smørgravis a null pointer, the empty string, or contains no 521250db81SDag-Erling Smørgrav.Sq \&/ 531250db81SDag-Erling Smørgravcharacters, 541250db81SDag-Erling Smørgrav.Fn dirname 551250db81SDag-Erling Smørgravreturns a pointer to the string 561250db81SDag-Erling Smørgrav.Qq \&. , 571250db81SDag-Erling Smørgravsignifying the current directory. 58e2f68161SEd SchoutenOtherwise, 59e2f68161SEd Schoutenit returns a pointer to the parent directory of 605c564baeSRuslan Ermilov.Fa path . 611250db81SDag-Erling Smørgrav.Sh SEE ALSO 621250db81SDag-Erling Smørgrav.Xr basename 1 , 631250db81SDag-Erling Smørgrav.Xr dirname 1 , 641250db81SDag-Erling Smørgrav.Xr basename 3 651250db81SDag-Erling Smørgrav.Sh STANDARDS 661250db81SDag-Erling SmørgravThe 671250db81SDag-Erling Smørgrav.Fn dirname 681250db81SDag-Erling Smørgravfunction conforms to 691250db81SDag-Erling Smørgrav.St -xpg4.2 . 701250db81SDag-Erling Smørgrav.Sh HISTORY 711250db81SDag-Erling SmørgravThe 721250db81SDag-Erling Smørgrav.Fn dirname 731250db81SDag-Erling Smørgravfunction first appeared in 748dfd7bcdSDavid E. O'Brien.Ox 2.2 758dfd7bcdSDavid E. O'Brienand 768dfd7bcdSDavid E. O'Brien.Fx 4.2 . 77e2f68161SEd Schouten.Pp 78e2f68161SEd SchoutenIn 79e2f68161SEd Schouten.Fx 12.0 , 80e2f68161SEd Schoutenthis function was reimplemented to store its result in the provided 81e2f68161SEd Schouteninput buffer. 82251c176fSRuslan Ermilov.Sh AUTHORS 83e2f68161SEd Schouten.An Nuxi, the Netherlands 84