emacs-pretest-bug
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: file sizes shown incorrectly for large files under Windows


From: Chris Moore
Subject: Re: file sizes shown incorrectly for large files under Windows
Date: Fri, 14 Nov 2003 02:21:46 +0100

Thanks for your comments Jason.

Jason Rumney writes:

 > If it is between that and doing nothing, it is still an
 > improvement. The case you found where Emacs opened a 1 byte buffer
 > without warning for example would at least produce a warning.

Right.  At the moment it is possible to lose 4Gb of data without warning - Emacs
shows a 4Gb file as being empty, I visit the empty file, edit it,
save it back (now it really is almost empty, and my data is gone, or
in a backup file at best).

 > > + #ifdef WINDOWSNT
 > 
 > It is better to avoid this. If it is possible to use __int64 instead
 > of off_t without breaking anything, then that is preferable to
 > introducing a new struct, as it avoids conditionals for WINDOWSNT.

I'll still need to introduce a new struct, but no new field.

 > > + #ifndef _STAT_DEFINED
 > 
 > Is ms-w32.h ALWAYS included before sys/stat.h? If not, this might
 > fail.

only the following objects refer to _stat or _fstat at all:

  w32fns.o:      U _stat
  w32.o:000033b0 T _fstat
  w32.o:00002e20 T _stat
  lread.o:       U _stat
  fileio.o:      U _stat
  dired.o:       U _stat
  buffer.o:      U _stat

note that _fstat is used precisely nowhere - all the code that uses
it is conditionally compiled out under Windows, which begs the
question of why w32.c contains a definition of it.

ms-w32.h is included by config.h which is included first in almost
every source file.  The only one of the source files for the above
objects which doesn't include config.h first is w32.c, but if that
wasn't seeing the modified struct before stat.h's struct then the fix
wouldn't be working at all.

I made changes to fstat() to fill in the new wider field even though
it doesn't appear to be used.

The new change set is much smaller.  dired.c no longer needs changing.

-------cut-here-------8<--------cut-here--------8<-------cut-here-------
Index: w32.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32.c,v
retrieving revision 1.85
diff -c -r1.85 w32.c
*** w32.c       1 Sep 2003 15:45:57 -0000       1.85
--- w32.c       14 Nov 2003 01:16:57 -0000
***************
*** 2438,2444 ****
    buf->st_rdev = volume_info.serialnum;
  
  
!   buf->st_size = wfd.nFileSizeLow;
  
    /* Convert timestamps to Unix format. */
    buf->st_mtime = convert_time (wfd.ftLastWriteTime);
--- 2438,2446 ----
    buf->st_rdev = volume_info.serialnum;
  
  
!   buf->st_size = wfd.nFileSizeHigh;
!   buf->st_size <<= 32;
!   buf->st_size |= wfd.nFileSizeLow;
  
    /* Convert timestamps to Unix format. */
    buf->st_mtime = convert_time (wfd.ftLastWriteTime);
***************
*** 2522,2528 ****
    buf->st_dev = info.dwVolumeSerialNumber;
    buf->st_rdev = info.dwVolumeSerialNumber;
  
!   buf->st_size = info.nFileSizeLow;
  
    /* Convert timestamps to Unix format. */
    buf->st_mtime = convert_time (info.ftLastWriteTime);
--- 2524,2532 ----
    buf->st_dev = info.dwVolumeSerialNumber;
    buf->st_rdev = info.dwVolumeSerialNumber;
  
!   buf->st_size = info.nFileSizeHigh;
!   buf->st_size <<= 32;
!   buf->st_size |= info.nFileSizeLow;
  
    /* Convert timestamps to Unix format. */
    buf->st_mtime = convert_time (info.ftLastWriteTime);

Index: ms-w32.h
===================================================================
RCS file: /cvsroot/emacs/emacs/src/s/ms-w32.h,v
retrieving revision 1.30
diff -c -r1.30 ms-w32.h
*** ms-w32.h    1 Sep 2003 15:45:58 -0000       1.30
--- ms-w32.h    14 Nov 2003 01:15:13 -0000
***************
*** 438,443 ****
--- 438,462 ----
  #endif
  #include <malloc.h>
  
+ #ifndef _STAT_DEFINED
+ struct stat
+ {
+       _dev_t  st_dev;         /* Equivalent to drive number 0=A 1=B ... */
+       _ino_t  st_ino;         /* Always zero ? */
+       _mode_t st_mode;        /* See above constants */
+       short   st_nlink;       /* Number of links. */
+       short   st_uid;         /* User: Maybe significant on NT ? */
+       short   st_gid;         /* Group: Ditto */
+       _dev_t  st_rdev;        /* Seems useless (not even filled in) */
+       __int64 st_size;        /* File size in bytes */
+       time_t  st_atime;       /* Accessed date (always 00:00 hrs local
+                                * on FAT) */
+       time_t  st_mtime;       /* Modified time */
+       time_t  st_ctime;       /* Creation time */
+ };
+ #define _STAT_DEFINED
+ #endif /* _STAT_DEFINED */
+ 
  #include <sys/stat.h>
  
  /* Define for those source files that do not include enough NT
-------cut-here-------8<--------cut-here--------8<-------cut-here-------

Chris.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]