openwritevnclose_suffix6.c (596B)
1 /* ISC license. */ 2 3 #include <string.h> 4 #include <stdio.h> 5 6 #include <skalibs/posixplz.h> 7 #include <skalibs/djbunix.h> 8 9 int openwritevnclose_suffix6 (char const *fn, struct iovec const *v, unsigned int n, devino *devino, unsigned int options, char const *suffix) 10 { 11 size_t len = strlen(fn) ; 12 size_t suffixlen = strlen(suffix) ; 13 char tmp[len + suffixlen + 1] ; 14 memcpy(tmp, fn, len) ; 15 memcpy(tmp + len, suffix, suffixlen + 1) ; 16 if (!openwritevnclose_unsafe5(tmp, v, n, devino, options)) return 0 ; 17 if (rename(tmp, fn) < 0) 18 { 19 unlink_void(tmp) ; 20 return 0 ; 21 } 22 return 1 ; 23 }