mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-28 19:47:52 +00:00
Merge pull request #2498 from linquize/read-large-file
Can read large file larger than 2GB on Win64
This commit is contained in:
commit
4c0c001529
@ -151,15 +151,14 @@ int p_rename(const char *from, const char *to)
|
||||
|
||||
#endif /* GIT_WIN32 */
|
||||
|
||||
int p_read(git_file fd, void *buf, size_t cnt)
|
||||
ssize_t p_read(git_file fd, void *buf, size_t cnt)
|
||||
{
|
||||
char *b = buf;
|
||||
|
||||
while (cnt) {
|
||||
ssize_t r;
|
||||
#ifdef GIT_WIN32
|
||||
assert((size_t)((unsigned int)cnt) == cnt);
|
||||
r = read(fd, b, (unsigned int)cnt);
|
||||
r = read(fd, b, cnt > INT_MAX ? INT_MAX : (unsigned int)cnt);
|
||||
#else
|
||||
r = read(fd, b, cnt);
|
||||
#endif
|
||||
@ -173,7 +172,7 @@ int p_read(git_file fd, void *buf, size_t cnt)
|
||||
cnt -= r;
|
||||
b += r;
|
||||
}
|
||||
return (int)(b - (char *)buf);
|
||||
return (b - (char *)buf);
|
||||
}
|
||||
|
||||
int p_write(git_file fd, const void *buf, size_t cnt)
|
||||
|
@ -97,7 +97,7 @@ typedef int git_file;
|
||||
* Use your manpages to check the docs on these.
|
||||
*/
|
||||
|
||||
extern int p_read(git_file fd, void *buf, size_t cnt);
|
||||
extern ssize_t p_read(git_file fd, void *buf, size_t cnt);
|
||||
extern int p_write(git_file fd, const void *buf, size_t cnt);
|
||||
|
||||
#define p_close(fd) close(fd)
|
||||
|
Loading…
Reference in New Issue
Block a user