*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->IRIX man pages -> dirname (3g)              
Title
Content
Arch
Section
 

Contents


dirname(3G)							   dirname(3G)


NAME    [Toc]    [Back]

     dirname - report the parent directory name	of a file pathname

SYNOPSIS    [Toc]    [Back]

     cc	[flag <b>...] file	... -lgen [library <b>...]

     #include <libgen.h>
     char *dirname (char *path);

DESCRIPTION    [Toc]    [Back]

     Given a pointer to	a null-terminated character string that	contains a
     filesystem	pathname, dirname returns a pointer to a static	constant
     string that is the	parent directory of that file.	In doing this, it
     sometimes places a	null byte in the pathname after	the next to last
     element, so the content of	path must be disposable.  Trailing ``/''
     characters	in the path are	not counted as part of the path.

     If	path or	*path is zero, a pointer to a static constant ``.'' is
     returned.

     dirname and basename together yield a complete pathname.  dirname (path<b>)
     is	the directory where basename (path<b>) is found.

EXAMPLES    [Toc]    [Back]

     A simple filename and the strings ``.'' and ``..''	all have ``.''	as
     their return value.
     Input string   Output pointer
     _____________________________
     /usr/lib	    /usr
     /usr/	    /
     usr	    .
     /		    /
     .		    .
     ..		    .

     The following code	reads a	pathname, changes directory to the appropriate
     directory (see chdir(2)), and opens the file.

     char path[100], *pathcopy;
     int fd;
     gets (path);
     pathcopy =	strdup (path);
     chdir (dirname (pathcopy) );
     fd	= open (basename (path), O_RDONLY);

SEE ALSO    [Toc]    [Back]

      
      
     basename(1), chdir(2), basename(3G)


									PPPPaaaaggggeeee 1111
[ Back ]
 Similar pages
Name OS Title
acl_get_file Tru64 Given the pathname to a file or directory, retrieve the designated ACL
create_child HP-UX Creates a child pointer at the master replica of the parent directory
getcwd FreeBSD get working directory pathname
getwd Tru64 Get current directory pathname
getcwd NetBSD get working directory pathname
getcwd Tru64 Get the pathname of the current directory
getwd NetBSD get working directory pathname
getwd OpenBSD get working directory pathname
getwd FreeBSD get working directory pathname
pxfgetcwd IRIX Gets the pathname of the working directory
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service