| #include "../git-compat-util.h" |
| /* Adapted from libiberty's basename.c. */ |
| char *gitbasename (char *path) |
| skip_dos_drive_prefix(&path); |
| for (base = path; *path; path++) { |
| } while (is_dir_sep(*path)); |
| while (--path != base && is_dir_sep(*path)) |
| char *gitdirname(char *path) |
| static struct strbuf buf = STRBUF_INIT; |
| char *p = path, *slash = NULL, c; |
| if ((dos_drive_prefix = skip_dos_drive_prefix(&p)) && !*p) |
| * POSIX.1-2001 says dirname("/") should return "/", and dirname("//") |
| * should return "//", but dirname("///") should return "/" again. |
| if (!p[1] || (is_dir_sep(p[1]) && !p[2])) |
| /* POSIX.1-2001 says to ignore trailing slashes */ |
| strbuf_addf(&buf, "%.*s.", dos_drive_prefix, path); |