openwritenclose_unsafe5.c (422B)
1 /* ISC license. */ 2 3 #include <errno.h> 4 #include <unistd.h> 5 6 #include <skalibs/posixplz.h> 7 #include <skalibs/djbunix.h> 8 9 int openwritenclose_unsafe5 (char const *fn, char const *s, size_t len, devino *devino, unsigned int options) 10 { 11 int fd = openc_trunc(fn) ; 12 if (fd < 0) return 0 ; 13 if (!writenclose_unsafe5(fd, s, len, devino, options)) 14 { 15 fd_close(fd) ; 16 unlink_void(fn) ; 17 return 0 ; 18 } 19 return 1 ; 20 }