Nut/OS  4.10.3
API Reference
dirname.c File Reference

Extracts the directory part of a pathname. More...

#include <errno.h>
#include <libgen.h>
#include <stdlib.h>
#include <string.h>
#include <memdebug.h>
Include dependency graph for dirname.c:

Go to the source code of this file.

Defines

#define MAXPATHLEN   256

Functions

char * dirname (CONST char *path)
 Extract the directory part of a given pathname.

Detailed Description

Extracts the directory part of a pathname.

 *
 * $Log$
 * Revision 1.2  2009/02/13 14:52:05  haraldkipp
 * Include memdebug.h for heap management debugging support.
 *
 * Revision 1.1  2006/08/01 07:42:56  haraldkipp
 * New functions extract last component and parent directory from pathnames.
 *
 *
 * 

Definition in file dirname.c.


Define Documentation

#define MAXPATHLEN   256

Definition at line 35 of file dirname.c.

Referenced by dirname().


Function Documentation

char* dirname ( CONST char *  path)

Extract the directory part of a given pathname.

This is the converse of basename().

Parameters:
pathPointer to the pathname.
Returns:
A pointer to the parent directory of the pathname. Any trailing slash is not counted as part of the directory name. If the specified pathname is a null pointer, an empty string, or contains no slash character, then a single dot is returned. On failures, a NULL pointer is returned and the global variable errno is set to indicate the error.

Definition at line 70 of file dirname.c.

References CONST, ENAMETOOLONG, errno, malloc(), MAXPATHLEN, strcpy(), strlen(), and strncpy().

Here is the call graph for this function: