Module: wine Branch: master Commit: e8f083bd37becffdc8d41cb76e7189d194bf48d9 URL: https://source.winehq.org/git/wine.git/?a=commit;h=e8f083bd37becffdc8d41cb76...
Author: Jacek Caban jacek@codeweavers.com Date: Mon Apr 22 14:13:21 2019 +0200
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
---
dlls/msvcp140/msvcp140.spec | 2 +- dlls/msvcp140/tests/msvcp140.c | 22 ++++++++++++++++++++++ dlls/msvcp90/ios.c | 20 ++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-)
diff --git a/dlls/msvcp140/msvcp140.spec b/dlls/msvcp140/msvcp140.spec index 5bd627c..8d2f43b 100644 --- a/dlls/msvcp140/msvcp140.spec +++ b/dlls/msvcp140/msvcp140.spec @@ -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 diff --git a/dlls/msvcp140/tests/msvcp140.c b/dlls/msvcp140/tests/msvcp140.c index 2f9cb6b..0440624 100644 --- a/dlls/msvcp140/tests/msvcp140.c +++ b/dlls/msvcp140/tests/msvcp140.c @@ -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"); diff --git a/dlls/msvcp90/ios.c b/dlls/msvcp90/ios.c index 6b94737..94d43cb 100644 --- a/dlls/msvcp90/ios.c +++ b/dlls/msvcp90/ios.c @@ -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)