YongHao Hu : msvcp110: Add tr2_sys__Statvfs implementation and test.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Jul 7 08:11:58 CDT 2015


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

Author: YongHao Hu <christopherwuy at gmail.com>
Date:   Tue Jul  7 15:10:01 2015 +0800

msvcp110: Add tr2_sys__Statvfs implementation and test.

---

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

diff --git a/dlls/msvcp110/msvcp110.spec b/dlls/msvcp110/msvcp110.spec
index edc43a8..a8692ec 100644
--- a/dlls/msvcp110/msvcp110.spec
+++ b/dlls/msvcp110/msvcp110.spec
@@ -1761,8 +1761,8 @@
 @ stub -arch=win64 ?_Stat at sys@tr2 at std@@YA?AW4file_type at 123@PEBDAEAH at Z
 @ stub -arch=win32 ?_Stat at sys@tr2 at std@@YA?AW4file_type at 123@PB_WAAH at Z
 @ stub -arch=win64 ?_Stat at sys@tr2 at std@@YA?AW4file_type at 123@PEB_WAEAH at Z
-@ stub -arch=win32 ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PBD at Z
-@ stub -arch=win64 ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PEBD at Z
+@ cdecl -arch=win32 ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PBD at Z(str) tr2_sys__Statvfs
+@ cdecl -arch=win64 ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PEBD at Z(str) tr2_sys__Statvfs
 @ stub -arch=win32 ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PB_W at Z
 @ stub -arch=win64 ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PEB_W at Z
 @ cdecl -arch=arm ?_Swap_all at _Container_base0@std@@QAAXAAU12@@Z(ptr ptr) Container_base0_Swap_all
diff --git a/dlls/msvcp120/msvcp120.spec b/dlls/msvcp120/msvcp120.spec
index 4993e01..b251ca3 100644
--- a/dlls/msvcp120/msvcp120.spec
+++ b/dlls/msvcp120/msvcp120.spec
@@ -1722,8 +1722,8 @@
 @ stub -arch=win64 ?_Stat at sys@tr2 at std@@YA?AW4file_type at 123@PEBDAEAH at Z
 @ stub -arch=win32 ?_Stat at sys@tr2 at std@@YA?AW4file_type at 123@PB_WAAH at Z
 @ stub -arch=win64 ?_Stat at sys@tr2 at std@@YA?AW4file_type at 123@PEB_WAEAH at Z
-@ stub -arch=win32 ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PBD at Z
-@ stub -arch=win64 ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PEBD at Z
+@ cdecl -arch=win32 ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PBD at Z(str) tr2_sys__Statvfs
+@ cdecl -arch=win64 ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PEBD at Z(str) tr2_sys__Statvfs
 @ stub -arch=win32 ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PB_W at Z
 @ stub -arch=win64 ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PEB_W at Z
 @ cdecl -arch=arm ?_Swap_all at _Container_base0@std@@QAAXAAU12@@Z(ptr ptr) Container_base0_Swap_all
diff --git a/dlls/msvcp120/tests/msvcp120.c b/dlls/msvcp120/tests/msvcp120.c
index 3b43c13..bc7c69b 100644
--- a/dlls/msvcp120/tests/msvcp120.c
+++ b/dlls/msvcp120/tests/msvcp120.c
@@ -38,6 +38,12 @@ typedef struct {
     BYTE isleadbyte[32];
 } _Cvtvec;
 
+struct space_info {
+    ULONGLONG capacity;
+    ULONGLONG free;
+    ULONGLONG available;
+};
+
 static inline const char* debugstr_longlong(ULONGLONG ll)
 {
     static char string[17];
@@ -68,6 +74,7 @@ static int (__cdecl *p_tr2_sys__Make_dir)(char const*);
 static MSVCP_bool (__cdecl *p_tr2_sys__Remove_dir)(char const*);
 static int (__cdecl *p_tr2_sys__Copy_file)(char const*, char const*, MSVCP_bool);
 static int (__cdecl *p_tr2_sys__Rename)(char const*, char const*);
+static struct space_info (__cdecl *p_tr2_sys__Statvfs)(char const*);
 
 static HMODULE msvcp;
 #define SETNOFAIL(x,y) x = (void*)GetProcAddress(msvcp,y)
@@ -112,6 +119,8 @@ static BOOL init(void)
                 "?_Copy_file at sys@tr2 at std@@YAHPEBD0_N at Z");
         SET(p_tr2_sys__Rename,
                 "?_Rename at sys@tr2 at std@@YAHPEBD0 at Z");
+        SET(p_tr2_sys__Statvfs,
+                "?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PEBD at Z");
     } else {
         SET(p_tr2_sys__File_size,
                 "?_File_size at sys@tr2 at std@@YA_KPBD at Z");
@@ -129,6 +138,8 @@ static BOOL init(void)
                 "?_Copy_file at sys@tr2 at std@@YAHPBD0_N at Z");
         SET(p_tr2_sys__Rename,
                 "?_Rename at sys@tr2 at std@@YAHPBD0 at Z");
+        SET(p_tr2_sys__Statvfs,
+                "?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PBD at Z");
     }
 
     msvcr = GetModuleHandleA("msvcr120.dll");
@@ -668,6 +679,34 @@ static void test_tr2_sys__Rename(void)
     ok(SetCurrentDirectoryA(current_path), "SetCurrentDirectoryA failed\n");
 }
 
+static void test_tr2_sys__Statvfs(void)
+{
+    struct space_info info;
+    char current_path[MAX_PATH];
+    memset(current_path, 0, MAX_PATH);
+    p_tr2_sys__Current_get(current_path);
+
+    info = p_tr2_sys__Statvfs(current_path);
+    ok(info.capacity >= info.free, "test_tr2_sys__Statvfs(): info.capacity < info.free\n");
+    ok(info.free >= info.available, "test_tr2_sys__Statvfs(): info.free < info.available\n");
+
+    info = p_tr2_sys__Statvfs(NULL);
+    ok(info.available == 0, "test_tr2_sys__Statvfs(): info.available expect: %d, got %s\n",
+            0, debugstr_longlong(info.available));
+    ok(info.capacity == 0, "test_tr2_sys__Statvfs(): info.capacity expect: %d, got %s\n",
+            0, debugstr_longlong(info.capacity));
+    ok(info.free == 0, "test_tr2_sys__Statvfs(): info.free expect: %d, got %s\n",
+            0, debugstr_longlong(info.free));
+
+    info = p_tr2_sys__Statvfs("not_exist");
+    ok(info.available == 0, "test_tr2_sys__Statvfs(): info.available expect: %d, got %s\n",
+            0, debugstr_longlong(info.available));
+    ok(info.capacity == 0, "test_tr2_sys__Statvfs(): info.capacity expect: %d, got %s\n",
+            0, debugstr_longlong(info.capacity));
+    ok(info.free == 0, "test_tr2_sys__Statvfs(): info.free expect: %d, got %s\n",
+            0, debugstr_longlong(info.free));
+}
+
 START_TEST(msvcp120)
 {
     if(!init()) return;
@@ -685,5 +724,6 @@ START_TEST(msvcp120)
     test_tr2_sys__Remove_dir();
     test_tr2_sys__Copy_file();
     test_tr2_sys__Rename();
+    test_tr2_sys__Statvfs();
     FreeLibrary(msvcp);
 }
diff --git a/dlls/msvcp120_app/msvcp120_app.spec b/dlls/msvcp120_app/msvcp120_app.spec
index fc7efa2..40db7e3 100644
--- a/dlls/msvcp120_app/msvcp120_app.spec
+++ b/dlls/msvcp120_app/msvcp120_app.spec
@@ -1722,8 +1722,8 @@
 @ stub -arch=win64 ?_Stat at sys@tr2 at std@@YA?AW4file_type at 123@PEBDAEAH at Z
 @ stub -arch=win32 ?_Stat at sys@tr2 at std@@YA?AW4file_type at 123@PB_WAAH at Z
 @ stub -arch=win64 ?_Stat at sys@tr2 at std@@YA?AW4file_type at 123@PEB_WAEAH at Z
-@ stub -arch=win32 ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PBD at Z
-@ stub -arch=win64 ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PEBD at Z
+@ cdecl -arch=win32 ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PBD at Z(str) msvcp120.?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PBD at Z
+@ cdecl -arch=win64 ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PEBD at Z(str) msvcp120.?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PEBD at Z
 @ stub -arch=win32 ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PB_W at Z
 @ stub -arch=win64 ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PEB_W at Z
 @ cdecl -arch=arm ?_Swap_all at _Container_base0@std@@QAAXAAU12@@Z(ptr ptr) msvcp120.?_Swap_all at _Container_base0@std@@QAAXAAU12@@Z
diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c
index 2628855..2311c58 100644
--- a/dlls/msvcp90/ios.c
+++ b/dlls/msvcp90/ios.c
@@ -318,6 +318,12 @@ typedef struct {
      */
 } strstream;
 
+struct space_info {
+    ULONGLONG capacity;
+    ULONGLONG free;
+    ULONGLONG available;
+};
+
 #if _MSVCP_VER >= 100
 #define VBTABLE_ALIGN 8
 #else
@@ -14309,6 +14315,24 @@ int __cdecl tr2_sys__Rename(char const* old_path, char const* new_path)
     return GetLastError();
 }
 
+/* ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PBD at Z */
+/* ?_Statvfs at sys@tr2 at std@@YA?AUspace_info at 123@PEBD at Z */
+struct space_info __cdecl tr2_sys__Statvfs(const char* path)
+{
+    ULARGE_INTEGER available, total, free;
+    struct space_info info;
+    TRACE("(%s)\n", debugstr_a(path));
+
+    if(!path || !GetDiskFreeSpaceExA(path, &available, &total, &free)) {
+        info.capacity = info.free = info.available = 0;
+    }else {
+        info.capacity = total.QuadPart;
+        info.free = free.QuadPart;
+        info.available = available.QuadPart;
+    }
+    return info;
+}
+
 /* ??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