Commit 61beb57c authored by YongHao Hu's avatar YongHao Hu Committed by Alexandre Julliard

msvcp110: Add tr2_sys__Statvfs implementation and test.

parent de571b8a
......@@ -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
......
......@@ -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
......
......@@ -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@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");
......@@ -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);
}
......@@ -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
......
......@@ -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@sys@tr2@std@@YA?AUspace_info@123@PBD@Z */
/* ?_Statvfs@sys@tr2@std@@YA?AUspace_info@123@PEBD@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@std@@QAE@PADHH@Z */
/* ??0strstream@std@@QEAA@PEAD_JH@Z */
#if STREAMSIZE_BITS == 64
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment