mirror of
https://github.com/autc04/Retro68.git
synced 2024-12-11 03:52:59 +00:00
28 lines
508 B
C
28 lines
508 B
C
#ifndef _NO_BASENAME
|
|
/* Copyright 2005 Shaun Jackman
|
|
* Permission to use, copy, modify, and distribute this software
|
|
* is freely granted, provided that this notice is preserved.
|
|
*/
|
|
|
|
#include <libgen.h>
|
|
#include <string.h>
|
|
|
|
char*
|
|
basename (char *path)
|
|
{
|
|
char *p;
|
|
if( path == NULL || *path == '\0' )
|
|
return ".";
|
|
p = path + strlen(path) - 1;
|
|
while( *p == '/' ) {
|
|
if( p == path )
|
|
return path;
|
|
*p-- = '\0';
|
|
}
|
|
while( p >= path && *p != '/' )
|
|
p--;
|
|
return p + 1;
|
|
}
|
|
|
|
#endif /* !_NO_BASENAME */
|