mirror of
https://github.com/git/git
synced 2024-08-27 19:49:21 +00:00
![Elijah Newren](/assets/img/avatar_default.png)
cache.h's nature of a dumping ground of includes prevented it from
being included in some compat/ files, forcing us into a workaround
of having a double forward declaration of the read_in_full() function
(see commit 14086b0a13
("compat/pread.c: Add a forward declaration to
fix a warning", 2007-11-17)). Now that we have moved functions like
read_in_full() from cache.h to wrapper.h, and wrapper.h isn't littered
with unrelated and scary #defines, get rid of the extra forward
declaration and just have compat/pread.c include wrapper.h.
Signed-off-by: Elijah Newren <newren@gmail.com>
Acked-by: Calvin Wan <calvinwan@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
20 lines
457 B
C
20 lines
457 B
C
#include "../git-compat-util.h"
|
|
#include "../wrapper.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;
|
|
}
|