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. More...
 
char * dirname (char *path)
 Return directory name from path. More...
 

Function Documentation

◆ FILE_LICENCE()

FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL  )

◆ basename()

char* basename ( char *  path)

Return base name from path.

Parameters
pathFull path
Return values
basenameBase name

Definition at line 42 of file basename.c.

42  {
43  char *basename;
44 
45  basename = strrchr ( path, '/' );
46  return ( basename ? ( basename + 1 ) : path );
47 }
char * strrchr(const char *src, int character)
Find rightmost character within a string.
Definition: string.c:274
char * basename(char *path)
Return base name from path.
Definition: basename.c:42

References basename(), and strrchr().

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

◆ dirname()

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.

57  {
58  char *separator;
59 
60  separator = strrchr ( path, '/' );
61  if ( separator == path ) {
62  return "/";
63  } else if ( separator ) {
64  *separator = 0;
65  return path;
66  } else {
67  return ".";
68  }
69 }
char * strrchr(const char *src, int character)
Find rightmost character within a string.
Definition: string.c:274

References strrchr().

Referenced by nfs_uri_init(), and resolve_path().