forked from aniani/vim
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)
This commit is contained in:
53
src/fileio.c
53
src/fileio.c
@@ -41,7 +41,7 @@ static char_u *readfile_charconvert(char_u *fname, char_u *fenc, int *fdp);
|
||||
static void check_marks_read(void);
|
||||
#endif
|
||||
#ifdef FEAT_CRYPT
|
||||
static char_u *check_for_cryptkey(char_u *cryptkey, char_u *ptr, long *sizep, off_t *filesizep, int newfile, char_u *fname, int *did_ask);
|
||||
static char_u *check_for_cryptkey(char_u *cryptkey, char_u *ptr, long *sizep, off_T *filesizep, int newfile, char_u *fname, int *did_ask);
|
||||
#endif
|
||||
#ifdef UNIX
|
||||
static void set_file_time(char_u *fname, time_t atime, time_t mtime);
|
||||
@@ -49,7 +49,7 @@ static void set_file_time(char_u *fname, time_t atime, time_t mtime);
|
||||
static int set_rw_fname(char_u *fname, char_u *sfname);
|
||||
static int msg_add_fileformat(int eol_type);
|
||||
static void msg_add_eol(void);
|
||||
static int check_mtime(buf_T *buf, struct stat *s);
|
||||
static int check_mtime(buf_T *buf, stat_T *s);
|
||||
static int time_differs(long t1, long t2);
|
||||
#ifdef FEAT_AUTOCMD
|
||||
static int apply_autocmds_exarg(event_T event, char_u *fname, char_u *fname_io, int force, buf_T *buf, exarg_T *eap);
|
||||
@@ -245,7 +245,7 @@ readfile(
|
||||
colnr_T len;
|
||||
long size = 0;
|
||||
char_u *p;
|
||||
off_t filesize = 0;
|
||||
off_T filesize = 0;
|
||||
int skip_read = FALSE;
|
||||
#ifdef FEAT_CRYPT
|
||||
char_u *cryptkey = NULL;
|
||||
@@ -269,7 +269,7 @@ readfile(
|
||||
#endif
|
||||
int fileformat = 0; /* end-of-line format */
|
||||
int keep_fileformat = FALSE;
|
||||
struct stat st;
|
||||
stat_T st;
|
||||
int file_readonly;
|
||||
linenr_T skip_count = 0;
|
||||
linenr_T read_count = 0;
|
||||
@@ -885,7 +885,7 @@ readfile(
|
||||
/* Read the first line (and a bit more). Immediately rewind to
|
||||
* the start of the file. If the read() fails "len" is -1. */
|
||||
len = read_eintr(fd, firstline, 80);
|
||||
lseek(fd, (off_t)0L, SEEK_SET);
|
||||
vim_lseek(fd, (off_T)0L, SEEK_SET);
|
||||
for (p = firstline; p < firstline + len; ++p)
|
||||
if (*p >= 0x80)
|
||||
{
|
||||
@@ -949,7 +949,7 @@ retry:
|
||||
read_buf_lnum = 1;
|
||||
read_buf_col = 0;
|
||||
}
|
||||
else if (read_stdin || lseek(fd, (off_t)0L, SEEK_SET) != 0)
|
||||
else if (read_stdin || vim_lseek(fd, (off_T)0L, SEEK_SET) != 0)
|
||||
{
|
||||
/* Can't rewind the file, give up. */
|
||||
error = TRUE;
|
||||
@@ -2253,7 +2253,8 @@ rewind_retry:
|
||||
if ( try_unix
|
||||
&& !read_stdin
|
||||
&& (read_buffer
|
||||
|| lseek(fd, (off_t)0L, SEEK_SET) == 0))
|
||||
|| vim_lseek(fd, (off_T)0L, SEEK_SET)
|
||||
== 0))
|
||||
{
|
||||
fileformat = EOL_UNIX;
|
||||
if (set_options)
|
||||
@@ -2958,7 +2959,7 @@ check_for_cryptkey(
|
||||
char_u *cryptkey, /* previous encryption key or NULL */
|
||||
char_u *ptr, /* pointer to read bytes */
|
||||
long *sizep, /* length of read bytes */
|
||||
off_t *filesizep, /* nr of bytes used from file */
|
||||
off_T *filesizep, /* nr of bytes used from file */
|
||||
int newfile, /* editing a new buffer */
|
||||
char_u *fname, /* file name to display */
|
||||
int *did_ask) /* flag: whether already asked for key */
|
||||
@@ -3145,7 +3146,7 @@ buf_write(
|
||||
int overwriting; /* TRUE if writing over original */
|
||||
int no_eol = FALSE; /* no end-of-line written */
|
||||
int device = FALSE; /* writing to a device */
|
||||
struct stat st_old;
|
||||
stat_T st_old;
|
||||
int prev_got_int = got_int;
|
||||
int file_readonly = FALSE; /* overwritten file is read-only */
|
||||
static char *err_readonly = "is read-only (cannot override: \"W\" in 'cpoptions')";
|
||||
@@ -3674,7 +3675,7 @@ buf_write(
|
||||
if (!(append && *p_pm == NUL) && !filtering && perm >= 0 && dobackup)
|
||||
{
|
||||
#if defined(UNIX) || defined(WIN32)
|
||||
struct stat st;
|
||||
stat_T st;
|
||||
#endif
|
||||
|
||||
if ((bkc & BKC_YES) || append) /* "yes" */
|
||||
@@ -3813,7 +3814,7 @@ buf_write(
|
||||
int bfd;
|
||||
char_u *copybuf, *wp;
|
||||
int some_error = FALSE;
|
||||
struct stat st_new;
|
||||
stat_T st_new;
|
||||
char_u *dirp;
|
||||
char_u *rootname;
|
||||
#if defined(UNIX)
|
||||
@@ -4343,7 +4344,7 @@ buf_write(
|
||||
if (errmsg == NULL)
|
||||
{
|
||||
#ifdef UNIX
|
||||
struct stat st;
|
||||
stat_T st;
|
||||
|
||||
/* Don't delete the file when it's a hard or symbolic link. */
|
||||
if ((!newfile && st_old.st_nlink > 1)
|
||||
@@ -4376,7 +4377,7 @@ buf_write(
|
||||
|
||||
restore_backup:
|
||||
{
|
||||
struct stat st;
|
||||
stat_T st;
|
||||
|
||||
/*
|
||||
* If we failed to open the file, we don't need a backup. Throw it
|
||||
@@ -4673,7 +4674,7 @@ restore_backup:
|
||||
if (backup != NULL && !backup_copy)
|
||||
{
|
||||
# ifdef HAVE_FCHOWN
|
||||
struct stat st;
|
||||
stat_T st;
|
||||
|
||||
/* don't change the owner when it's already OK, some systems remove
|
||||
* permission or ACL stuff */
|
||||
@@ -4929,7 +4930,7 @@ restore_backup:
|
||||
|
||||
if (backup != NULL)
|
||||
{
|
||||
struct stat st;
|
||||
stat_T st;
|
||||
|
||||
/*
|
||||
* If the original file does not exist yet
|
||||
@@ -5221,7 +5222,7 @@ msg_add_fileformat(int eol_type)
|
||||
msg_add_lines(
|
||||
int insert_space,
|
||||
long lnum,
|
||||
off_t nchars)
|
||||
off_T nchars)
|
||||
{
|
||||
char_u *p;
|
||||
|
||||
@@ -5233,6 +5234,9 @@ msg_add_lines(
|
||||
#ifdef LONG_LONG_OFF_T
|
||||
sprintf((char *)p,
|
||||
"%ldL, %lldC", lnum, (long long)nchars);
|
||||
#elif defined(WIN3264)
|
||||
sprintf((char *)p,
|
||||
"%ldL, %I64dC", lnum, (__int64)nchars);
|
||||
#else
|
||||
sprintf((char *)p,
|
||||
/* Explicit typecast avoids warning on Mac OS X 10.6 */
|
||||
@@ -5251,6 +5255,9 @@ msg_add_lines(
|
||||
#ifdef LONG_LONG_OFF_T
|
||||
sprintf((char *)p,
|
||||
_("%lld characters"), (long long)nchars);
|
||||
#elif defined(WIN3264)
|
||||
sprintf((char *)p,
|
||||
_("%I64d characters"), (__int64)nchars);
|
||||
#else
|
||||
sprintf((char *)p,
|
||||
/* Explicit typecast avoids warning on Mac OS X 10.6 */
|
||||
@@ -5274,7 +5281,7 @@ msg_add_eol(void)
|
||||
* using the same timestamp but can't set the size.
|
||||
*/
|
||||
static int
|
||||
check_mtime(buf_T *buf, struct stat *st)
|
||||
check_mtime(buf_T *buf, stat_T *st)
|
||||
{
|
||||
if (buf->b_mtime_read != 0
|
||||
&& time_differs((long)st->st_mtime, buf->b_mtime_read))
|
||||
@@ -6441,7 +6448,7 @@ vim_rename(char_u *from, char_u *to)
|
||||
#ifdef AMIGA
|
||||
BPTR flock;
|
||||
#endif
|
||||
struct stat st;
|
||||
stat_T st;
|
||||
long perm;
|
||||
#ifdef HAVE_ACL
|
||||
vim_acl_T acl; /* ACL from original file */
|
||||
@@ -6469,7 +6476,7 @@ vim_rename(char_u *from, char_u *to)
|
||||
|
||||
#ifdef UNIX
|
||||
{
|
||||
struct stat st_to;
|
||||
stat_T st_to;
|
||||
|
||||
/* It's possible for the source and destination to be the same file.
|
||||
* This happens when "from" and "to" differ in case and are on a FAT32
|
||||
@@ -6768,7 +6775,7 @@ buf_check_timestamp(
|
||||
buf_T *buf,
|
||||
int focus UNUSED) /* called for GUI focus event */
|
||||
{
|
||||
struct stat st;
|
||||
stat_T st;
|
||||
int stat_res;
|
||||
int retval = 0;
|
||||
char_u *path;
|
||||
@@ -6780,7 +6787,7 @@ buf_check_timestamp(
|
||||
#if defined(FEAT_CON_DIALOG) || defined(FEAT_GUI_DIALOG)
|
||||
int can_reload = FALSE;
|
||||
#endif
|
||||
off_t orig_size = buf->b_orig_size;
|
||||
off_T orig_size = buf->b_orig_size;
|
||||
int orig_mode = buf->b_orig_mode;
|
||||
#ifdef FEAT_GUI
|
||||
int save_mouse_correct = need_mouse_correct;
|
||||
@@ -7209,7 +7216,7 @@ buf_reload(buf_T *buf, int orig_mode)
|
||||
}
|
||||
|
||||
void
|
||||
buf_store_time(buf_T *buf, struct stat *st, char_u *fname UNUSED)
|
||||
buf_store_time(buf_T *buf, stat_T *st, char_u *fname UNUSED)
|
||||
{
|
||||
buf->b_mtime = (long)st->st_mtime;
|
||||
buf->b_orig_size = st->st_size;
|
||||
@@ -7349,7 +7356,7 @@ vim_tempname(
|
||||
static char *(tempdirs[]) = {TEMPDIRNAMES};
|
||||
int i;
|
||||
# ifndef EEXIST
|
||||
struct stat st;
|
||||
stat_T st;
|
||||
# endif
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user