aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.c6
-rw-r--r--lib/lib.h1
2 files changed, 7 insertions, 0 deletions
diff --git a/lib/lib.c b/lib/lib.c
index 510b830b..985c580d 100644
--- a/lib/lib.c
+++ b/lib/lib.c
@@ -178,6 +178,12 @@ void xaccess(char *path, int flags)
if (access(path, flags)) perror_exit("Can't access '%s'\n", path);
}
+// Die unless we can delete a file. (File must exist to be deleted.)
+void xunlink(char *path)
+{
+ if (unlink(path)) perror_exit("unlink '%s'", path);
+}
+
// Die unless we can open/create a file, returning file descriptor.
int xcreate(char *path, int flags, int mode)
{
diff --git a/lib/lib.h b/lib/lib.h
index fdead960..28ff0da8 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -60,6 +60,7 @@ void xputc(char c);
void xflush(void);
void xexec(char **argv);
void xaccess(char *path, int flags);
+void xunlink(char *path);
int xcreate(char *path, int flags, int mode);
int xopen(char *path, int flags);
void xclose(int fd);