iPXE
Functions
libgen.h File Reference

Go to the source code of this file.

Functions

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

Function Documentation

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )
char* basename ( char *  path)

Return base name from path.

Parameters:
pathFull path
Return values:
basenameBase name

Definition at line 42 of file basename.c.

References basename(), and strrchr().

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

                               {
        char *basename;

        basename = strrchr ( path, '/' );
        return ( basename ? ( basename + 1 ) : path );
}
char* dirname ( char *  path)

Return directory name from path.

Parameters:
pathFull path
Return values:
dirnameDirectory name

Note that this function may modify its argument.

Definition at line 57 of file basename.c.

References strrchr().

Referenced by nfs_uri_init(), and resolve_path().

                              {
        char *separator;

        separator = strrchr ( path, '/' );
        if ( separator == path ) {
                return "/";
        } else if ( separator ) {
                *separator = 0;
                return path;
        } else {
                return ".";
        }
}