These functions are available since msvcr70.dll. For older msvcrt versions
provide mingw-w64 emulation of _futime64() function via WinAPI function
SetFileTime(). Functions _utime64() and _wutime64() are then emulated via
_futime64() function.
---
mingw-w64-crt/Makefile.am | 6 ++++
mingw-w64-crt/lib-common/msvcrt.def.in | 6 ++--
mingw-w64-crt/misc/_futime64.c | 46 ++++++++++++++++++++++++++
mingw-w64-crt/misc/_utime64.c | 29 ++++++++++++++++
mingw-w64-crt/misc/_wutime64.c | 29 ++++++++++++++++
5 files changed, 113 insertions(+), 3 deletions(-)
create mode 100644 mingw-w64-crt/misc/_futime64.c
create mode 100644 mingw-w64-crt/misc/_utime64.c
create mode 100644 mingw-w64-crt/misc/_wutime64.c
diff --git a/mingw-w64-crt/Makefile.am b/mingw-w64-crt/Makefile.am
index 45fefe19715c..220a0e210e5b 100644
--- a/mingw-w64-crt/Makefile.am
+++ b/mingw-w64-crt/Makefile.am
@@ -578,6 +578,7 @@ src_msvcrt32=\
misc/_difftime64.c \
misc/_free_locale.c \
misc/_ftime64.c \
+ misc/_futime64.c \
misc/_get_current_locale.c \
misc/_get_doserrno.c \
misc/_get_fmode.c \
@@ -590,7 +591,9 @@ src_msvcrt32=\
misc/_set_doserrno.c \
misc/_set_fmode.c \
misc/_time64.c \
+ misc/_utime64.c \
misc/_wctime64.c \
+ misc/_wutime64.c \
misc/imaxabs.c \
misc/output_format.c \
misc/_get_errno.c \
@@ -897,11 +900,14 @@ src_pre_msvcr70=\
misc/_aligned_realloc.c \
misc/_ctime64.c \
misc/_ftime64.c \
+ misc/_futime64.c \
misc/_gmtime64.c \
misc/_localtime64.c \
misc/_mktime64.c \
misc/_time64.c \
+ misc/_utime64.c \
misc/_wctime64.c \
+ misc/_wutime64.c \
misc/strtoimax.c \
misc/strtoumax.c \
misc/wcstoimax.c \
diff --git a/mingw-w64-crt/lib-common/msvcrt.def.in
b/mingw-w64-crt/lib-common/msvcrt.def.in
index 23df1a05cf2e..d90796a70e07 100644
--- a/mingw-w64-crt/lib-common/msvcrt.def.in
+++ b/mingw-w64-crt/lib-common/msvcrt.def.in
@@ -1155,19 +1155,19 @@ _findfirst64
_findnext64
F_NON_I386(_fstat64) ; i386 _fstat64 replaced by emu
F_NON_I386(_ftime64) ; i386 _ftime64 replaced by emu
-_futime64
+F_NON_I386(_futime64) ; i386 _futime64 replaced by emu
F_NON_I386(_gmtime64) ; i386 _gmtime64 replaced by emu
F_NON_I386(_localtime64) ; i386 _localtime64 replaced by emu
F_NON_I386(_mktime64) ; i386 _mktime64 replaced by emu
F_X86_ANY(_osplatform DATA)
F_NON_I386(_stat64) ; i386 _stat64 replaced by emu
F_NON_I386(_time64) ; i386 _time64 replaced by emu
-_utime64
+F_NON_I386(_utime64) ; i386 _utime64 replaced by emu
F_NON_I386(_wctime64) ; i386 _wctime64 replaced by emu
_wfindfirst64
_wfindnext64
F_NON_I386(_wstat64) ; i386 _wstat64 replaced by emu
-_wutime64
+F_NON_I386(_wutime64) ; i386 _wutime64 replaced by emu
; These symbols were added in Windows 2000 SP4 OS system version of msvcrt.dll
F_X86_ANY(_get_heap_handle) ; _get_heap_handle is not available in Windows XP
and Windows XP SP1 OS system versions of msvcrt.dll, but is in XP SP2 and SP3
diff --git a/mingw-w64-crt/misc/_futime64.c b/mingw-w64-crt/misc/_futime64.c
new file mode 100644
index 000000000000..4be9706a8760
--- /dev/null
+++ b/mingw-w64-crt/misc/_futime64.c
@@ -0,0 +1,46 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <windows.h>
+#include <errno.h>
+#include <utime.h>
+#include <time.h>
+#include <io.h>
+
+#include "filetime_to_time64.h"
+
+static int __cdecl emu__futime64(int fd, struct __utimbuf64 *times)
+{
+ struct __utimbuf64 utimbuf64;
+ FILETIME last_access_time;
+ FILETIME last_write_time;
+ HANDLE handle;
+
+ handle = (HANDLE)_get_osfhandle(fd);
+ if (handle == INVALID_HANDLE_VALUE)
+ return -1;
+
+ if (!times) {
+ utimbuf64.actime = utimbuf64.modtime = _time64(NULL);
+ times = &utimbuf64;
+ }
+
+ time64_to_filetime(times->actime, &last_access_time);
+ time64_to_filetime(times->modtime, &last_write_time);
+
+ if (!SetFileTime(handle, NULL, &last_access_time, &last_write_time)) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ return 0;
+}
+
+#define RETT int
+#define FUNC _futime64
+#define ARGS int fd, struct __utimbuf64 *times
+#define CALL fd, times
+#include "msvcrt_or_emu_glue.h"
diff --git a/mingw-w64-crt/misc/_utime64.c b/mingw-w64-crt/misc/_utime64.c
new file mode 100644
index 000000000000..a95f244d96d0
--- /dev/null
+++ b/mingw-w64-crt/misc/_utime64.c
@@ -0,0 +1,29 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <utime.h>
+#include <fcntl.h>
+#include <io.h>
+
+static int __cdecl emu__utime64(const char *filename, struct __utimbuf64
*times)
+{
+ int fd;
+ int ret;
+
+ fd = open(filename, O_RDWR | O_BINARY);
+ if (fd < 0)
+ return -1;
+
+ ret = _futime64(fd, times);
+ close(fd);
+ return ret;
+}
+
+#define RETT int
+#define FUNC _utime64
+#define ARGS const char *filename, struct __utimbuf64 *times
+#define CALL filename, times
+#include "msvcrt_or_emu_glue.h"
diff --git a/mingw-w64-crt/misc/_wutime64.c b/mingw-w64-crt/misc/_wutime64.c
new file mode 100644
index 000000000000..aa791718a015
--- /dev/null
+++ b/mingw-w64-crt/misc/_wutime64.c
@@ -0,0 +1,29 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#include <utime.h>
+#include <fcntl.h>
+#include <io.h>
+
+static int __cdecl emu__wutime64(const wchar_t *filename, struct __utimbuf64
*times)
+{
+ int fd;
+ int ret;
+
+ fd = _wopen(filename, O_RDWR | O_BINARY);
+ if (fd < 0)
+ return -1;
+
+ ret = _futime64(fd, times);
+ close(fd);
+ return ret;
+}
+
+#define RETT int
+#define FUNC _wutime64
+#define ARGS const wchar_t *filename, struct __utimbuf64 *times
+#define CALL filename, times
+#include "msvcrt_or_emu_glue.h"
--
2.20.1
_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public