diff options
Diffstat (limited to 'wrapper.c')
-rw-r--r-- | wrapper.c | 13 |
1 files changed, 13 insertions, 0 deletions
@@ -375,6 +375,19 @@ FILE *xfdopen(int fd, const char *mode) return stream; } +FILE *fopen_for_writing(const char *path) +{ + FILE *ret = fopen(path, "w"); + + if (!ret && errno == EPERM) { + if (!unlink(path)) + ret = fopen(path, "w"); + else + errno = EPERM; + } + return ret; +} + int xmkstemp(char *template) { int fd; |