YongHao Hu : msvcp110: Add tr2_sys__Current_set implementation and test.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Jun 15 08:49:10 CDT 2015


Module: wine
Branch: master
Commit: 64dfb0855070e6e33021a76570425a54a72f6e7b
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=64dfb0855070e6e33021a76570425a54a72f6e7b

Author: YongHao Hu <christopherwuy at gmail.com>
Date:   Sat Jun 13 00:30:49 2015 +0800

msvcp110: Add tr2_sys__Current_set implementation and test.

---

 dlls/msvcp110/msvcp110.spec         |  4 ++--
 dlls/msvcp120/msvcp120.spec         |  4 ++--
 dlls/msvcp120/tests/msvcp120.c      | 47 +++++++++++++++++++++++++++++++++++++
 dlls/msvcp120_app/msvcp120_app.spec |  4 ++--
 dlls/msvcp90/ios.c                  |  8 +++++++
 5 files changed, 61 insertions(+), 6 deletions(-)

diff --git a/dlls/msvcp110/msvcp110.spec b/dlls/msvcp110/msvcp110.spec
index 13d790e..a06d260 100644
--- a/dlls/msvcp110/msvcp110.spec
+++ b/dlls/msvcp110/msvcp110.spec
@@ -1171,8 +1171,8 @@
 @ cdecl -arch=win64 ?_Current_get at sys@tr2 at std@@YAPEADPEAD at Z(ptr) tr2_sys__Current_get
 @ stub -arch=win32 ?_Current_get at sys@tr2 at std@@YAPA_WPA_W at Z
 @ stub -arch=win64 ?_Current_get at sys@tr2 at std@@YAPEA_WPEA_W at Z
-@ stub -arch=win32 ?_Current_set at sys@tr2 at std@@YA_NPBD at Z
-@ stub -arch=win64 ?_Current_set at sys@tr2 at std@@YA_NPEBD at Z
+@ cdecl -arch=win32 ?_Current_set at sys@tr2 at std@@YA_NPBD at Z(str) tr2_sys__Current_set
+@ cdecl -arch=win64 ?_Current_set at sys@tr2 at std@@YA_NPEBD at Z(str) tr2_sys__Current_set
 @ stub -arch=win32 ?_Current_set at sys@tr2 at std@@YA_NPB_W at Z
 @ stub -arch=win64 ?_Current_set at sys@tr2 at std@@YA_NPEB_W at Z
 @ cdecl -arch=arm ?_Decref at facet@locale at std@@UAAPAV_Facet_base at 3@XZ(ptr) locale_facet__Decref
diff --git a/dlls/msvcp120/msvcp120.spec b/dlls/msvcp120/msvcp120.spec
index 9547473..275d7ab 100644
--- a/dlls/msvcp120/msvcp120.spec
+++ b/dlls/msvcp120/msvcp120.spec
@@ -1136,8 +1136,8 @@
 @ cdecl -arch=win64 ?_Current_get at sys@tr2 at std@@YAPEADAEAY0BAE at D@Z(ptr) tr2_sys__Current_get
 @ stub -arch=win32 ?_Current_get at sys@tr2 at std@@YAPA_WAAY0BAE at _W@Z
 @ stub -arch=win64 ?_Current_get at sys@tr2 at std@@YAPEA_WAEAY0BAE at _W@Z
-@ stub -arch=win32 ?_Current_set at sys@tr2 at std@@YA_NPBD at Z
-@ stub -arch=win64 ?_Current_set at sys@tr2 at std@@YA_NPEBD at Z
+@ cdecl -arch=win32 ?_Current_set at sys@tr2 at std@@YA_NPBD at Z(str) tr2_sys__Current_set
+@ cdecl -arch=win64 ?_Current_set at sys@tr2 at std@@YA_NPEBD at Z(str) tr2_sys__Current_set
 @ stub -arch=win32 ?_Current_set at sys@tr2 at std@@YA_NPB_W at Z
 @ stub -arch=win64 ?_Current_set at sys@tr2 at std@@YA_NPEB_W at Z
 @ cdecl -arch=arm ?_Decref at facet@locale at std@@UAAPAV_Facet_base at 3@XZ(ptr) locale_facet__Decref
diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c
index 6760a13..5953fbe 100644
--- a/dlls/msvcp120/tests/msvcp120.c
+++ b/dlls/msvcp120/tests/msvcp120.c
@@ -23,6 +23,7 @@
 #include "winbase.h"
 
 typedef int MSVCRT_long;
+typedef unsigned char MSVCP_bool;
 
 /* xtime */
 typedef struct {
@@ -62,6 +63,7 @@ static void (CDECL *p__Do_call)(void *this);
 static ULONGLONG(__cdecl *p_tr2_sys__File_size)(char const*);
 static int (__cdecl *p_tr2_sys__Equivalent)(char const*, char const*);
 static char* (__cdecl *p_tr2_sys__Current_get)(char *);
+static MSVCP_bool (__cdecl *p_tr2_sys__Current_set)(char const*);
 
 static HMODULE msvcp;
 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
@@ -96,6 +98,8 @@ static BOOL init(void)
                 "?_Equivalent at sys@tr2 at std@@YAHPEBD0 at Z");
         SET(p_tr2_sys__Current_get,
                 "?_Current_get at sys@tr2 at std@@YAPEADAEAY0BAE at D@Z");
+        SET(p_tr2_sys__Current_set,
+                "?_Current_set at sys@tr2 at std@@YA_NPEBD at Z");
     } else {
         SET(p_tr2_sys__File_size,
                 "?_File_size at sys@tr2 at std@@YA_KPBD at Z");
@@ -103,6 +107,8 @@ static BOOL init(void)
                 "?_Equivalent at sys@tr2 at std@@YAHPBD0 at Z");
         SET(p_tr2_sys__Current_get,
                 "?_Current_get at sys@tr2 at std@@YAPADAAY0BAE at D@Z");
+        SET(p_tr2_sys__Current_set,
+                "?_Current_set at sys@tr2 at std@@YA_NPBD at Z");
     }
 
     msvcr = GetModuleHandleA("msvcr120.dll");
@@ -423,6 +429,46 @@ static void test_tr2_sys__Current_get(void)
     ok(!strcmp(origin_path, current_path), "test_tr2_sys__Current_get(): expect: %s, got %s\n", origin_path, current_path);
 }
 
+static void test_tr2_sys__Current_set(void)
+{
+    char temp_path[MAX_PATH], current_path[MAX_PATH], origin_path[MAX_PATH];
+    char *temp;
+    memset(temp_path, 0, MAX_PATH);
+    GetTempPathA(MAX_PATH, temp_path);
+    memset(origin_path, 0, MAX_PATH);
+    GetCurrentDirectoryA(MAX_PATH, origin_path);
+    temp = p_tr2_sys__Current_get(origin_path);
+    ok(temp == origin_path, "p_tr2_sys__Current_get returned different buffer\n");
+
+    ok(p_tr2_sys__Current_set(temp_path), "p_tr2_sys__Current_set to temp_path failed\n");
+    memset(current_path, 0, MAX_PATH);
+    temp = p_tr2_sys__Current_get(current_path);
+    ok(temp == current_path, "p_tr2_sys__Current_get returned different buffer\n");
+    temp[strlen(temp)] = '\\';
+    ok(!strcmp(temp_path, current_path), "test_tr2_sys__Current_get(): expect: %s, got %s\n", temp_path, current_path);
+
+    ok(p_tr2_sys__Current_set("./"), "p_tr2_sys__Current_set to temp_path failed\n");
+    memset(current_path, 0, MAX_PATH);
+    temp = p_tr2_sys__Current_get(current_path);
+    ok(temp == current_path, "p_tr2_sys__Current_get returned different buffer\n");
+    temp[strlen(temp)] = '\\';
+    ok(!strcmp(temp_path, current_path), "test_tr2_sys__Current_get(): expect: %s, got %s\n", temp_path, current_path);
+
+    errno = 0xdeadbeef;
+    ok(!p_tr2_sys__Current_set("not_exisist_dir"), "p_tr2_sys__Current_set to not_exist_dir succeed\n");
+    ok(errno == 0xdeadbeef, "errno = %d\n", errno);
+
+    errno = 0xdeadbeef;
+    ok(!p_tr2_sys__Current_set("??invalid_name>>"), "p_tr2_sys__Current_set to ??invalid_name>> succeed\n");
+    ok(errno == 0xdeadbeef, "errno = %d\n", errno);
+
+    ok(p_tr2_sys__Current_set(origin_path), "p_tr2_sys__Current_set to origin_path failed\n");
+    memset(current_path, 0, MAX_PATH);
+    temp = p_tr2_sys__Current_get(current_path);
+    ok(temp == current_path, "p_tr2_sys__Current_get returned different buffer\n");
+    ok(!strcmp(origin_path, current_path), "test_tr2_sys__Current_get(): expect: %s, got %s\n", origin_path, current_path);
+}
+
 START_TEST(msvcp120)
 {
     if(!init()) return;
@@ -435,5 +481,6 @@ START_TEST(msvcp120)
     test_tr2_sys__File_size();
     test_tr2_sys__Equivalent();
     test_tr2_sys__Current_get();
+    test_tr2_sys__Current_set();
     FreeLibrary(msvcp);
 }
diff --git a/dlls/msvcp120_app/msvcp120_app.spec b/dlls/msvcp120_app/msvcp120_app.spec
index 11e208a..596eee5 100644
--- a/dlls/msvcp120_app/msvcp120_app.spec
+++ b/dlls/msvcp120_app/msvcp120_app.spec
@@ -1136,8 +1136,8 @@
 @ cdecl -arch=win64 ?_Current_get at sys@tr2 at std@@YAPEADAEAY0BAE at D@Z(ptr) msvcp120.?_Current_get at sys@tr2 at std@@YAPEADAEAY0BAE at D@Z
 @ stub -arch=win32 ?_Current_get at sys@tr2 at std@@YAPA_WAAY0BAE at _W@Z
 @ stub -arch=win64 ?_Current_get at sys@tr2 at std@@YAPEA_WAEAY0BAE at _W@Z
-@ stub -arch=win32 ?_Current_set at sys@tr2 at std@@YA_NPBD at Z
-@ stub -arch=win64 ?_Current_set at sys@tr2 at std@@YA_NPEBD at Z
+@ cdecl -arch=win32 ?_Current_set at sys@tr2 at std@@YA_NPBD at Z(str) msvcp120.?_Current_set at sys@tr2 at std@@YA_NPBD at Z
+@ cdecl -arch=win64 ?_Current_set at sys@tr2 at std@@YA_NPEBD at Z(str) msvcp120.?_Current_set at sys@tr2 at std@@YA_NPEBD at Z
 @ stub -arch=win32 ?_Current_set at sys@tr2 at std@@YA_NPB_W at Z
 @ stub -arch=win64 ?_Current_set at sys@tr2 at std@@YA_NPEB_W at Z
 @ cdecl -arch=arm ?_Decref at facet@locale at std@@UAAPAV_Facet_base at 3@XZ(ptr) msvcp120.?_Decref at facet@locale at std@@UAAPAV_Facet_base at 3@XZ
diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c
index e11d8c4..e78c46b 100644
--- a/dlls/msvcp90/ios.c
+++ b/dlls/msvcp90/ios.c
@@ -14252,6 +14252,14 @@ char* __cdecl tr2_sys__Current_get(char *current_path)
     return current_path;
 }
 
+/* ?_Current_set at sys@tr2 at std@@YA_NPBD at Z */
+/* ?_Current_set at sys@tr2 at std@@YA_NPEBD at Z */
+MSVCP_bool __cdecl tr2_sys__Current_set(char const* path)
+{
+    TRACE("(%p)\n", path);
+    return SetCurrentDirectoryA(path) != 0;
+}
+
 /* ??0strstream at std@@QAE at PADHH@Z */
 /* ??0strstream at std@@QEAA at PEAD_JH@Z */
 #if STREAMSIZE_BITS == 64




More information about the wine-cvs mailing list