diff options
author | Marcel Raad <Marcel.Raad@teamviewer.com> | 2020-07-23 21:28:14 +0200 |
---|---|---|
committer | Marcel Raad <Marcel.Raad@teamviewer.com> | 2020-07-27 10:42:38 +0200 |
commit | 0c6112a139c1133f7bdfc440903c0e5602c84d90 (patch) | |
tree | 3e7229f7e175db8c3a2bfea45cad93c38ed9e1b3 /src/tool_filetime.c | |
parent | 8829703b5a8d595457f3f4954cf09e6d6bae1523 (diff) | |
download | curl-0c6112a139c1133f7bdfc440903c0e5602c84d90.tar.gz |
WIN32: stop forcing narrow-character API
Except where the results are only used for character output.
getenv is not touched because it's part of the public API, and having
it return UTF-8 instead of ANSI would be a breaking change.
Fixes https://github.com/curl/curl/issues/5658
Fixes https://github.com/curl/curl/issues/5712
Closes https://github.com/curl/curl/pull/5718
Diffstat (limited to 'src/tool_filetime.c')
-rw-r--r-- | src/tool_filetime.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/tool_filetime.c b/src/tool_filetime.c index 6071e44d2..3970570e4 100644 --- a/src/tool_filetime.c +++ b/src/tool_filetime.c @@ -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); |