Last change
on this file since 2842 was 2725, checked in by Bruno Cornec, 14 years ago |
- Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
|
File size:
869 bytes
|
Rev | Line | |
---|
[821] | 1 | /* vi: set sw=4 ts=4: */
|
---|
| 2 | /*
|
---|
| 3 | * bb_get_last_path_component implementation for busybox
|
---|
| 4 | *
|
---|
| 5 | * Copyright (C) 2001 Manuel Novoa III <mjn3@codepoet.org>
|
---|
| 6 | *
|
---|
[2725] | 7 | * Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
---|
[821] | 8 | */
|
---|
| 9 |
|
---|
| 10 | #include "libbb.h"
|
---|
[2725] | 11 | /*
|
---|
| 12 | * "/" -> "/"
|
---|
| 13 | * "abc" -> "abc"
|
---|
| 14 | * "abc/def" -> "def"
|
---|
| 15 | * "abc/def/" -> ""
|
---|
| 16 | */
|
---|
| 17 | char* FAST_FUNC bb_get_last_path_component_nostrip(const char *path)
|
---|
[821] | 18 | {
|
---|
[2725] | 19 | char *slash = strrchr(path, '/');
|
---|
[821] | 20 |
|
---|
[2725] | 21 | if (!slash || (slash == path && !slash[1]))
|
---|
| 22 | return (char*)path;
|
---|
[821] | 23 |
|
---|
[2725] | 24 | return slash + 1;
|
---|
| 25 | }
|
---|
[821] | 26 |
|
---|
[2725] | 27 | /*
|
---|
| 28 | * "/" -> "/"
|
---|
| 29 | * "abc" -> "abc"
|
---|
| 30 | * "abc/def" -> "def"
|
---|
| 31 | * "abc/def/" -> "def" !!
|
---|
| 32 | */
|
---|
| 33 | char* FAST_FUNC bb_get_last_path_component_strip(char *path)
|
---|
| 34 | {
|
---|
| 35 | char *slash = last_char_is(path, '/');
|
---|
[821] | 36 |
|
---|
[2725] | 37 | if (slash)
|
---|
| 38 | while (*slash == '/' && slash != path)
|
---|
| 39 | *slash-- = '\0';
|
---|
| 40 |
|
---|
| 41 | return bb_get_last_path_component_nostrip(path);
|
---|
[821] | 42 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.