Merge branch 'jt/doc-submitting-rerolled-series'
[alt-git.git] / compat / pread.c
blob484e6d4c716ef6b6c3e5b24ff5a1879db3039d5d
1 #include "../git-compat-util.h"
2 #include "../wrapper.h"
4 ssize_t git_pread(int fd, void *buf, size_t count, off_t offset)
6 off_t current_offset;
7 ssize_t rc;
9 current_offset = lseek(fd, 0, SEEK_CUR);
11 if (lseek(fd, offset, SEEK_SET) < 0)
12 return -1;
14 rc = read_in_full(fd, buf, count);
16 if (current_offset != lseek(fd, current_offset, SEEK_SET))
17 return -1;
18 return rc;