diff options
author | Bram Moolenaar <Bram@vim.org> | 2016-07-01 17:17:39 +0200 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2016-07-01 17:17:39 +0200 |
commit | 8767f52fbfd4f053ce00a978227c95f1d7d323fe (patch) | |
tree | ac0cb33815d6e9d41f9b7a6b4ee4335e6076feaa /src/os_mswin.c | |
parent | 4a6c670b844a3ef9aec865a8216eaf363bab8721 (diff) | |
download | vim-8767f52fbfd4f053ce00a978227c95f1d7d323fe.zip |
patch 7.4.1975
Problem: On MS-Windows large files (> 2Gbyte) cause problems.
Solution: Use "off_T" instead of "off_t". Use "stat_T" instead of "struct
stat". Use 64 bit system functions if available. (Ken Takata)
Diffstat (limited to 'src/os_mswin.c')
-rw-r--r-- | src/os_mswin.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/os_mswin.c b/src/os_mswin.c index e0ba32366..e1e6f1703 100644 --- a/src/os_mswin.c +++ b/src/os_mswin.c @@ -481,6 +481,18 @@ slash_adjust(char_u *p) } } +/* Use 64-bit stat functions if available. */ +#ifdef HAVE_STAT64 +# undef stat +# undef _stat +# undef _wstat +# undef _fstat +# define stat _stat64 +# define _stat _stat64 +# define _wstat _wstat64 +# define _fstat _fstat64 +#endif + #if (defined(_MSC_VER) && (_MSC_VER >= 1300)) || defined(__MINGW32__) # define OPEN_OH_ARGTYPE intptr_t #else @@ -488,7 +500,7 @@ slash_adjust(char_u *p) #endif static int -stat_symlink_aware(const char *name, struct stat *stp) +stat_symlink_aware(const char *name, stat_T *stp) { #if (defined(_MSC_VER) && (_MSC_VER < 1900)) || defined(__MINGW32__) /* Work around for VC12 or earlier (and MinGW). stat() can't handle @@ -527,7 +539,7 @@ stat_symlink_aware(const char *name, struct stat *stp) int fd, n; fd = _open_osfhandle((OPEN_OH_ARGTYPE)h, _O_RDONLY); - n = _fstat(fd, (struct _stat*)stp); + n = _fstat(fd, (struct _stat *)stp); if ((n == 0) && (attr & FILE_ATTRIBUTE_DIRECTORY)) stp->st_mode = (stp->st_mode & ~S_IFREG) | S_IFDIR; _close(fd); @@ -540,7 +552,7 @@ stat_symlink_aware(const char *name, struct stat *stp) #ifdef FEAT_MBYTE static int -wstat_symlink_aware(const WCHAR *name, struct _stat *stp) +wstat_symlink_aware(const WCHAR *name, stat_T *stp) { # if (defined(_MSC_VER) && (_MSC_VER < 1900)) || defined(__MINGW32__) /* Work around for VC12 or earlier (and MinGW). _wstat() can't handle @@ -580,7 +592,7 @@ wstat_symlink_aware(const WCHAR *name, struct _stat *stp) int fd; fd = _open_osfhandle((OPEN_OH_ARGTYPE)h, _O_RDONLY); - n = _fstat(fd, stp); + n = _fstat(fd, (struct _stat *)stp); if ((n == 0) && (attr & FILE_ATTRIBUTE_DIRECTORY)) stp->st_mode = (stp->st_mode & ~S_IFREG) | S_IFDIR; _close(fd); @@ -588,7 +600,7 @@ wstat_symlink_aware(const WCHAR *name, struct _stat *stp) } } # endif - return _wstat(name, stp); + return _wstat(name, (struct _stat *)stp); } #endif @@ -596,7 +608,7 @@ wstat_symlink_aware(const WCHAR *name, struct _stat *stp) * stat() can't handle a trailing '/' or '\', remove it first. */ int -vim_stat(const char *name, struct stat *stp) +vim_stat(const char *name, stat_T *stp) { #ifdef FEAT_MBYTE /* WinNT and later can use _MAX_PATH wide characters for a pathname, which @@ -641,7 +653,7 @@ vim_stat(const char *name, struct stat *stp) if (wp != NULL) { - n = wstat_symlink_aware(wp, (struct _stat *)stp); + n = wstat_symlink_aware(wp, stp); vim_free(wp); if (n >= 0 || g_PlatformId == VER_PLATFORM_WIN32_NT) return n; |