YongHao Hu : msvcp110: Add tr2_sys__Unlink implementation and test.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Feb 22 08:57:39 CST 2016


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

Author: YongHao Hu <christopherwuy at gmail.com>
Date:   Sat Feb 20 00:40:34 2016 +0800

msvcp110: Add tr2_sys__Unlink implementation and test.

Signed-off-by: YongHao Hu <christopherwuy at gmail.com>
Signed-off-by: Piotr Caban <piotr at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

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

diff --git a/dlls/msvcp110/msvcp110.spec b/dlls/msvcp110/msvcp110.spec
index 3d89924..1d9525c 100644
--- a/dlls/msvcp110/msvcp110.spec
+++ b/dlls/msvcp110/msvcp110.spec
@@ -1805,8 +1805,8 @@
 @ cdecl -arch=win32 ?_Tidy at ios_base@std@@AAAXXZ(ptr) ios_base_Tidy
 @ stub -arch=i386 ?_Tidy at ios_base@std@@AAEXXZ
 @ cdecl -arch=win64 ?_Tidy at ios_base@std@@AEAAXXZ(ptr) ios_base_Tidy
-@ stub -arch=win32 ?_Unlink at sys@tr2 at std@@YAHPBD at Z
-@ stub -arch=win64 ?_Unlink at sys@tr2 at std@@YAHPEBD at Z
+@ cdecl -arch=win32 ?_Unlink at sys@tr2 at std@@YAHPBD at Z(str) tr2_sys__Unlink
+@ cdecl -arch=win64 ?_Unlink at sys@tr2 at std@@YAHPEBD at Z(str) tr2_sys__Unlink
 @ stub -arch=win32 ?_Unlink at sys@tr2 at std@@YAHPB_W at Z
 @ stub -arch=win64 ?_Unlink at sys@tr2 at std@@YAHPEB_W at Z
 @ cdecl -arch=arm ?_Unlock@?$basic_streambuf at DU?$char_traits at D@std@@@std@@UAAXXZ(ptr) basic_streambuf_char__Unlock
diff --git a/dlls/msvcp120/msvcp120.spec b/dlls/msvcp120/msvcp120.spec
index 1bb487e..e5daa62 100644
--- a/dlls/msvcp120/msvcp120.spec
+++ b/dlls/msvcp120/msvcp120.spec
@@ -1766,8 +1766,8 @@
 @ cdecl -arch=win32 ?_Tidy at ios_base@std@@AAAXXZ(ptr) ios_base_Tidy
 @ stub -arch=i386 ?_Tidy at ios_base@std@@AAEXXZ
 @ cdecl -arch=win64 ?_Tidy at ios_base@std@@AEAAXXZ(ptr) ios_base_Tidy
-@ stub -arch=win32 ?_Unlink at sys@tr2 at std@@YAHPBD at Z
-@ stub -arch=win64 ?_Unlink at sys@tr2 at std@@YAHPEBD at Z
+@ cdecl -arch=win32 ?_Unlink at sys@tr2 at std@@YAHPBD at Z(str) tr2_sys__Unlink
+@ cdecl -arch=win64 ?_Unlink at sys@tr2 at std@@YAHPEBD at Z(str) tr2_sys__Unlink
 @ stub -arch=win32 ?_Unlink at sys@tr2 at std@@YAHPB_W at Z
 @ stub -arch=win64 ?_Unlink at sys@tr2 at std@@YAHPEB_W at Z
 @ cdecl -arch=arm ?_Unlock@?$basic_streambuf at DU?$char_traits at D@std@@@std@@UAAXXZ(ptr) basic_streambuf_char__Unlock
diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c
index f884d0c..17a41d1 100644
--- a/dlls/msvcp120/tests/msvcp120.c
+++ b/dlls/msvcp120/tests/msvcp120.c
@@ -134,6 +134,7 @@ static char* (__cdecl *p_tr2_sys__Read_dir)(char*, void*, enum file_type*);
 static void (__cdecl *p_tr2_sys__Close_dir)(void*);
 static int (__cdecl *p_tr2_sys__Link)(char const*, char const*);
 static int (__cdecl *p_tr2_sys__Symlink)(char const*, char const*);
