aboutsummaryrefslogtreecommitdiffstats
path: root/src/libunixonacid/openslurpnclose_at.c
blob: 8880a717507dc68a885edddf1e0a4f3cc6997a15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/* ISC license. */

#include <skalibs/djbunix.h>
#include <skalibs/unix-transactional.h>

int openslurpnclose_at (int dirfd, char const *fn, stralloc *sa, size_t n)
{
  int fd = openc_readatb(dirfd, fn) ;
  if (fd < 0) return 0 ;
  if (!slurpn(fd, sa, n))
  {
    fd_close(fd) ;
    return 0 ;
  }
  fd_close(fd) ;
  return 1 ;
}