Fixed text file auto-detection: treat EOF character 032 at the end of file as printable
[git/platforms.git] / compat / pread.c
blobce299977246dcc9532ea7664a3ddc00fb0e455fb
1 #include "../git-compat-util.h"
3 int read_in_full(int fd, void *buf, size_t count);
5 ssize_t git_pread(int fd, void *buf, size_t count, off_t offset)
7 off_t current_offset;
8 ssize_t rc;
10 current_offset = lseek(fd, 0, SEEK_CUR);
12 if (lseek(fd, offset, SEEK_SET) < 0)
13 return -1;
15 rc = read_in_full(fd, buf, count);
17 if (current_offset != lseek(fd, current_offset, SEEK_SET))
18 return -1;
19 return rc;