Nut/OS  4.10.3
API Reference
basename.c File Reference

Returns last component of a pathname. More...

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

Go to the source code of this file.

Defines

#define MAXPATHLEN   256

Functions

char * basename (CONST char *path)
 Return the last component from a given pathname.

Detailed Description

Returns last component 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 basename.c.


Define Documentation

#define MAXPATHLEN   256

Definition at line 52 of file basename.c.

Referenced by basename().


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: