diff options
author | Omar Polo <op@omarpolo.com> | 2023-08-08 15:56:27 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2023-08-08 15:56:27 +0000 |
commit | d98ef734940a49d192d87024e60559b38eb190c9 (patch) | |
tree | 9fd986bdf4000c35d8c51d0d5ce557162222acf9 /utils.c | |
parent | 877b479bcc183e71a6d78cb938548c21ed4303fc (diff) |
move strip_path to utils.c
Diffstat (limited to 'utils.c')
-rw-r--r-- | utils.c | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -29,6 +29,23 @@ #include "log.h" +const char * +strip_path(const char *path, int strip) +{ + char *t; + + while (strip > 0) { + if ((t = strchr(path, '/')) == NULL) { + path = strchr(path, '\0'); + break; + } + path = t; + strip--; + } + + return path; +} + int starts_with(const char *str, const char *prefix) { |