diff options
author | Lennart Poettering <lennart@poettering.net> | 2013-09-25 20:58:23 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2013-09-25 21:04:35 +0200 |
commit | fecffe5d0a1bd66d80e5a8728ff8a89673be0df7 (patch) | |
tree | 133a9f9b0dc791723a1e63fa6efb5fafa4a8ba60 /src/shared/path-util.h | |
parent | bc5fb0809e6f5784888f30057708548f14dcb459 (diff) |
util: add macro for iterating through all prefixes of a path
Syntactic sugar in a macro PATH_FOREACH_PREFIX.
Diffstat (limited to 'src/shared/path-util.h')
-rw-r--r-- | src/shared/path-util.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/shared/path-util.h b/src/shared/path-util.h index 9452931586..03f2cf273c 100644 --- a/src/shared/path-util.h +++ b/src/shared/path-util.h @@ -51,3 +51,6 @@ int path_is_read_only_fs(const char *path); int path_is_os_tree(const char *path); int find_binary(const char *name, char **filename); + +#define PATH_FOREACH_PREFIX(prefix, path) \ + for (char *_slash = strrchr(path_kill_slashes(strcpy(prefix, path)), '/'); _slash && !(*_slash = 0); _slash = strrchr((prefix), '/')) |