+static int (__cdecl *p_tr2_sys__Unlink)(char const*);
 
 /* thrd */
 typedef struct
@@ -271,6 +272,8 @@ static BOOL init(void)
                 "?_Link at sys@tr2 at std@@YAHPEBD0 at Z");
         SET(p_tr2_sys__Symlink,
                 "?_Symlink at sys@tr2 at std@@YAHPEBD0 at Z");
+        SET(p_tr2_sys__Unlink,
+                "?_Unlink at sys@tr2 at std@@YAHPEBD at Z");
         SET(p__Thrd_current,
                 "_Thrd_current");
     } else {
@@ -328,6 +331,8 @@ static BOOL init(void)
                 "?_Link at sys@tr2 at std@@YAHPBD0 at Z");
         SET(p_tr2_sys__Symlink,
                 "?_Symlink at sys@tr2 at std@@YAHPBD0 at Z");
+        SET(p_tr2_sys__Unlink,
+                "?_Unlink at sys@tr2 at std@@YAHPBD at Z");
 #ifdef __i386__
         SET(p_i386_Thrd_current,
                 "_Thrd_current");
@@ -1460,6 +1465,60 @@ static void test_tr2_sys__Symlink(void)
     ok(ret == 1, "tr2_sys__Remove_dir(): expect 1 got %d\n", ret);
 }
 
+static void test_tr2_sys__Unlink(void)
+{
+    int ret, i;
+    HANDLE file;
+    LARGE_INTEGER file_size;
+    struct {
+        char const *path;
+        int last_error;
+        MSVCP_bool is_todo;
+    } tests[] = {
+        { "tr2_test_dir\\f1_symlink", ERROR_SUCCESS, TRUE },
+        { "tr2_test_dir\\f1_link", ERROR_SUCCESS, FALSE },
+        { "tr2_test_dir\\f1", ERROR_SUCCESS, FALSE },
+        { "tr2_test_dir", ERROR_ACCESS_DENIED, FALSE },
+        { "not_exist", ERROR_FILE_NOT_FOUND, FALSE },
+        { "not_exist_dir\\not_exist_file", ERROR_PATH_NOT_FOUND, FALSE },
+        { NULL, ERROR_PATH_NOT_FOUND, FALSE }
+    };
+
+    ret = p_tr2_sys__Make_dir("tr2_test_dir");
+    ok(ret == 1, "tr2_sys__Make_dir(): expect 1 got %d\n", ret);
+    file = CreateFileA("tr2_test_dir/f1", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
+    ok(file != INVALID_HANDLE_VALUE, "create file failed: INVALID_HANDLE_VALUE\n");
+    file_size.QuadPart = 7;
+    ok(SetFilePointerEx(file, file_size, NULL, FILE_BEGIN), "SetFilePointerEx failed\n");
+    ok(SetEndOfFile(file), "SetEndOfFile failed\n");
+    CloseHandle(file);
+
+    ret = p_tr2_sys__Symlink("tr2_test_dir/f1", "tr2_test_dir/f1_symlink");
+    if(ret==ERROR_PRIVILEGE_NOT_HELD || ret==ERROR_INVALID_FUNCTION) {
+        tests[0].last_error = ERROR_FILE_NOT_FOUND;
+        win_skip("Privilege not held or symbolic link not supported, skipping symbolic link tests.\n");
+    }else {
+        ok(ret == ERROR_SUCCESS, "tr2_sys__Symlink(): expect: ERROR_SUCCESS, got %d\n", ret);
+    }
+    ret = p_tr2_sys__Link("tr2_test_dir/f1", "tr2_test_dir/f1_link");
+    ok(ret == ERROR_SUCCESS, "tr2_sys__Link(): expect: ERROR_SUCCESS, got %d\n", ret);
+
+    for(i=0; i<sizeof(tests)/sizeof(tests[0]); i++) {
+        errno = 0xdeadbeef;
+        ret = p_tr2_sys__Unlink(tests[i].path);
+        todo_wine_if(tests[i].is_todo)
+            ok(ret == tests[i].last_error, "tr2_sys__Unlink(): test %d expect: %d, got %d\n",
+                    i+1, tests[i].last_error, ret);
+        ok(errno == 0xdeadbeef, "tr2_sys__Unlink(): test %d errno expect: 0xdeadbeef, got %d\n", i+1, ret);
+    }
+
+    ok(!DeleteFileA("tr2_test_dir/f1"), "expect tr2_test_dir/f1 not to exist\n");
+    ok(!DeleteFileA("tr2_test_dir/f1_link"), "expect tr2_test_dir/f1_link not to exist\n");
+    ok(!DeleteFileA("tr2_test_dir/f1_symlink"), "expect tr2_test_dir/f1_symlink not to exist\n");
+    ret = p_tr2_sys__Remove_dir("tr2_test_dir");
+    ok(ret == 1, "tr2_sys__Remove_dir(): expect 1 got %d\n", ret);
+}
+
 static int __cdecl thrd_thread(void *arg)
 {
     _Thrd_t *thr = arg;
@@ -1751,6 +1810,7 @@ START_TEST(msvcp120)
     test_tr2_sys__dir_operation();
     test_tr2_sys__Link();
     test_tr2_sys__Symlink();
+    test_tr2_sys__Unlink();
 
     test_thrd();
     test_cnd();
diff --git a/dlls/msvcp120_app/msvcp120_app.spec b/dlls/msvcp120_app/msvcp120_app.spec
index 2d0a95b..5da4e05 100644
--- a/dlls/msvcp120_app/msvcp120_app.spec
+++ b/dlls/msvcp120_app/msvcp120_app.spec
@@ -1766,8 +1766,8 @@
 @ cdecl -arch=win32 ?_Tidy at ios_base@std@@AAAXXZ(ptr) msvcp120.?_Tidy at ios_base@std@@AAAXXZ
 @ stub -arch=i386 ?_Tidy at ios_base@std@@AAEXXZ
 @ cdecl -arch=win64 ?_Tidy at ios_base@std@@AEAAXXZ(ptr) msvcp120.?_Tidy at ios_base@std@@AEAAXXZ
-@ stub -arch=win32 ?_Unlink at sys@tr2 at std@@YAHPBD at Z
-@ stub -arch=win64 ?_Unlink at sys@tr2 at std@@YAHPEBD at Z
+@ cdecl -arch=win32 ?_Unlink at sys@tr2 at std@@YAHPBD at Z(str) msvcp120.?_Unlink at sys@tr2 at std@@YAHPBD at Z
+@ cdecl -arch=win64 ?_Unlink at sys@tr2 at std@@YAHPEBD at Z(str) msvcp120.?_Unlink at sys@tr2 at std@@YAHPEBD at Z
 @ stub -arch=win32 ?_Unlink at sys@tr2 at std@@YAHPB_W at Z
 @ stub -arch=win64 ?_Unlink at sys@tr2 at std@@YAHPEB_W at Z
 @ cdecl -arch=arm ?_Unlock@?$basic_streambuf at DU?$char_traits at D@std@@@std@@UAAXXZ(ptr) msvcp120.?_Unlock@?$basic_streambuf at DU?$char_traits at D@std@@@std@@UAAXXZ
diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c
index d9ff610..1613402 100644
--- a/dlls/msvcp90/ios.c
+++ b/dlls/msvcp90/ios.c
@@ -14782,6 +14782,17 @@ int __cdecl tr2_sys__Symlink(char const* existing_file_name, char const* file_na
     return GetLastError();
 }
 
+/* ?_Unlink at sys@tr2 at std@@YAHPBD at Z */
+/* ?_Unlink at sys@tr2 at std@@YAHPEBD at Z */
+int __cdecl tr2_sys__Unlink(char const* path)
+{
+    TRACE("(%s)\n", debugstr_a(path));
+
+    if(DeleteFileA(path))
+        return ERROR_SUCCESS;
+    return GetLastError();
+}
+
 /* ??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