https://github.com/git/git
Raw File
Tip revision: 28bc30220f30850a10217d61f73e46d8a541e670 authored by Junio C Hamano on 28 May 2008, 05:20:53 UTC
GIT 1.5.5.3
Tip revision: 28bc302
pread.c
#include "../git-compat-util.h"

ssize_t git_pread(int fd, void *buf, size_t count, off_t offset)
{
        off_t current_offset;
        ssize_t rc;

        current_offset = lseek(fd, 0, SEEK_CUR);

        if (lseek(fd, offset, SEEK_SET) < 0)
                return -1;

        rc = read_in_full(fd, buf, count);

        if (current_offset != lseek(fd, current_offset, SEEK_SET))
                return -1;
        return rc;
}
back to top