Piotr Caban : msvcp110: Add _Last_write_time(wchar_t) implementation.

Alexandre Julliard julliard at winehq.org
Thu Nov 29 15:09:36 CST 2018


Module: wine
Branch: stable
Commit: c7e65ea2dbeec02b29760f8be8015ea4fa116dc4
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=c7e65ea2dbeec02b29760f8be8015ea4fa116dc4

Author: Piotr Caban <piotr at 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 at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit efb6b3734aac964c7d83a683eb503d9da5be1cc4)
Signed-off-by: Michael Stefaniuc <mstefani at 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 32e696a..91051a4 100644
--- a/dlls/msvcp110/msvcp110.spec
+++ b/dlls/msvcp110/msvcp110.spec
@@ -1561,12 +1561,12 @@
 @ cdecl -arch=win64 ?_Iput@?$num_put at _WV?$ostreambuf_iterator at _WU?$char_traits at _W@std@@@std@@@std@@AEBA?AV?$ostreambuf_iterator at _WU?$char_traits at _W@std@@@2 at V32@AEAVios_base at 2@_WPEAD_K at Z(ptr ptr ptr ptr long ptr long) num_put_wchar__Iput
 @ cdecl -arch=win32 ?_Last_write_time at sys@tr2 at std@@YAXPBD_J at Z(str int64) tr2_sys__Last_write_time_set
 @ cdecl -arch=win64 ?_Last_write_time at sys@tr2 at std@@YAXPEBD_J at Z(str int64) tr2_sys__Last_write_time_set
-@ stub -arch=win32 ?_Last_write_time at sys@tr2 at std@@YAXPB_W_J at Z
-@ stub -arch=win64 ?_Last_write_time at sys@tr2 at std@@YAXPEB_W_J at Z
+@ cdecl -arch=win32 ?_Last_write_time at sys@tr2 at std@@YAXPB_W_J at Z(wstr int64) tr2_sys__Last_write_time_set_wchar
+@ cdecl -arch=win64 ?_Last_write_time at sys@tr2 at std@@YAXPEB_W_J at Z(wstr int64) tr2_sys__Last_write_time_set_wchar
 @ cdecl -ret64 -arch=win32 ?_Last_write_time at sys@tr2 at std@@YA_JPBD at Z(str) tr2_sys__Last_write_time
 @ cdecl -ret64 -arch=win64 ?_Last_write_time at sys@tr2 at std@@YA_JPEBD at Z(str) tr2_sys__Last_write_time
-@ stub -arch=win32 ?_Last_write_time at sys@tr2 at std@@YA_JPB_W at Z
-@ stub -arch=win64 ?_Last_write_time at sys@tr2 at std@@YA_JPEB_W at Z
+@ cdecl -ret64 -arch=win32 ?_Last_write_time at sys@tr2 at std@@YA_JPB_W at Z(wstr) tr2_sys__Last_write_time_wchar
+@ cdecl -ret64 -arch=win64 ?_Last_write_time at sys@tr2 at std@@YA_JPEB_W at Z(wstr) tr2_sys__Last_write_time_wchar
 @ cdecl -arch=arm ?_Launch at _Pad@std@@QAAXPAU_Thrd_imp_t@@@Z(ptr ptr) _Pad__Launch
 @ thiscall -arch=i386 ?_Launch at _Pad@std@@QAEXPAU_Thrd_imp_t@@@Z(ptr ptr) _Pad__Launch
 @ cdecl -arch=win64 ?_Launch at _Pad@std@@QEAAXPEAU_Thrd_imp_t@@@Z(ptr ptr) _Pad__Launch
diff --git a/dlls/msvcp120/msvcp120.spec b/dlls/msvcp120/msvcp120.spec
index 6aee8d7..dd25c9f 100644
--- a/dlls/msvcp120/msvcp120.spec
+++ b/dlls/msvcp120/msvcp120.spec
@@ -1522,12 +1522,12 @@
 @ cdecl -arch=win64 ?_Iput@?$num_put at _WV?$ostreambuf_iterator at _WU?$char_traits at _W@std@@@std@@@std@@AEBA?AV?$ostreambuf_iterator at _WU?$char_traits at _W@std@@@2 at V32@AEAVios_base at 2@_WPEAD_K at Z(ptr ptr ptr ptr long ptr long) num_put_wchar__Iput
 @ cdecl -arch=win32 ?_Last_write_time at sys@tr2 at std@@YAXPBD_J at Z(str int64) tr2_sys__Last_write_time_set
 @ cdecl -arch=win64 ?_Last_write_time at sys@tr2 at std@@YAXPEBD_J at Z(str int64) tr2_sys__Last_write_time_set
-@ stub -arch=win32 ?_Last_write_time at sys@tr2 at std@@YAXPB_W_J at Z
-@ stub -arch=win64 ?_Last_write_time at sys@tr2 at std@@YAXPEB_W_J at Z
+@ cdecl -arch=win32 ?_Last_write_time at sys@tr2 at std@@YAXPB_W_J at Z(wstr int64) tr2_sys__Last_write_time_set_wchar
+@ cdecl -arch=win64 ?_Last_write_time at sys@tr2 at std@@YAXPEB_W_J at Z(wstr int64) tr2_sys__Last_write_time_set_wchar
 @ cdecl -ret64 -arch=win32 ?_Last_write_time at sys@tr2 at std@@YA_JPBD at Z(str) tr2_sys__Last_write_time
 @ cdecl -ret64 -arch=win64 ?_Last_write_time at sys@tr2 at std@@YA_JPEBD at Z(str) tr2_sys__Last_write_time
