file: Support unicode urls on windows #6501
Conversation
That is because open takes 2 or 3 arguments. To fix it you could do |
@@ -356,9 +358,11 @@ | |||
# define fstat(fdes,stp) _fstat(fdes, stp) | |||
# define stat(fname,stp) curlx_win32_stat(fname, stp) | |||
# define struct_stat struct _stat | |||
# define open(fname,oflag) curlx_win32_open(fname, oflag) |
emilengler
Jan 21, 2021
Contributor
Please don't redfine a POSIX syscall
Please don't redfine a POSIX syscall
return result; | ||
#endif | ||
|
||
return (open)(filename, oflag); |
emilengler
Jan 21, 2021
Contributor
Why even define the function on non Windows platforms?
Why even define the function on non Windows platforms?
MarcelRaad
Jan 21, 2021
Member
It's not, this is in a #if defined(USE_WIN32_LARGE_FILES) || defined(USE_WIN32_SMALL_FILES)
block.
It's not, this is in a #if defined(USE_WIN32_LARGE_FILES) || defined(USE_WIN32_SMALL_FILES)
block.
int curlx_win32_open(const char *filename, int oflag) | ||
{ | ||
#ifdef _UNICODE | ||
int result = 0; |
MarcelRaad
Jan 21, 2021
Member
The error value is defined as -1 and 0 might be a valid result: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/open-wopen?view=msvc-160#return-value
The error value is defined as -1 and 0 might be a valid result: https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/open-wopen?view=msvc-160#return-value
foopoiuyt
Jan 21, 2021
Author
Contributor
Thanks, totally missed it (and the later check as mentioned below).
Thanks, totally missed it (and the later check as mentioned below).
63585f8
to
1106ff3
@@ -82,6 +82,29 @@ char *curlx_convert_wchar_to_UTF8(const wchar_t *str_w) | |||
|
|||
#if defined(USE_WIN32_LARGE_FILES) || defined(USE_WIN32_SMALL_FILES) | |||
|
|||
int curlx_win32_open(const char *filename, int oflag, ...) | |||
{ | |||
int pmode = 0; |
MarcelRaad
Jan 21, 2021
Member
Indentation is wrong here.
Indentation is wrong here.
if(filename_w) | ||
result = _wopen(filename_w, oflag, pmode); | ||
free(filename_w); | ||
if(result) |
MarcelRaad
Jan 21, 2021
Member
This should be if(result != -1)
now.
This should be if(result != -1)
now.
1106ff3
to
6dc311a
@@ -356,9 +359,12 @@ | |||
# define fstat(fdes,stp) _fstat(fdes, stp) | |||
# define stat(fname,stp) curlx_win32_stat(fname, stp) | |||
# define struct_stat struct _stat | |||
# define open(fname,oflag,...) curlx_win32_open(fname, oflag \ | |||
, ## __VA_ARGS__) |
jay
Jan 22, 2021
•
Member
I would do away with __VA_ARGS__
I don't think all compilers support it
I would do away with __VA_ARGS__
I don't think all compilers support it
9a9a4fc
to
cf951b5
Thanks |
Support file: urls with utf-8 filenames on Windows when _UNICODE is defined.