aboutsummaryrefslogtreecommitdiffstats
path: root/libskrift_open_font_at.c
blob: 87459917bd6d4b003dd6db6a2166df243b6170b8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* See LICENSE file for copyright and license details. */
#include "common.h"

int
libskrift_open_font_at(LIBSKRIFT_FONT **fontp, int dirfd, const char *path)
{
	int fd, ret, saved_errno;
	if (!*path) {
		return libskrift_open_font_fd(fontp, dirfd);
	} else {
		fd = openat(dirfd, path, O_RDONLY);
		if (fd < 0)
			return -1;
		ret = libskrift_open_font_fd(fontp, fd);
		saved_errno = errno;
		close(fd);
		errno = saved_errno;
		return ret;
	}
}