Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages | Examples

libgen.h File Reference


Detailed Description

Path name parts.

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


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.


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:
path Pointer 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.

char* dirname CONST char *  path  ) 
 

Extract the directory part of a given pathname.

This is the converse of basename().

Parameters:
path Pointer 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.


© 2000-2006 by egnite Software GmbH - visit http://www.ethernut.de/