block: don't put spaces around :
[ironout.git] / path.c
blob5fff529dde3f04ee8c529f52445ad20091eabeff
1 #include <string.h>
2 #include "path.h"
4 void dirname(char *dir, char *path)
6 char *slash = strrchr(path, '/');
7 if (slash) {
8 size_t len = slash - path + 1;
9 memcpy(dir, path, len);
10 dir[len] = '\0';
11 } else {
12 strcpy(dir, "./");
16 void basename(char *name, char *path)
18 char *slash = strrchr(path, '/');
19 if (slash)
20 strcpy(name, slash + 1);
21 else
22 strcpy(name, path);