From 3a468809b8c9a18c009ec85c2a5ad42d3fe9b314 Mon Sep 17 00:00:00 2001 From: Lucas De Marchi Date: Wed, 7 Dec 2011 13:50:52 -0200 Subject: [PATCH] Add helper path_is_absolute() --- libkmod/libkmod-private.h | 1 + libkmod/libkmod-util.c | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/libkmod/libkmod-private.h b/libkmod/libkmod-private.h index e0cdd55..58ac0db 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 58ba1d3..477139f 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] == '/'; +}