blob: 484e6d4c716ef6b6c3e5b24ff5a1879db3039d5d [file] [log] [blame]
Stefan-W. Hahn69006792007-01-09 22:04:12 +01001#include "../git-compat-util.h"
Elijah Newren65156bb2023-04-11 00:42:02 -07002#include "../wrapper.h"
Stefan-W. Hahn69006792007-01-09 22:04:12 +01003
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}