From: Daniel Lehman dlehman25@gmail.com
--- dlls/msvcp140/tests/msvcp140.c | 6 ++-- dlls/msvcp90/ios.c | 56 ++++++++++++++++++++++++++++++++++ 2 files changed, 58 insertions(+), 4 deletions(-)
diff --git a/dlls/msvcp140/tests/msvcp140.c b/dlls/msvcp140/tests/msvcp140.c index 250ead1bc76..72a74076621 100644 --- a/dlls/msvcp140/tests/msvcp140.c +++ b/dlls/msvcp140/tests/msvcp140.c @@ -1709,9 +1709,8 @@ static void test__Fiopen(void) static const struct { const char *loc; const char *path; - int is_todo; } tests[] = { - { "German.utf8", "t\xc3\xa4\xc3\x8f\xc3\xb6\xc3\x9f.txt", TRUE }, + { "German.utf8", "t\xc3\xa4\xc3\x8f\xc3\xb6\xc3\x9f.txt" }, { "Polish.utf8", "t\xc4\x99\xc5\x9b\xc4\x87.txt" }, { "Turkish.utf8", "t\xc3\x87\xc4\x9e\xc4\xb1\xc4\xb0\xc5\x9e.txt" }, { "Arabic.utf8", "t\xd8\xaa\xda\x86.txt" }, @@ -1736,9 +1735,8 @@ static void test__Fiopen(void) p_fclose(f);
f = p__Fiopen_wchar(wpath, OPENMODE_in, SH_DENYNO); - todo_wine_if(tests[i].is_todo) ok(!!f, "failed to open %s with locale %s\n", wine_dbgstr_w(wpath), tests[i].loc); - if(f) p_fclose(f); + p_fclose(f);
p__unlink(tests[i].path); } diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c index 5b791cd4345..d854892172f 100644 --- a/dlls/msvcp90/ios.c +++ b/dlls/msvcp90/ios.c @@ -3266,6 +3266,61 @@ FILE* __cdecl _Fiopen_wchar(const wchar_t *name, int mode, int prot)
/* ?_Fiopen@std@@YAPAU_iobuf@@PBDHH@Z */ /* ?_Fiopen@std@@YAPEAU_iobuf@@PEBDHH@Z */ +#if _MSVCP_VER >= 140 +FILE* __cdecl _Fiopen(const char *name, int mode, int prot) +{ + static const struct { + int mode; + const char str[4]; + const char str_bin[4]; + } str_mode[] = { + {OPENMODE_out, "w", "wb"}, + {OPENMODE_out|OPENMODE_app, "a", "ab"}, + {OPENMODE_app, "a", "ab"}, + {OPENMODE_out|OPENMODE_trunc, "w", "wb"}, + {OPENMODE_in, "r", "rb"}, + {OPENMODE_in|OPENMODE_out, "r+", "r+b"}, + {OPENMODE_in|OPENMODE_out|OPENMODE_trunc, "w+", "w+b"}, + {OPENMODE_in|OPENMODE_out|OPENMODE_app, "a+", "a+b"}, + {OPENMODE_in|OPENMODE_app, "a+", "a+b"} + }; + + int real_mode = mode & ~(OPENMODE_ate|OPENMODE__Nocreate|OPENMODE__Noreplace|OPENMODE_binary); + size_t mode_idx; + FILE *f = NULL; + + TRACE("(%s %d %d)\n", debugstr_a(name), mode, prot); + + for(mode_idx=0; mode_idx<ARRAY_SIZE(str_mode); mode_idx++) + if(str_mode[mode_idx].mode == real_mode) + break; + if(mode_idx == ARRAY_SIZE(str_mode)) + return NULL; + + if((mode & OPENMODE__Nocreate) && !(f = fopen(name, "r"))) + return NULL; + else if(f) + fclose(f); + + if((mode & OPENMODE__Noreplace) && (mode & (OPENMODE_out|OPENMODE_app)) + && (f = fopen(name, "r"))) { + fclose(f); + return NULL; + } + + f = _fsopen(name, (mode & OPENMODE_binary) ? str_mode[mode_idx].str_bin + : str_mode[mode_idx].str, prot); + if(!f) + return NULL; + + if((mode & OPENMODE_ate) && fseek(f, 0, SEEK_END)) { + fclose(f); + return NULL; + } + + return f; +} +#else FILE* __cdecl _Fiopen(const char *name, int mode, int prot) { wchar_t nameW[FILENAME_MAX]; @@ -3281,6 +3336,7 @@ FILE* __cdecl _Fiopen(const char *name, int mode, int prot) #endif return _Fiopen_wchar(nameW, mode, prot); } +#endif
/* ?__Fiopen@std@@YAPAU_iobuf@@PBDH@Z */ /* ?__Fiopen@std@@YAPEAU_iobuf@@PEBDH@Z */