]> git.proxmox.com Git - libgit2.git/commitdiff
Can read large file larger than 2GB on Windows
authorLinquize <linquize@yahoo.com.hk>
Sat, 2 Aug 2014 13:57:56 +0000 (21:57 +0800)
committerLinquize <linquize@yahoo.com.hk>
Sun, 10 Aug 2014 14:00:04 +0000 (22:00 +0800)
src/posix.c
src/posix.h

index 7aeb0e6c1a800aa8305895c6230ef3d2163ee633..21b049e1bc62055989b0ce97ea86060ec28e2ca7 100644 (file)
@@ -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)
index 9ef3487399aa92293b9a2812274322b161fc3fb3..71c403c2f0e556774c9e28e83316e9bff3738a62 100644 (file)
@@ -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)