diff options
Diffstat (limited to 'libbb/get_last_path_component.c')
-rw-r--r-- | libbb/get_last_path_component.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/libbb/get_last_path_component.c b/libbb/get_last_path_component.c index 72598d22e..db4be68ad 100644 --- a/libbb/get_last_path_component.c +++ b/libbb/get_last_path_component.c | |||
@@ -6,8 +6,21 @@ | |||
6 | * | 6 | * |
7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree. |
8 | */ | 8 | */ |
9 | |||
10 | #include "libbb.h" | 9 | #include "libbb.h" |
10 | |||
11 | const char* FAST_FUNC bb_basename(const char *name) | ||
12 | { | ||
13 | const char *cp = strrchr(name, '/'); | ||
14 | if (cp) | ||
15 | return cp + 1; | ||
16 | #if ENABLE_PLATFORM_MINGW32 | ||
17 | cp = strrchr(name, '\\'); | ||
18 | if (cp) | ||
19 | return cp + 1; | ||
20 | #endif | ||
21 | return name; | ||
22 | } | ||
23 | |||
11 | /* | 24 | /* |
12 | * "/" -> "/" | 25 | * "/" -> "/" |
13 | * "abc" -> "abc" | 26 | * "abc" -> "abc" |