Piotr Caban : msvcp110: Add _Last_write_time(wchar_t) implementation.
Module: wine Branch: master Commit: efb6b3734aac964c7d83a683eb503d9da5be1cc4 URL: https://source.winehq.org/git/wine.git/?a=commit;h=efb6b3734aac964c7d83a683e... Author: Piotr Caban <piotr(a)codeweavers.com> Date: Wed Aug 15 12:43:27 2018 +0200 msvcp110: Add _Last_write_time(wchar_t) implementation. Signed-off-by: Piotr Caban <piotr(a)codeweavers.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/msvcp110/msvcp110.spec | 8 ++-- dlls/msvcp120/msvcp120.spec | 8 ++-- dlls/msvcp120_app/msvcp120_app.spec | 8 ++-- dlls/msvcp90/ios.c | 78 ++++++++++++++++++++++++++++++------- 4 files changed, 75 insertions(+), 27 deletions(-) diff --git a/dlls/msvcp110/msvcp110.spec b/dlls/msvcp110/msvcp110.spec index fbffd14..58680d0 100644 --- a/dlls/msvcp110/msvcp110.spec +++ b/dlls/msvcp110/msvcp110.spec @@ -1561,12 +1561,12 @@ @ cdecl -arch=win64 ?_Iput@?$num_put(a)_WV?$ostreambuf_iterator(a)_WU?$char_traits(a)_W@std@@@std@@@std@@AEBA?AV?$ostreambuf_iterator(a)_WU?$char_traits(a)_W@std@@@2(a)V32@AEAVios_base(a)2@_WPEAD_K(a)Z(ptr ptr ptr ptr long ptr long) num_put_wchar__Iput @ cdecl -arch=win32 ?_Last_write_time(a)sys@tr2(a)std@@YAXPBD_J(a)Z(str int64) tr2_sys__Last_write_time_set @ cdecl -arch=win64 ?_Last_write_time(a)sys@tr2(a)std@@YAXPEBD_J(a)Z(str int64) tr2_sys__Last_write_time_set -@ stub -arch=win32 ?_Last_write_time(a)sys@tr2(a)std@@YAXPB_W_J(a)Z -@ stub -arch=win64 ?_Last_write_time(a)sys@tr2(a)std@@YAXPEB_W_J(a)Z +@ cdecl -arch=win32 ?_Last_write_time(a)sys@tr2(a)std@@YAXPB_W_J(a)Z(wstr int64) tr2_sys__Last_write_time_set_wchar +@ cdecl -arch=win64 ?_Last_write_time(a)sys@tr2(a)std@@YAXPEB_W_J(a)Z(wstr int64) tr2_sys__Last_write_time_set_wchar @ cdecl -ret64 -arch=win32 ?_Last_write_time(a)sys@tr2(a)std@@YA_JPBD(a)Z(str) tr2_sys__Last_write_time @ cdecl -ret64 -arch=win64 ?_Last_write_time(a)sys@tr2(a)std@@YA_JPEBD(a)Z(str) tr2_sys__Last_write_time -@ stub -arch=win32 ?_Last_write_time(a)sys@tr2(a)std@@YA_JPB_W(a)Z -@ stub -arch=win64 ?_Last_write_time(a)sys@tr2(a)std@@YA_JPEB_W(a)Z +@ cdecl -ret64 -arch=win32 ?_Last_write_time(a)sys@tr2(a)std@@YA_JPB_W(a)Z(wstr) tr2_sys__Last_write_time_wchar +@ cdecl -ret64 -arch=win64 ?_Last_write_time(a)sys@tr2(a)std@@YA_JPEB_W(a)Z(wstr) tr2_sys__Last_write_time_wchar @ cdecl -arch=arm ?_Launch(a)_Pad@std@@QAAXPAU_Thrd_imp_t@@@Z(ptr ptr) _Pad__Launch @ thiscall -arch=i386 ?_Launch(a)_Pad@std@@QAEXPAU_Thrd_imp_t@@@Z(ptr ptr) _Pad__Launch @ cdecl -arch=win64 ?_Launch(a)_Pad@std@@QEAAXPEAU_Thrd_imp_t@@@Z(ptr ptr) _Pad__Launch diff --git a/dlls/msvcp120/msvcp120.spec b/dlls/msvcp120/msvcp120.spec index 3dda358..934daf7 100644 --- a/dlls/msvcp120/msvcp120.spec +++ b/dlls/msvcp120/msvcp120.spec @@ -1522,12 +1522,12 @@ @ cdecl -arch=win64 ?_Iput@?$num_put(a)_WV?$ostreambuf_iterator(a)_WU?$char_traits(a)_W@std@@@std@@@std@@AEBA?AV?$ostreambuf_iterator(a)_WU?$char_traits(a)_W@std@@@2(a)V32@AEAVios_base(a)2@_WPEAD_K(a)Z(ptr ptr ptr ptr long ptr long) num_put_wchar__Iput @ cdecl -arch=win32 ?_Last_write_time(a)sys@tr2(a)std@@YAXPBD_J(a)Z(str int64) tr2_sys__Last_write_time_set @ cdecl -arch=win64 ?_Last_write_time(a)sys@tr2(a)std@@YAXPEBD_J(a)Z(str int64) tr2_sys__Last_write_time_set -@ stub -arch=win32 ?_Last_write_time(a)sys@tr2(a)std@@YAXPB_W_J(a)Z -@ stub -arch=win64 ?_Last_write_time(a)sys@tr2(a)std@@YAXPEB_W_J(a)Z +@ cdecl -arch=win32 ?_Last_write_time(a)sys@tr2(a)std@@YAXPB_W_J(a)Z(wstr int64) tr2_sys__Last_write_time_set_wchar +@ cdecl -arch=win64 ?_Last_write_time(a)sys@tr2(a)std@@YAXPEB_W_J(a)Z(wstr int64) tr2_sys__Last_write_time_set_wchar @ cdecl -ret64 -arch=win32 ?_Last_write_time(a)sys@tr2(a)std@@YA_JPBD(a)Z(str) tr2_sys__Last_write_time @ cdecl -ret64 -arch=win64 ?_Last_write_time(a)sys@tr2(a)std@@YA_JPEBD(a)Z(str) tr2_sys__Last_write_time -@ stub -arch=win32 ?_Last_write_time(a)sys@tr2(a)std@@YA_JPB_W(a)Z -@ stub -arch=win64 ?_Last_write_time(a)sys@tr2(a)std@@YA_JPEB_W(a)Z +@ cdecl -ret64 -arch=win32 ?_Last_write_time(a)sys@tr2(a)std@@YA_JPB_W(a)Z(wstr) tr2_sys__Last_write_time_wchar +@ cdecl -ret64 -arch=win64 ?_Last_write_time(a)sys@tr2(a)std@@YA_JPEB_W(a)Z(wstr) tr2_sys__Last_write_time_wchar @ cdecl -arch=arm ?_Launch(a)_Pad@std@@QAAXPAU_Thrd_imp_t@@@Z(ptr ptr) _Pad__Launch @ thiscall -arch=i386 ?_Launch(a)_Pad@std@@QAEXPAU_Thrd_imp_t@@@Z(ptr ptr) _Pad__Launch @ cdecl -arch=win64 ?_Launch(a)_Pad@std@@QEAAXPEAU_Thrd_imp_t@@@Z(ptr ptr) _Pad__Launch diff --git a/dlls/msvcp120_app/msvcp120_app.spec b/dlls/msvcp120_app/msvcp120_app.spec index 1db54a7..b2edb0f 100644 --- a/dlls/msvcp120_app/msvcp120_app.spec +++ b/dlls/msvcp120_app/msvcp120_app.spec @@ -1522,12 +1522,12 @@ @ cdecl -arch=win64 ?_Iput@?$num_put(a)_WV?$ostreambuf_iterator(a)_WU?$char_traits(a)_W@std@@@std@@@std@@AEBA?AV?$ostreambuf_iterator(a)_WU?$char_traits(a)_W@std@@@2(a)V32@AEAVios_base(a)2@_WPEAD_K(a)Z(ptr ptr ptr ptr long ptr long) msvcp120.?_Iput@?$num_put(a)_WV?$ostreambuf_iterator(a)_WU?$char_traits(a)_W@std@@@std@@@std@@AEBA?AV?$ostreambuf_iterator(a)_WU?$char_traits(a)_W@std@@@2(a)V32@AEAVios_base(a)2@_WPEAD_K(a)Z @ cdecl -arch=win32 ?_Last_write_time(a)sys@tr2(a)std@@YAXPBD_J(a)Z(str int64) msvcp120.?_Last_write_time(a)sys@tr2(a)std@@YAXPBD_J(a)Z @ cdecl -arch=win64 ?_Last_write_time(a)sys@tr2(a)std@@YAXPEBD_J(a)Z(str int64) msvcp120.?_Last_write_time(a)sys@tr2(a)std@@YAXPEBD_J(a)Z -@ stub -arch=win32 ?_Last_write_time(a)sys@tr2(a)std@@YAXPB_W_J(a)Z -@ stub -arch=win64 ?_Last_write_time(a)sys@tr2(a)std@@YAXPEB_W_J(a)Z +@ cdecl -arch=win32 ?_Last_write_time(a)sys@tr2(a)std@@YAXPB_W_J(a)Z(wstr int64) msvcp120.?_Last_write_time(a)sys@tr2(a)std@@YAXPB_W_J(a)Z +@ cdecl -arch=win64 ?_Last_write_time(a)sys@tr2(a)std@@YAXPEB_W_J(a)Z(wstr int64) msvcp120.?_Last_write_time(a)sys@tr2(a)std@@YAXPEB_W_J(a)Z @ cdecl -ret64 -arch=win32 ?_Last_write_time(a)sys@tr2(a)std@@YA_JPBD(a)Z(str) msvcp120.?_Last_write_time(a)sys@tr2(a)std@@YA_JPBD(a)Z @ cdecl -ret64 -arch=win64 ?_Last_write_time(a)sys@tr2(a)std@@YA_JPEBD(a)Z(str) msvcp120.?_Last_write_time(a)sys@tr2(a)std@@YA_JPEBD(a)Z -@ stub -arch=win32 ?_Last_write_time(a)sys@tr2(a)std@@YA_JPB_W(a)Z -@ stub -arch=win64 ?_Last_write_time(a)sys@tr2(a)std@@YA_JPEB_W(a)Z +@ cdecl -ret64 -arch=win32 ?_Last_write_time(a)sys@tr2(a)std@@YA_JPB_W(a)Z(wstr) msvcp120.?_Last_write_time(a)sys@tr2(a)std@@YA_JPB_W(a)Z +@ cdecl -ret64 -arch=win64 ?_Last_write_time(a)sys@tr2(a)std@@YA_JPEB_W(a)Z(wstr) msvcp120.?_Last_write_time(a)sys@tr2(a)std@@YA_JPEB_W(a)Z @ cdecl -arch=arm ?_Launch(a)_Pad@std@@QAAXPAU_Thrd_imp_t@@@Z(ptr ptr) msvcp120.?_Launch(a)_Pad@std@@QAAXPAU_Thrd_imp_t@@@Z @ thiscall -arch=i386 ?_Launch(a)_Pad@std@@QAEXPAU_Thrd_imp_t@@@Z(ptr ptr) msvcp120.?_Launch(a)_Pad@std@@QAEXPAU_Thrd_imp_t@@@Z @ cdecl -arch=win64 ?_Launch(a)_Pad@std@@QEAAXPEAU_Thrd_imp_t@@@Z(ptr ptr) msvcp120.?_Launch(a)_Pad@std@@QEAAXPEAU_Thrd_imp_t@@@Z diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c index e71d30f..64e0f2b 100644 --- a/dlls/msvcp90/ios.c +++ b/dlls/msvcp90/ios.c @@ -14845,14 +14845,26 @@ enum file_type __cdecl tr2_sys__Lstat(char const* path, int* err_code) return tr2_sys__Stat(path, err_code); } +static __int64 get_last_write_time(HANDLE h) +{ + FILETIME wt; + __int64 ret; + + if(!GetFileTime(h, 0, 0, &wt)) + return 0; + + ret = (((__int64)wt.dwHighDateTime)<< 32) + wt.dwLowDateTime; + ret -= TICKS_1601_TO_1970; + return ret; +} + /* ?_Last_write_time(a)sys@tr2(a)std@@YA_JPBD(a)Z */ /* ?_Last_write_time(a)sys@tr2(a)std@@YA_JPEBD(a)Z */ __int64 __cdecl tr2_sys__Last_write_time(char const* path) { HANDLE handle; - FILETIME lwt; - int ret; - __int64 last_write_time; + __int64 ret; + TRACE("(%s)\n", debugstr_a(path)); handle = CreateFileA(path, 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, @@ -14860,15 +14872,38 @@ __int64 __cdecl tr2_sys__Last_write_time(char const* path) if(handle == INVALID_HANDLE_VALUE) return 0; - ret = GetFileTime(handle, 0, 0, &lwt); + ret = get_last_write_time(handle); CloseHandle(handle); - if(!ret) + return ret / TICKSPERSEC; +} + +/* ?_Last_write_time(a)sys@tr2(a)std@@YA_JPB_W(a)Z */ +/* ?_Last_write_time(a)sys@tr2(a)std@@YA_JPEB_W(a)Z */ +__int64 __cdecl tr2_sys__Last_write_time_wchar(const wchar_t *path) +{ + HANDLE handle; + __int64 ret; + + TRACE("(%s)\n", debugstr_w(path)); + + handle = CreateFileW(path, 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); + if(handle == INVALID_HANDLE_VALUE) return 0; - last_write_time = (((__int64)lwt.dwHighDateTime)<< 32) + lwt.dwLowDateTime; - last_write_time -= TICKS_1601_TO_1970; - last_write_time /= TICKSPERSEC; - return last_write_time; + ret = get_last_write_time(handle); + CloseHandle(handle); + return ret / TICKSPERSEC; +} + +static int set_last_write_time(HANDLE h, __int64 time) +{ + FILETIME wt; + + time += TICKS_1601_TO_1970; + wt.dwLowDateTime = (DWORD)time; + wt.dwHighDateTime = (DWORD)(time >> 32); + return SetFileTime(h, 0, 0, &wt); } /* ?_Last_write_time(a)sys@tr2(a)std@@YAXPBD_J(a)Z */ @@ -14876,7 +14911,7 @@ __int64 __cdecl tr2_sys__Last_write_time(char const* path) void __cdecl tr2_sys__Last_write_time_set(char const* path, __int64 newtime) { HANDLE handle; - FILETIME lwt; + TRACE("(%s)\n", debugstr_a(path)); handle = CreateFileA(path, FILE_WRITE_ATTRIBUTES, @@ -14889,12 +14924,25 @@ void __cdecl tr2_sys__Last_write_time_set(char const* path, __int64 newtime) * According to the test of msvcp120, * msvcp120's implementation does nothing. Obviously, this is a bug of windows. */ + set_last_write_time(handle, newtime * TICKSPERSEC); + CloseHandle(handle); +} + +/* ?_Last_write_time(a)sys@tr2(a)std@@YAXPB_W_J(a)Z */ +/* ?_Last_write_time(a)sys@tr2(a)std@@YAXPEB_W_J(a)Z */ +void __cdecl tr2_sys__Last_write_time_set_wchar(const wchar_t *path, __int64 time) +{ + HANDLE handle; + + TRACE("(%s)\n", debugstr_w(path)); + + handle = CreateFileW(path, FILE_WRITE_ATTRIBUTES, + FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0); + if(handle == INVALID_HANDLE_VALUE) + return; - newtime *= TICKSPERSEC; - newtime += TICKS_1601_TO_1970; - lwt.dwLowDateTime = (DWORD)(newtime); - lwt.dwHighDateTime = (DWORD)(newtime >> 32); - SetFileTime(handle, 0, 0, &lwt); + set_last_write_time(handle, time * TICKSPERSEC); CloseHandle(handle); }
participants (1)
-
Alexandre Julliard