kbd: use a better get_key method
[thunix.git] / fs / fslib.c
blob8e239e182d872c09730780f1cceedf811d732270
1 #include <stdio.h>
2 #include <string.h>
3 #include <malloc.h>
5 const char *get_base_name(const char *path_org)
7 char *p;
8 char *path = strdup(path_org);
10 p = strrchr(path, '/');
11 if (!p) {
12 free(path);
13 return path_org;
15 /* the /linux/hello/ case */
16 if (*(p + 1) == 0) {
17 *p = 0;
18 p--;
19 while (*p != '/' && p >= path) {
20 *p = 0;
21 p--;
23 if (p < path)
24 return NULL;
27 return p + 1;