summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinquize <linquize@yahoo.com.hk>2014-08-02 21:57:56 +0800
committerLinquize <linquize@yahoo.com.hk>2014-08-10 22:00:04 +0800
commitc6ba8a3765101adf61d7064e34519d2ff7512941 (patch)
tree9cb354efa54bfe8f67b4926a9b75a23d9499642c
parent59403f1ff55346c64bfaa0744ea7f3375da71725 (diff)
downloadlibgit2-c6ba8a3765101adf61d7064e34519d2ff7512941.tar.gz
Can read large file larger than 2GB on Windows
-rw-r--r--src/posix.c7
-rw-r--r--src/posix.h2
2 files changed, 4 insertions, 5 deletions
diff --git a/src/posix.c b/src/posix.c
index 7aeb0e6c1..21b049e1b 100644
--- a/src/posix.c
+++ b/src/posix.c
@@ -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)
diff --git a/src/posix.h b/src/posix.h
index 9ef348739..71c403c2f 100644
--- a/src/posix.h
+++ b/src/posix.h
@@ -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)