basename.c File Reference

Get base name of path. More...

#include <string.h>
#include <libgen.h>

Go to the source code of this file.

Functions

 FILE_LICENCE (GPL2_OR_LATER)
char * basename (char *path)
 Return base name from path.
char * dirname (char *path)
 Return directory name from path.


Detailed Description

Get base name of path.

Definition in file basename.c.


Function Documentation

FILE_LICENCE ( GPL2_OR_LATER   ) 

char* basename ( char *  path  ) 

Return base name from path.

Parameters:
path Full path
Return values:
basename Base name

Definition at line 37 of file basename.c.

References basename(), and strrchr().

Referenced by basename(), image_set_uri(), and imgfetch_core_exec().

00037                                {
00038         char *basename;
00039 
00040         basename = strrchr ( path, '/' );
00041         return ( basename ? ( basename + 1 ) : path );
00042 }

char* dirname ( char *  path  ) 

Return directory name from path.

Parameters:
path Full path
Return values:
dirname Directory name
Note that this function may modify its argument.

Definition at line 52 of file basename.c.

References strrchr().

Referenced by resolve_path().

00052                               {
00053         char *separator;
00054 
00055         separator = strrchr ( path, '/' );
00056         if ( separator == path ) {
00057                 return "/";
00058         } else if ( separator ) {
00059                 *separator = 0;
00060                 return path;
00061         } else {
00062                 return ".";
00063         }
00064 }


Generated on Tue Apr 6 20:01:14 2010 for gPXE by  doxygen 1.5.7.1