Git fork
1#include "../git-compat-util.h"
2#include "../wrapper.h"
3
4ssize_t git_pread(int fd, void *buf, size_t count, off_t offset)
5{
6 off_t current_offset;
7 ssize_t rc;
8
9 current_offset = lseek(fd, 0, SEEK_CUR);
10
11 if (lseek(fd, offset, SEEK_SET) < 0)
12 return -1;
13
14 rc = read_in_full(fd, buf, count);
15
16 if (current_offset != lseek(fd, current_offset, SEEK_SET))
17 return -1;
18 return rc;
19}