diff options
author | Colin Walters <walters@verbum.org> | 2015-03-05 09:02:48 -0500 |
---|---|---|
committer | Colin Walters <walters@verbum.org> | 2015-03-05 09:02:48 -0500 |
commit | 175502e5bee236123d27adf4be01e8ba8fe2b178 (patch) | |
tree | b6f25277c0808d69d270a10674bc907a1decc259 /glnx-fdio.h | |
parent | a11b2eb20aa20db8076eb5fc86848d50cb6b6477 (diff) | |
download | libglnx-175502e5bee236123d27adf4be01e8ba8fe2b178.tar.gz |
Add glnx_basename()
We have to wrap the glibc version to ensure we get the right version,
otherwise depending on the variance of includes we may end up crashing
if we get the POSIX version.
Diffstat (limited to 'glnx-fdio.h')
-rw-r--r-- | glnx-fdio.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/glnx-fdio.h b/glnx-fdio.h index 688eeb2..19f938c 100644 --- a/glnx-fdio.h +++ b/glnx-fdio.h @@ -26,9 +26,24 @@ #include <sys/stat.h> #include <fcntl.h> #include <attr/xattr.h> +/* From systemd/src/shared/util.h */ +/* When we include libgen.h because we need dirname() we immediately + * undefine basename() since libgen.h defines it as a macro to the XDG + * version which is really broken. */ +#include <libgen.h> +#undef basename G_BEGIN_DECLS +/* Irritatingly, g_basename() which is what we want + * is deprecated. + */ +static inline +const char *glnx_basename (const char *path) +{ + return (basename) (path); +} + GBytes * glnx_fd_readall_bytes (int fd, GCancellable *cancellable, |