From: YongHaoHu Subject: [PATCH 3/6]: msvcp110: Add tr2_sys__Statvfs implementation and test.(try 2) Message-Id: <5596083C.3010607@gmail.com> Date: Fri, 3 Jul 2015 11:57:48 +0800 try2: Use QuadPart instead of LowPart and HighPart. --- 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 46f49a0..3a9e025 100644 --- a/dlls/msvcp110/msvcp110.spec +++ b/dlls/msvcp110/msvcp110.spec @@ -1761,8 +1761,8 @@ @ stub -arch=win64 ?_Stat@sys@tr2@std@@YA?AW4file_type@123@PEBDAEAH@Z @ stub -arch=win32 ?_Stat@sys@tr2@std@@YA?AW4file_type@123@PB_WAAH@Z @ stub -arch=win64 ?_Stat@sys@tr2@std@@YA?AW4file_type@123@PEB_WAEAH@Z -@ stub -arch=win32 ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PBD@Z -@ stub -arch=win64 ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PEBD@Z +@ cdecl -arch=win32 ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PBD@Z(str) tr2_sys__Statvfs +@ cdecl -arch=win64 ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PEBD@Z(str) tr2_sys__Statvfs @ stub -arch=win32 ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PB_W@Z @ stub -arch=win64 ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PEB_W@Z @ cdecl -arch=arm ?_Swap_all@_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@sys@tr2@std@@YA?AW4file_type@123@PEBDAEAH@Z @ stub -arch=win32 ?_Stat@sys@tr2@std@@YA?AW4file_type@123@PB_WAAH@Z @ stub -arch=win64 ?_Stat@sys@tr2@std@@YA?AW4file_type@123@PEB_WAEAH@Z -@ stub -arch=win32 ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PBD@Z -@ stub -arch=win64 ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PEBD@Z +@ cdecl -arch=win32 ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PBD@Z(str) tr2_sys__Statvfs +@ cdecl -arch=win64 ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PEBD@Z(str) tr2_sys__Statvfs @ stub -arch=win32 ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PB_W@Z @ stub -arch=win64 ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PEB_W@Z @ cdecl -arch=arm ?_Swap_all@_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 61271a8..38085b7 100644 --- a/dlls/msvcp120/tests/msvcp120.c +++ b/dlls/msvcp120/tests/msvcp120.c @@ -38,6 +38,12 @@ typedef struct { BYTE isleadbyte[32]; } _Cvtvec; +typedef struct { + ULONGLONG capacity; + ULONGLONG free; + ULONGLONG available; +} space_info; + 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 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@sys@tr2@std@@YAHPEBD0_N@Z"); SET(p_tr2_sys__Rename, "?_Rename@sys@tr2@std@@YAHPEBD0@Z"); + SET(p_tr2_sys__Statvfs, + "?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PEBD@Z"); } else { SET(p_tr2_sys__File_size, "?_File_size@sys@tr2@std@@YA_KPBD@Z"); @@ -129,6 +138,8 @@ static BOOL init(void) "?_Copy_file@sys@tr2@std@@YAHPBD0_N@Z"); SET(p_tr2_sys__Rename, "?_Rename@sys@tr2@std@@YAHPBD0@Z"); + SET(p_tr2_sys__Statvfs, + "?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PBD@Z"); } msvcr = GetModuleHandleA("msvcr120.dll"); @@ -651,6 +662,34 @@ static void test_tr2_sys__Rename(void) ok(SetCurrentDirectoryA(current_path), "SetCurrentDirectoryA failed\n"); } +static void test_tr2_sys__Statvfs(void) +{ + 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; @@ -668,5 +707,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@sys@tr2@std@@YA?AW4file_type@123@PEBDAEAH@Z @ stub -arch=win32 ?_Stat@sys@tr2@std@@YA?AW4file_type@123@PB_WAAH@Z @ stub -arch=win64 ?_Stat@sys@tr2@std@@YA?AW4file_type@123@PEB_WAEAH@Z -@ stub -arch=win32 ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PBD@Z -@ stub -arch=win64 ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PEBD@Z +@ cdecl -arch=win32 ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PBD@Z(str) msvcp120.?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PBD@Z +@ cdecl -arch=win64 ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PEBD@Z(str) msvcp120.?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PEBD@Z @ stub -arch=win32 ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PB_W@Z @ stub -arch=win64 ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PEB_W@Z @ cdecl -arch=arm ?_Swap_all@_Container_base0@std@@QAAXAAU12@@Z(ptr ptr) msvcp120.?_Swap_all@_Container_base0@std@@QAAXAAU12@@Z diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c index b5fa7c9..225416d 100644 --- a/dlls/msvcp90/ios.c +++ b/dlls/msvcp90/ios.c @@ -318,6 +318,12 @@ typedef struct { */ } strstream; +typedef struct { + ULONGLONG capacity; + ULONGLONG free; + ULONGLONG available; +} space_info; + #if _MSVCP_VER >= 100 #define VBTABLE_ALIGN 8 #else @@ -14308,6 +14314,24 @@ int __cdecl tr2_sys__Rename(char const* old_path, char const* new_path) return GetLastError(); } +/* ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PBD@Z */ +/* ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PEBD@Z */ +space_info __cdecl tr2_sys__Statvfs(const char* path) +{ + ULARGE_INTEGER available, total, free; + 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@std@@QAE@PADHH@Z */ /* ??0strstream@std@@QEAA@PEAD_JH@Z */ #if STREAMSIZE_BITS == 64