Nut/OS  4.10.3
API Reference
libgen.h File Reference

Path name parts. More...

#include <sys/types.h>
Include dependency graph for libgen.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

char * basename (CONST char *)
 Return the last component from a given pathname.
char * dirname (CONST char *)
 Extract the directory part of a given pathname.

Detailed Description

Path name parts.

 *
 * $Log$
 * Revision 1.1  2006/08/01 07:42:56  haraldkipp
 * New functions extract last component and parent directory from pathnames.
 *
 *
 * 

Definition in file libgen.h.


Function Documentation

char* basename ( CONST char *  path)

Return the last component from a given pathname.

Trailing slashes are removed.

Note:
This function returns a pointer to internal static storage space that will be overwritten by subsequent calls.
Parameters:
pathPointer to the pathname.
Returns:
Pointer to the last component. If the specified pathname contains slashes only, a single slash is returned. If the pathname is empty or a NULL pointer, then a single dot is returned. In case of any error, a NULL pointer is returned and the global variable errno is set to indicate the error.

Definition at line 71 of file basename.c.

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

Here is the call graph for this function:

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: