msvcp140: Add _Resize implementation.
Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Piotr Caban <piotr@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
88d2576ae7
commit
e8f083bd37
|
@ -3695,7 +3695,7 @@
|
|||
@ cdecl _Read_dir(ptr ptr ptr) tr2_sys__Read_dir_wchar
|
||||
@ cdecl _Remove_dir(wstr) tr2_sys__Remove_dir_wchar
|
||||
@ cdecl _Rename(wstr wstr) tr2_sys__Rename_wchar
|
||||
@ stub _Resize
|
||||
@ cdecl _Resize(wstr int64)
|
||||
@ cdecl _Set_last_write_time(wstr int64)
|
||||
@ stub _Sinh
|
||||
@ extern _Snan _Snan
|
||||
|
|
|
@ -178,6 +178,7 @@ static MSVCP_bool (__cdecl *p_Current_get)(WCHAR *);
|
|||
static MSVCP_bool (__cdecl *p_Current_set)(WCHAR const *);
|
||||
static int (__cdecl *p_Equivalent)(WCHAR const*, WCHAR const*);
|
||||
static ULONGLONG (__cdecl *p_File_size)(WCHAR const *);
|
||||
static int (__cdecl *p_Resize)(const WCHAR *, UINT64);
|
||||
static __int64 (__cdecl *p_Last_write_time)(WCHAR const*);
|
||||
static void (__cdecl *p_Set_last_write_time)(WCHAR const*, __int64);
|
||||
static int (__cdecl *p_Link)(WCHAR const*, WCHAR const*);
|
||||
|
@ -270,6 +271,7 @@ static BOOL init(void)
|
|||
SET(p_Current_set, "_Current_set");
|
||||
SET(p_Equivalent, "_Equivalent");
|
||||
SET(p_File_size, "_File_size");
|
||||
SET(p_Resize, "_Resize");
|
||||
SET(p_Last_write_time, "_Last_write_time");
|
||||
SET(p_Set_last_write_time, "_Set_last_write_time");
|
||||
SET(p_Link, "_Link");
|
||||
|
@ -657,6 +659,7 @@ static void test_File_size(void)
|
|||
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];
|
||||
int r;
|
||||
|
||||
GetCurrentDirectoryW(MAX_PATH, origin_path);
|
||||
GetTempPathW(MAX_PATH, temp_path);
|
||||
|
@ -692,7 +695,26 @@ static void test_File_size(void)
|
|||
ok(val == ~(ULONGLONG)0, "file_size is %s\n", wine_dbgstr_longlong(val));
|
||||
ok(errno == 0xdeadbeef, "errno = %d\n", errno);
|
||||
|
||||
r = p_Resize(test_f1_W, 1000);
|
||||
ok(!r, "p_Resize returned %d\n", r);
|
||||
val = p_File_size(test_f1_W);
|
||||
ok(val == 1000, "file_size is %s\n", wine_dbgstr_longlong(val));
|
||||
|
||||
r = p_Resize(test_f1_W, 100);
|
||||
ok(!r, "p_Resize returned %d\n", r);
|
||||
val = p_File_size(test_f1_W);
|
||||
ok(val == 100, "file_size is %s\n", wine_dbgstr_longlong(val));
|
||||
|
||||
r = p_Resize(test_f1_W, 0);
|
||||
ok(!r, "p_Resize returned %d\n", r);
|
||||
val = p_File_size(test_f1_W);
|
||||
ok(val == 0, "file_size is %s\n", wine_dbgstr_longlong(val));
|
||||
|
||||
ok(DeleteFileW(test_f1_W), "expect wine_test_dir/f1 to exist\n");
|
||||
|
||||
r = p_Resize(test_f1_W, 0);
|
||||
ok(r == ERROR_FILE_NOT_FOUND, "p_Resize returned %d\n", r);
|
||||
|
||||
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");
|
||||
|
|
|
@ -15593,6 +15593,26 @@ ULONGLONG __cdecl _File_size(WCHAR const* path)
|
|||
return ((ULONGLONG)(fad.nFileSizeHigh) << 32) + fad.nFileSizeLow;
|
||||
}
|
||||
|
||||
int __cdecl _Resize(const WCHAR *path, UINT64 size)
|
||||
{
|
||||
LARGE_INTEGER offset;
|
||||
HANDLE file;
|
||||
BOOL ret;
|
||||
|
||||
TRACE("(%s %s)\n", debugstr_w(path), wine_dbgstr_longlong(size));
|
||||
|
||||
file = CreateFileW(path, FILE_GENERIC_WRITE, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, OPEN_EXISTING, 0, 0);
|
||||
if(file == INVALID_HANDLE_VALUE)
|
||||
return GetLastError();
|
||||
|
||||
offset.QuadPart = size;
|
||||
if((ret = SetFilePointerEx(file, offset, NULL, FILE_BEGIN)))
|
||||
ret = SetEndOfFile(file);
|
||||
CloseHandle(file);
|
||||
return ret ? 0 : GetLastError();
|
||||
}
|
||||
|
||||
/* ?_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