]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 58656] Fix mtime for large files on MS-Windows
authorEli Zaretskii <eliz@gnu.org>
Sat, 29 May 2021 08:37:09 +0000 (11:37 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 29 May 2021 08:37:09 +0000 (11:37 +0300)
In MSVC builds, 'stat' fails when called on files larger than
2GB.  Call '_stat64' instead to work around this.

* src/remake.c (STAT): Define to '_stat64' for MSVC builds.
(name_mtime) [WINDOWS32]: Use STAT instead of 'stat'.
Suggested by Makoto Kato <m_kato@ga2.so-net.ne.jp>.

src/remake.c

index dc3097c2be493b59a586023fe6232471cd8eb758..f7605fc062c5e0a916537f3b90f5d9f94af9625b 100644 (file)
@@ -35,6 +35,13 @@ this program.  If not, see <http://www.gnu.org/licenses/>.  */
 #endif
 #ifdef WINDOWS32
 #include <io.h>
+#include <sys/stat.h>
+#if defined(_MSC_VER) && _MSC_VER > 1200
+/* VC7 or later supprots _stat64 to access 64-bit file size. */
+#define STAT _stat64
+#else
+#define STAT stat
+#endif
 #endif
 
 
@@ -1466,7 +1473,11 @@ static FILE_TIMESTAMP
 name_mtime (const char *name)
 {
   FILE_TIMESTAMP mtime;
+#if defined(WINDOWS32)
+  struct STAT st;
+#else
   struct stat st;
+#endif
   int e;
 
 #if defined(WINDOWS32)
@@ -1498,7 +1509,11 @@ name_mtime (const char *name)
         tend = &tem[0];
       }
 
+#if defined(WINDOWS32)
+    e = STAT (tem, &st);
+#else
     e = stat (tem, &st);
+#endif
     if (e == 0 && !_S_ISDIR (st.st_mode) && tend < tem + (p - name - 1))
       {
         errno = ENOTDIR;