summaryrefslogtreecommitdiff
path: root/src/libunixonacid/opendir_at.c
blob: c1de4f141add2679f493aa4c57d09c4c4b129b0b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* ISC license. */

/* Should not be necessary but old NetBSD/OpenBSD fail to
   properly expose fdopendir() otherwise */
#include <skalibs/nonposix.h>

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

DIR *opendir_at (int dfd, char const *name)
{
  DIR *dir ;
  int fd = openc_readatb(dfd, name) ;
  if (fd < 0) return 0 ;
  dir = fdopendir(fd) ;
  if (!dir) fd_close(fd) ;
  return dir ;
}