Last change
on this file since 577 was
444,
checked in by satin@…, 6 years ago
|
add newlib,libalmos-mkh, restructure shared_syscalls.h and mini-libc
|
File size:
508 bytes
|
Line | |
---|
1 | #ifndef _NO_BASENAME |
---|
2 | /* Copyright 2005 Shaun Jackman |
---|
3 | * Permission to use, copy, modify, and distribute this software |
---|
4 | * is freely granted, provided that this notice is preserved. |
---|
5 | */ |
---|
6 | |
---|
7 | #include <libgen.h> |
---|
8 | #include <string.h> |
---|
9 | |
---|
10 | char* |
---|
11 | basename (char *path) |
---|
12 | { |
---|
13 | char *p; |
---|
14 | if( path == NULL || *path == '\0' ) |
---|
15 | return "."; |
---|
16 | p = path + strlen(path) - 1; |
---|
17 | while( *p == '/' ) { |
---|
18 | if( p == path ) |
---|
19 | return path; |
---|
20 | *p-- = '\0'; |
---|
21 | } |
---|
22 | while( p >= path && *p != '/' ) |
---|
23 | p--; |
---|
24 | return p + 1; |
---|
25 | } |
---|
26 | |
---|
27 | #endif /* !_NO_BASENAME */ |
---|
Note: See
TracBrowser
for help on using the repository browser.