summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mdk-stage1/utils.c14
-rw-r--r--mdk-stage1/utils.h1
2 files changed, 15 insertions, 0 deletions
diff --git a/mdk-stage1/utils.c b/mdk-stage1/utils.c
index 492061887..af5ee9af3 100644
--- a/mdk-stage1/utils.c
+++ b/mdk-stage1/utils.c
@@ -179,3 +179,17 @@ void lowercase(char *s)
i++;
}
}
+
+char *my_dirname(char *path) {
+ char *p = strrchr (path, '/');
+ char *tmp;
+ int len;
+ if (!p)
+ return path;
+ len = p-path+1;
+ tmp = malloc(len);
+ strncpy(tmp, path, len-1);
+ tmp[len-1] = '\0';
+ return tmp;
+}
+
diff --git a/mdk-stage1/utils.h b/mdk-stage1/utils.h
index d0d7ae617..d42c52d06 100644
--- a/mdk-stage1/utils.h
+++ b/mdk-stage1/utils.h
@@ -28,6 +28,7 @@ char ** list_directory(char * direct);
int string_array_length(char ** a);
char * asprintf_(const char *msg, ...);
int scall_(int retval, char * msg, char * file, int line);
+char *my_dirname(char *path);
#define scall(retval, msg) scall_(retval, msg, __FILE__, __LINE__)
void lowercase(char *s);