From: Lucas De Marchi Date: Wed, 7 Dec 2011 15:50:52 +0000 (-0200) Subject: Add helper path_is_absolute() X-Git-Tag: v1~76 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a468809b8c9a18c009ec85c2a5ad42d3fe9b314;p=thirdparty%2Fkmod.git Add helper path_is_absolute() --- diff --git a/libkmod/libkmod-private.h b/libkmod/libkmod-private.h index e0cdd558..58ac0db1 100644 --- a/libkmod/libkmod-private.h +++ b/libkmod/libkmod-private.h @@ -116,6 +116,7 @@ ssize_t read_str_safe(int fd, char *buf, size_t buflen) __must_check __attribute int read_str_long(int fd, long *value, int base) __must_check __attribute__((nonnull(2))); int read_str_ulong(int fd, unsigned long *value, int base) __must_check __attribute__((nonnull(2))); char *strchr_replace(char *s, int c, char r); +bool path_is_absolute(const char *p) __must_check __attribute__((nonnull(1))); #endif diff --git a/libkmod/libkmod-util.c b/libkmod/libkmod-util.c index 58ba1d3a..477139f5 100644 --- a/libkmod/libkmod-util.c +++ b/libkmod/libkmod-util.c @@ -214,3 +214,10 @@ char *strchr_replace(char *s, int c, char r) return s; } + +bool path_is_absolute(const char *p) +{ + assert(p != NULL); + + return p[0] == '/'; +}