Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
dirname(3)
Edit
PageHistory
Diff
Info
LikePages
DIRNAME !!!DIRNAME NAME SYNOPSIS DESCRIPTION EXAMPLE RETURN VALUE BUGS CONFORMING TO SEE ALSO ---- !!NAME dirname, basename - Parse pathname components !!SYNOPSIS __#include __ ''*path''__); char *basename(char__ ''*path''__); __ !!DESCRIPTION __dirname__ and __basename__ break a null-terminated pathname string into directory and filename components. In the usual case, __dirname__ returns the string up to, but not including, the final '/', and __basename__ returns the component following the final '/'. Trailing '/' characters are not counted as part of the pathname. If ''path'' does not contain a slash, __dirname__ returns the string __basename__ returns a copy of ''path''. If ''path'' is the string ''dirname__ and __basename__ return the string __path'' is a NULL pointer or points to an empty string, then both __dirname__ and __basename__ return the string __ Concatenating the string returned by __dirname__, a __basename__ yields a complete pathname. Both __dirname__ and __basename__ may modify the contents of ''path'', so if you need to preserve the pathname string, copies should be passed to these functions. Furthermore, __dirname__ and __basename__ may return pointers to statically allocated memory which may overwritten by subsequent calls. The following list of examples (taken from SUSv2) shows the strings returned by __dirname__ and __basename__ for different paths: __path dirname basename __ __ !!EXAMPLE char *dirc, *basec, *bname, *dname; char *path = !!RETURN VALUE Both __dirname__ and __basename__ return pointers to null-terminated strings. !!BUGS In versions of glibc up to and including 2.2.1, __dirname__ does not correctly handle pathnames with trailing '/' characters, and generates a segmentation violation if given a NULL argument. !!CONFORMING TO SUSv2 !!SEE ALSO dirname(1), basename(1), ----
One page links to
dirname(3)
:
Man3d
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.