summaryrefslogtreecommitdiff
path: root/src/tool_filetime.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tool_filetime.c')
-rw-r--r--src/tool_filetime.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/tool_filetime.c b/src/tool_filetime.c
index 6071e44d2..1ffc981fe 100644
--- a/src/tool_filetime.c
+++ b/src/tool_filetime.c
@@ -5,7 +5,7 @@
* | (__| |_| | _ <| |___
* \___|\___/|_| \_\_____|
*
- * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
+ * Copyright (C) 1998 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
*
* This software is licensed as described in the file COPYING, which
* you should have received as part of this distribution. The terms
@@ -21,6 +21,8 @@
***************************************************************************/
#include "tool_filetime.h"
+#include "curlx.h"
+
#ifdef HAVE_UTIME_H
# include <utime.h>
#elif defined(HAVE_SYS_UTIME_H)
@@ -36,11 +38,13 @@ curl_off_t getfiletime(const char *filename, FILE *error_stream)
access to a 64-bit type we can bypass stat and get the times directly. */
#if defined(WIN32) && (SIZEOF_CURL_OFF_T >= 8)
HANDLE hfile;
+ TCHAR *tchar_filename = curlx_convert_UTF8_to_tchar((char *)filename);
- hfile = CreateFileA(filename, FILE_READ_ATTRIBUTES,
+ hfile = CreateFile(tchar_filename, FILE_READ_ATTRIBUTES,
(FILE_SHARE_READ | FILE_SHARE_WRITE |
FILE_SHARE_DELETE),
NULL, OPEN_EXISTING, 0, NULL);
+ curlx_unicodefree(tchar_filename);
if(hfile != INVALID_HANDLE_VALUE) {
FILETIME ft;
if(GetFileTime(hfile, NULL, NULL, &ft)) {
@@ -93,6 +97,7 @@ void setfiletime(curl_off_t filetime, const char *filename,
access to a 64-bit type we can bypass utime and set the times directly. */
#if defined(WIN32) && (SIZEOF_CURL_OFF_T >= 8)
HANDLE hfile;
+ TCHAR *tchar_filename = curlx_convert_UTF8_to_tchar((char *)filename);
/* 910670515199 is the maximum unix filetime that can be used as a
Windows FILETIME without overflow: 30827-12-31T23:59:59. */
@@ -100,13 +105,15 @@ void setfiletime(curl_off_t filetime, const char *filename,
fprintf(error_stream,
"Failed to set filetime %" CURL_FORMAT_CURL_OFF_T
" on outfile: overflow\n", filetime);
+ curlx_unicodefree(tchar_filename);
return;
}
- hfile = CreateFileA(filename, FILE_WRITE_ATTRIBUTES,
+ hfile = CreateFile(tchar_filename, FILE_WRITE_ATTRIBUTES,
(FILE_SHARE_READ | FILE_SHARE_WRITE |
FILE_SHARE_DELETE),
NULL, OPEN_EXISTING, 0, NULL);
+ curlx_unicodefree(tchar_filename);
if(hfile != INVALID_HANDLE_VALUE) {
curl_off_t converted = ((curl_off_t)filetime * 10000000) +
CURL_OFF_T_C(116444736000000000);