path-util: Add path_simplify_full()
Sometimes its useful to keep a trailing slash in the path so let's add path_simplify_full() and a flag to do just that.
This commit is contained in:
@@ -76,7 +76,14 @@ char* path_extend_internal(char **x, ...);
|
||||
#define path_extend(x, ...) path_extend_internal(x, __VA_ARGS__, POINTER_MAX)
|
||||
#define path_join(...) path_extend_internal(NULL, __VA_ARGS__, POINTER_MAX)
|
||||
|
||||
char* path_simplify(char *path);
|
||||
typedef enum PathSimplifyFlags {
|
||||
PATH_SIMPLIFY_KEEP_TRAILING_SLASH = 1 << 0,
|
||||
} PathSimplifyFlags;
|
||||
|
||||
char *path_simplify_full(char *path, PathSimplifyFlags flags);
|
||||
static inline char* path_simplify(char *path) {
|
||||
return path_simplify_full(path, 0);
|
||||
}
|
||||
|
||||
static inline bool path_equal_ptr(const char *a, const char *b) {
|
||||
return !!a == !!b && (!a || path_equal(a, b));
|
||||
|
||||
Reference in New Issue
Block a user