msvcp140: Implement _File_size.
Signed-off-by: Stefan Dösinger <stefan@codeweavers.com> Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
d6e2a6f370
commit
dc736dae63
|
@ -3648,7 +3648,7 @@
|
|||
@ extern _FNan _FNan
|
||||
@ stub _FSinh
|
||||
@ extern _FSnan _FSnan
|
||||
@ stub _File_size
|
||||
@ cdecl _File_size(wstr)
|
||||
@ cdecl -ret64 _Getcoll() _Getcoll
|
||||
@ cdecl _Getctype(ptr) _Getctype
|
||||
@ cdecl _Getcvt(ptr) _Getcvt
|
||||
|
|
|
@ -152,6 +152,7 @@ static int (__cdecl *p__Schedule_chore)(_Threadpool_chore*);
|
|||
static int (__cdecl *p__Reschedule_chore)(const _Threadpool_chore*);
|
||||
static void (__cdecl *p__Release_chore)(_Threadpool_chore*);
|
||||
|
||||
static ULONGLONG (__cdecl *p_File_size)(WCHAR const *);
|
||||
static int (__cdecl *p_To_byte)(const WCHAR *src, char *dst);
|
||||
static int (__cdecl *p_To_wide)(const char *src, WCHAR *dst);
|
||||
|
||||
|
@ -216,6 +217,7 @@ static BOOL init(void)
|
|||
SET(p__Release_chore, "?_Release_chore@details@Concurrency@@YAXPAU_Threadpool_chore@12@@Z");
|
||||
}
|
||||
|
||||
SET(p_File_size, "_File_size");
|
||||
SET(p_To_byte, "_To_byte");
|
||||
SET(p_To_wide, "_To_wide");
|
||||
|
||||
|
@ -563,6 +565,59 @@ static void test_to_wide(void)
|
|||
}
|
||||
}
|
||||
|
||||
static void test_File_size(void)
|
||||
{
|
||||
ULONGLONG val;
|
||||
HANDLE file;
|
||||
LARGE_INTEGER file_size;
|
||||
WCHAR test_f1_W[] = {'w','i','n','e','_','t','e','s','t','_','d','i','r','/','f','1',0};
|
||||
WCHAR test_f2_W[] = {'w','i','n','e','_','t','e','s','t','_','d','i','r','/','f','2',0};
|
||||
WCHAR test_dir_W[] = {'w','i','n','e','_','t','e','s','t','_','d','i','r',0};
|
||||
WCHAR test_ne_W[] = {'w','i','n','e','_','t','e','s','t','_','d','i','r','/','n','e',0};
|
||||
WCHAR temp_path[MAX_PATH], origin_path[MAX_PATH];
|
||||
|
||||
memset(origin_path, 0, sizeof(origin_path));
|
||||
memset(origin_path, 0, sizeof(temp_path));
|
||||
GetCurrentDirectoryW(MAX_PATH, origin_path);
|
||||
GetTempPathW(MAX_PATH, temp_path);
|
||||
ok(SetCurrentDirectoryW(temp_path), "SetCurrentDirectoryW to temp_path failed\n");
|
||||
|
||||
CreateDirectoryW(test_dir_W, NULL);
|
||||
|
||||
file = CreateFileW(test_f1_W, 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);
|
||||
val = p_File_size(test_f1_W);
|
||||
ok(val == 7, "file_size is %s\n", wine_dbgstr_longlong(val));
|
||||
|
||||
file = CreateFileW(test_f2_W, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
|
||||
ok(file != INVALID_HANDLE_VALUE, "create file failed: INVALID_HANDLE_VALUE\n");
|
||||
CloseHandle(file);
|
||||
val = p_File_size(test_f2_W);
|
||||
ok(val == 0, "file_size is %s\n", wine_dbgstr_longlong(val));
|
||||
|
||||
val = p_File_size(test_dir_W);
|
||||
ok(val == 0, "file_size is %s\n", wine_dbgstr_longlong(val));
|
||||
|
||||
errno = 0xdeadbeef;
|
||||
val = p_File_size(test_ne_W);
|
||||
ok(val == ~(ULONGLONG)0, "file_size is %s\n", wine_dbgstr_longlong(val));
|
||||
ok(errno == 0xdeadbeef, "errno = %d\n", errno);
|
||||
|
||||
errno = 0xdeadbeef;
|
||||
val = p_File_size(NULL);
|
||||
ok(val == ~(ULONGLONG)0, "file_size is %s\n", wine_dbgstr_longlong(val));
|
||||
ok(errno == 0xdeadbeef, "errno = %d\n", errno);
|
||||
|
||||
ok(DeleteFileW(test_f1_W), "expect wine_test_dir/f1 to exist\n");
|
||||
ok(DeleteFileW(test_f2_W), "expect wine_test_dir/f2 to exist\n");
|
||||
ok(RemoveDirectoryW(test_dir_W), "expect wine_test_dir to exist\n");
|
||||
ok(SetCurrentDirectoryW(origin_path), "SetCurrentDirectoryW to origin_path failed\n");
|
||||
}
|
||||
|
||||
START_TEST(msvcp140)
|
||||
{
|
||||
if(!init()) return;
|
||||
|
@ -574,5 +629,6 @@ START_TEST(msvcp140)
|
|||
test_chore();
|
||||
test_to_byte();
|
||||
test_to_wide();
|
||||
test_File_size();
|
||||
FreeLibrary(msvcp);
|
||||
}
|
||||
|
|
|
@ -15471,6 +15471,18 @@ ULONGLONG __cdecl tr2_sys__File_size_wchar(WCHAR const* path)
|
|||
return ((ULONGLONG)(fad.nFileSizeHigh) << 32) + fad.nFileSizeLow;
|
||||
}
|
||||
|
||||
/* _File_size, msvcp140 version. Different error handling. */
|
||||
ULONGLONG __cdecl _File_size(WCHAR const* path)
|
||||
{
|
||||
WIN32_FILE_ATTRIBUTE_DATA fad;
|
||||
|
||||
TRACE("(%s)\n", debugstr_w(path));
|
||||
if(!GetFileAttributesExW(path, GetFileExInfoStandard, &fad))
|
||||
return ~(ULONGLONG)0;
|
||||
|
||||
return ((ULONGLONG)(fad.nFileSizeHigh) << 32) + fad.nFileSizeLow;
|
||||
}
|
||||
|
||||
/* ?_Equivalent@sys@tr2@std@@YAHPB_W0@Z */
|
||||
/* ?_Equivalent@sys@tr2@std@@YAHPEB_W0@Z */
|
||||
int __cdecl tr2_sys__Equivalent_wchar(WCHAR const* path1, WCHAR const* path2)
|
||||
|
|
Loading…
Reference in New Issue