X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fbasic%2Frm-rf.h;h=e13f7003e3e73d515466ff91bfc15e9be58376fc;hb=9b00a533195b7fec54a791ca02090e0799214770;hp=96579eb1828e6f2cc2e0af9787f9e0e116aaf914;hpb=3b22396a4b2767a98172f6915929c47738cb0a1e;p=elogind.git diff --git a/src/basic/rm-rf.h b/src/basic/rm-rf.h index 96579eb18..e13f7003e 100644 --- a/src/basic/rm-rf.h +++ b/src/basic/rm-rf.h @@ -1,5 +1,3 @@ -/*-*- Mode: C; c-basic-offset: 8; indent-tabs-mode: nil -*-*/ - #pragma once /*** @@ -32,3 +30,10 @@ typedef enum RemoveFlags { int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev); int rm_rf(const char *path, RemoveFlags flags); + +/* Useful for usage with _cleanup_(), destroys a directory and frees the pointer */ +static inline void rm_rf_physical_and_free(char *p) { + (void) rm_rf(p, REMOVE_ROOT|REMOVE_PHYSICAL); + free(p); +} +DEFINE_TRIVIAL_CLEANUP_FUNC(char*, rm_rf_physical_and_free);