2 Copyright © 2004, The AROS Development Team. All rights reserved.
5 POSIX function basename().
11 #include <aros/debug.h>
13 /*****************************************************************************
24 Returns the part after the latest '/' of a path.
25 Trailing '/' are not counted as part of the path.
28 filename - Path which should be split.
31 Rightmost part of the path.
44 ******************************************************************************/
49 if (!filename
|| *filename
== '\0')
51 D(bug("basename()=.\n"));
55 uname
= (char *)__path_a2u(filename
);
59 if (pos
[0] == '/' && pos
[1] == '\0')
61 D(bug("basename(/)=/\n"));
65 D(bug("basename(%s)=", filename
));
67 pos
= uname
+ strlen(uname
);
68 while (pos
[-1] == '/')
82 D(bug("%s\n", uname
));