diff --git a/dlls/msvcp140/msvcp140.spec b/dlls/msvcp140/msvcp140.spec index 57d02776c3c..f999e9aceff 100644 --- a/dlls/msvcp140/msvcp140.spec +++ b/dlls/msvcp140/msvcp140.spec @@ -3694,7 +3694,7 @@ @ cdecl -ret64 _Query_perf_frequency() @ cdecl _Read_dir(ptr ptr ptr) tr2_sys__Read_dir_wchar @ cdecl _Remove_dir(wstr) tr2_sys__Remove_dir_wchar -@ stub _Rename +@ cdecl _Rename(wstr wstr) tr2_sys__Rename_wchar @ stub _Resize @ stub _Set_last_write_time @ stub _Sinh diff --git a/dlls/msvcp140/tests/msvcp140.c b/dlls/msvcp140/tests/msvcp140.c index fdec4298dbd..aefec6be4f7 100644 --- a/dlls/msvcp140/tests/msvcp140.c +++ b/dlls/msvcp140/tests/msvcp140.c @@ -176,6 +176,7 @@ static int (__cdecl *p_Make_dir)(WCHAR const*); static void* (__cdecl *p_Open_dir)(WCHAR*, WCHAR const*, int *, enum file_type*); static WCHAR* (__cdecl *p_Read_dir)(WCHAR*, void*, enum file_type*); static MSVCP_bool (__cdecl *p_Remove_dir)(WCHAR const*); +static int (__cdecl *p_Rename)(WCHAR const*, WCHAR const*); static enum file_type (__cdecl *p_Stat)(WCHAR const *, int *); static int (__cdecl *p_Symlink)(WCHAR const*, WCHAR const*); static WCHAR* (__cdecl *p_Temp_get)(WCHAR *); @@ -259,6 +260,7 @@ static BOOL init(void) SET(p_Open_dir, "_Open_dir"); SET(p_Read_dir, "_Read_dir"); SET(p_Remove_dir, "_Remove_dir"); + SET(p_Rename, "_Rename"); SET(p_Stat, "_Stat"); SET(p_Symlink, "_Symlink"); SET(p_Temp_get, "_Temp_get"); @@ -1085,6 +1087,100 @@ static void test_Temp_get(void) todo_wine ok(path[len + 1] == 0xaaaa, "Too many bytes were zeroed - %x\n", path[len + 1]); } +static void test_Rename(void) +{ + int ret, i; + HANDLE file, h1, h2; + BY_HANDLE_FILE_INFORMATION info1, info2; + WCHAR temp_path[MAX_PATH], current_path[MAX_PATH]; + LARGE_INTEGER file_size; + static const WCHAR wine_test_dirW[] = + {'w','i','n','e','_','t','e','s','t','_','d','i','r',0}; + static const WCHAR f1W[] = + {'w','i','n','e','_','t','e','s','t','_','d','i','r','\\','f','1',0}; + static const WCHAR f1_renameW[] = + {'w','i','n','e','_','t','e','s','t','_','d','i','r','\\','f','1','_','r','e','n','a','m','e',0}; + static const WCHAR f1_rename2W[] = + {'w','i','n','e','_','t','e','s','t','_','d','i','r','\\','f','1','_','r','e','n','a','m','e','2',0}; + static const WCHAR not_existW[] = + {'w','i','n','e','_','t','e','s','t','_','d','i','r','\\','n','o','t','_','e','x','i','s','t',0}; + static const WCHAR not_exist2W[] = + {'w','i','n','e','_','t','e','s','t','_','d','i','r','\\','n','o','t','_','e','x','i','s','t','2',0}; + static const WCHAR invalidW[] = + {'w','i','n','e','_','t','e','s','t','_','d','i','r','\\','?','?','i','n','v','a','l','i','d','>',0}; + static const struct { + const WCHAR *old_path; + const WCHAR *new_path; + int val; + } tests[] = { + { f1W, f1_renameW, ERROR_SUCCESS }, + { f1W, NULL, ERROR_FILE_NOT_FOUND }, + { f1W, f1_renameW, ERROR_FILE_NOT_FOUND }, + { NULL, f1_rename2W, ERROR_PATH_NOT_FOUND }, + { f1_renameW, invalidW, ERROR_INVALID_NAME }, + { not_existW, not_exist2W, ERROR_FILE_NOT_FOUND }, + { not_existW, invalidW, ERROR_FILE_NOT_FOUND } + }; + + memset(current_path, 0, MAX_PATH); + GetCurrentDirectoryW(MAX_PATH, current_path); + memset(temp_path, 0, MAX_PATH); + GetTempPathW(MAX_PATH, temp_path); + ok(SetCurrentDirectoryW(temp_path), "SetCurrentDirectoryW to temp_path failed\n"); + ret = p_Make_dir(wine_test_dirW); + + ok(ret == 1, "_Make_dir(): expect 1 got %d\n", ret); + file = CreateFileW(f1W, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL); + ok(file != INVALID_HANDLE_VALUE, "create file failed: INVALID_HANDLE_VALUE\n"); + CloseHandle(file); + + ret = p_Rename(f1W, f1W); + todo_wine ok(ERROR_SUCCESS == ret, "_Rename(): expect: ERROR_SUCCESS, got %d\n", ret); + for(i=0; i