gno/usr.man/man3/basename.3
gdr-ftp 2495ce287f basename.3:
dirname now returns "." instead of "" for arguments containing
	no directory components
fgets.3:
	added a GNO note about streams opened in binary mode.
1998-04-11 19:13:41 +00:00

70 lines
1.4 KiB
Groff

.\"
.\" Routines and man page by Devin Reade
.\"
.\" $Id: basename.3,v 1.2 1998/04/11 19:13:41 gdr-ftp Exp $
.\"
.TH BASENAME 3 "29 March 1998" GNO "Library Routines"
.SH NAME
.BR basename ,
.BR dirname
\- get components of a pathname
.SH SYNOPSIS
#include <unistd.h>
.sp 1
char *\fBbasename\fR (const char *\fIpath\fR);
.br
char *\fBdirname\fR (const char *\fIpath\fR);
.SH DESCRIPTION
.B basename
returns a pointer to the file component of
.IR path .
If
.I path
ends with a directory separator, then
.B basename
returns an empty string.
.LP
.B dirname
returns a pointer to an internal buffer containing the directory
component of
.IR path ,
without a trailing directory separator.
If
.I path
ends with a directory separator, then that character is the only part
of
.I path
not included in the resultant string.
If
.I path
contains no directory separator, then the string \fB"."\fR is returned.
If
.I path
is NULL, an empty string is returned.
.LP
Unlike
.BR ExpandPathGS (2),
.BR dirname
does not expand any GS/OS prefixes that may be present in
.IR path .
.LP
Under GS/OS, permissable directory separators are
.B :
and
.BR / ,
with the former taking precedence.
.SH COMPATIBILITY
.BR basename
is thread-safe;
.BR dirname
is not.
.SH BUGS
If
.IR path
is longer than PATH_MAX characters,
.BR dirname
will only consider the first PATH_MAX-1 characters.
.SH AUTHOR
Devin Reade <gdr@myrias.com>