-@ stub -arch=win32 ?_Last_write_time at sys@tr2 at std@@YA_JPB_W at Z
-@ stub -arch=win64 ?_Last_write_time at sys@tr2 at std@@YA_JPEB_W at Z
+@ cdecl -ret64 -arch=win32 ?_Last_write_time at sys@tr2 at std@@YA_JPB_W at Z(wstr) tr2_sys__Last_write_time_wchar
+@ cdecl -ret64 -arch=win64 ?_Last_write_time at sys@tr2 at std@@YA_JPEB_W at Z(wstr) tr2_sys__Last_write_time_wchar
 @ cdecl -arch=arm ?_Launch at _Pad@std@@QAAXPAU_Thrd_imp_t@@@Z(ptr ptr) _Pad__Launch
 @ thiscall -arch=i386 ?_Launch at _Pad@std@@QAEXPAU_Thrd_imp_t@@@Z(ptr ptr) _Pad__Launch
 @ cdecl -arch=win64 ?_Launch at _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 0963974..6f599b6 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 at _WV?$ostreambuf_iterator at _WU?$char_traits at _W@std@@@std@@@std@@AEBA?AV?$ostreambuf_iterator at _WU?$char_traits at _W@std@@@2 at V32@AEAVios_base at 2@_WPEAD_K at Z(ptr ptr ptr ptr long ptr long) msvcp120.?_Iput@?$num_put at _WV?$ostreambuf_iterator at _WU?$char_traits at _W@std@@@std@@@std@@AEBA?AV?$ostreambuf_iterator at _WU?$char_traits at _W@std@@@2 at V32@AEAVios_base at 2@_WPEAD_K at Z
 @ cdecl -arch=win32 ?_Last_write_time at sys@tr2 at std@@YAXPBD_J at Z(str int64) msvcp120.?_Last_write_time at sys@tr2 at std@@YAXPBD_J at Z
 @ cdecl -arch=win64 ?_Last_write_time at sys@tr2 at std@@YAXPEBD_J at Z(str int64) msvcp120.?_Last_write_time at sys@tr2 at std@@YAXPEBD_J at Z
-@ stub -arch=win32 ?_Last_write_time at sys@tr2 at std@@YAXPB_W_J at Z
-@ stub -arch=win64 ?_Last_write_time at sys@tr2 at std@@YAXPEB_W_J at Z
+@ cdecl -arch=win32 ?_Last_write_time at sys@tr2 at std@@YAXPB_W_J at Z(wstr int64) msvcp120.?_Last_write_time at sys@tr2 at std@@YAXPB_W_J at Z
+@ cdecl -arch=win64 ?_Last_write_time at sys@tr2 at std@@YAXPEB_W_J at Z(wstr int64) msvcp120.?_Last_write_time at sys@tr2 at std@@YAXPEB_W_J at Z
 @ cdecl -ret64 -arch=win32 ?_Last_write_time at sys@tr2 at std@@YA_JPBD at Z(str) msvcp120.?_Last_write_time at sys@tr2 at std@@YA_JPBD at Z
 @ cdecl -ret64 -arch=win64 ?_Last_write_time at sys@tr2 at std@@YA_JPEBD at Z(str) msvcp120.?_Last_write_time at sys@tr2 at std@@YA_JPEBD at Z
-@ stub -arch=win32 ?_Last_write_time at sys@tr2 at std@@YA_JPB_W at Z
-@ stub -arch=win64 ?_Last_write_time at sys@tr2 at std@@YA_JPEB_W at Z
+@ cdecl -ret64 -arch=win32 ?_Last_write_time at sys@tr2 at std@@YA_JPB_W at Z(wstr) msvcp120.?_Last_write_time at sys@tr2 at std@@YA_JPB_W at Z
+@ cdecl -ret64 -arch=win64 ?_Last_write_time at sys@tr2 at std@@YA_JPEB_W at Z(wstr) msvcp120.?_Last_write_time at sys@tr2 at std@@YA_JPEB_W at Z
 @ cdecl -arch=arm ?_Launch at _Pad@std@@QAAXPAU_Thrd_imp_t@@@Z(ptr ptr) msvcp120.?_Launch at _Pad@std@@QAAXPAU_Thrd_imp_t@@@Z
 @ thiscall -arch=i386 ?_Launch at _Pad@std@@QAEXPAU_Thrd_imp_t@@@Z(ptr ptr) msvcp120.?_Launch at _Pad@std@@QAEXPAU_Thrd_imp_t@@@Z
 @ cdecl -arch=win64 ?_Launch at _Pad@std@@QEAAXPEAU_Thrd_imp_t@@@Z(ptr ptr) msvcp120.?_Launch at _Pad@std@@QEAAXPEAU_Thrd_imp_t@@@Z
diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c
index fb9d668..d7de542 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 at sys@tr2 at std@@YA_JPBD at Z */
 /* ?_Last_write_time at sys@tr2 at std@@YA_JPEBD at 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 at sys@tr2 at std@@YA_JPB_W at Z */
+/* ?_Last_write_time at sys@tr2 at std@@YA_JPEB_W at 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 at sys@tr2 at std@@YAXPBD_J at 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 at sys@tr2 at std@@YAXPB_W_J at Z */
+/* ?_Last_write_time at sys@tr2 at std@@YAXPEB_W_J at 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);
 }
 




More information about the wine-cvs mailing list