msvcp120: Tr2::_Rename_wchar NULL ptr handling differs from tr2::_Rename.
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
17c203ea86
commit
84b2d69a76
|
@ -1474,9 +1474,8 @@ static void test_tr2_sys__Rename(void)
|
|||
BY_HANDLE_FILE_INFORMATION info1, info2;
|
||||
char temp_path[MAX_PATH], current_path[MAX_PATH];
|
||||
LARGE_INTEGER file_size;
|
||||
WCHAR testW[] = {'t','r','2','_','t','e','s','t','_','d','i','r','/','f','1',0};
|
||||
WCHAR testW2[] = {'t','r','2','_','t','e','s','t','_','d','i','r','/','f','w',0};
|
||||
struct {
|
||||
static const WCHAR testW[] = {'t','r','2','_','t','e','s','t','_','d','i','r','/','f','1',0};
|
||||
static const struct {
|
||||
char const *old_path;
|
||||
char const *new_path;
|
||||
int val;
|
||||
|
@ -1488,6 +1487,29 @@ static void test_tr2_sys__Rename(void)
|
|||
{ "tr2_test_dir\\f1_rename", "tr2_test_dir\\??invalid_name>>", ERROR_INVALID_NAME },
|
||||
{ "tr2_test_dir\\not_exist_file", "tr2_test_dir\\not_exist_rename", ERROR_FILE_NOT_FOUND }
|
||||
};
|
||||
static const WCHAR f1_renameW[] =
|
||||
{'t','r','2','_','t','e','s','t','_','d','i','r','\\','f','1','_','r','e','n','a','m','e',0};
|
||||
static const WCHAR f1_rename2W[] =
|
||||
{'t','r','2','_','t','e','s','t','_','d','i','r','\\','f','1','_','r','e','n','a','m','e','2',0};
|
||||
static const WCHAR not_existW[] =
|
||||
{'t','r','2','_','t','e','s','t','_','d','i','r','\\','n','o','t','_','e','x','i','s','t',0};
|
||||
static const WCHAR not_exist2W[] =
|
||||
{'t','r','2','_','t','e','s','t','_','d','i','r','\\','n','o','t','_','e','x','i','s','t','2',0};
|
||||
static const WCHAR invalidW[] =
|
||||
{'t','r','2','_','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;
|
||||
} testsW[] = {
|
||||
{ testW, f1_renameW, ERROR_SUCCESS },
|
||||
{ testW, NULL, ERROR_FILE_NOT_FOUND }, /* Differs from the A version */
|
||||
{ testW, f1_renameW, ERROR_FILE_NOT_FOUND },
|
||||
{ NULL, f1_rename2W, ERROR_PATH_NOT_FOUND }, /* Differs from the A version */
|
||||
{ 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);
|
||||
GetCurrentDirectoryA(MAX_PATH, current_path);
|
||||
|
@ -1538,10 +1560,34 @@ static void test_tr2_sys__Rename(void)
|
|||
ok(ret == ERROR_ALREADY_EXISTS, "test_tr2_sys__Rename(): expect: ERROR_ALREADY_EXISTS, got %d\n", ret);
|
||||
ok(p_tr2_sys__File_size("tr2_test_dir\\f1") == 7, "test_tr2_sys__Rename(): expect: 7, got %s\n", wine_dbgstr_longlong(p_tr2_sys__File_size("tr2_test_dir\\f1")));
|
||||
ok(p_tr2_sys__File_size("tr2_test_dir\\f1_rename") == 0, "test_tr2_sys__Rename(): expect: 0, got %s\n",wine_dbgstr_longlong(p_tr2_sys__File_size("tr2_test_dir\\f1_rename")));
|
||||
ret = p_tr2_sys__Rename_wchar(testW, testW2);
|
||||
ok(ret == ERROR_SUCCESS, "tr2_sys__Rename_wchar(): expect: ERROR_SUCCESS, got %d\n", ret);
|
||||
|
||||
ok(DeleteFileW(testW2), "expect fw to exist\n");
|
||||
ok(DeleteFileA("tr2_test_dir\\f1_rename"), "expect f1_rename to exist\n");
|
||||
|
||||
for(i=0; i<ARRAY_SIZE(testsW); i++) {
|
||||
errno = 0xdeadbeef;
|
||||
if(testsW[i].val == ERROR_SUCCESS) {
|
||||
h1 = CreateFileW(testsW[i].old_path, 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, OPEN_EXISTING, 0, 0);
|
||||
ok(h1 != INVALID_HANDLE_VALUE, "create file failed: INVALID_HANDLE_VALUE\n");
|
||||
ok(GetFileInformationByHandle(h1, &info1), "GetFileInformationByHandle failed\n");
|
||||
CloseHandle(h1);
|
||||
}
|
||||
SetLastError(0xdeadbeef);
|
||||
ret = p_tr2_sys__Rename_wchar(testsW[i].old_path, testsW[i].new_path);
|
||||
ok(ret == testsW[i].val, "test_tr2_sys__Rename_wchar(): test %d expect: %d, got %d\n", i+1, testsW[i].val, ret);
|
||||
ok(errno == 0xdeadbeef, "test_tr2_sys__Rename_wchar(): test %d errno expect 0xdeadbeef, got %d\n", i+1, errno);
|
||||
if(ret == ERROR_SUCCESS) {
|
||||
h2 = CreateFileW(testsW[i].new_path, 0, FILE_SHARE_DELETE | FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
NULL, OPEN_EXISTING, 0, 0);
|
||||
ok(h2 != INVALID_HANDLE_VALUE, "create file failed: INVALID_HANDLE_VALUE\n");
|
||||
ok(GetFileInformationByHandle(h2, &info2), "GetFileInformationByHandle failed\n");
|
||||
CloseHandle(h2);
|
||||
ok(info1.nFileIndexHigh == info2.nFileIndexHigh
|
||||
&& info1.nFileIndexLow == info2.nFileIndexLow,
|
||||
"test_tr2_sys__Rename_wchar(): test %d expect two files equivalent\n", i+1);
|
||||
}
|
||||
}
|
||||
|
||||
ok(DeleteFileA("tr2_test_dir\\f1_rename"), "expect f1_rename to exist\n");
|
||||
ret = p_tr2_sys__Remove_dir("tr2_test_dir");
|
||||
ok(ret == 1, "test_tr2_sys__Remove_dir(): expect %d got %d\n", 1, ret);
|
||||
|
|
|
@ -15630,9 +15630,6 @@ int __cdecl tr2_sys__Rename_wchar(WCHAR const* old_path, WCHAR const* new_path)
|
|||
{
|
||||
TRACE("(%s %s)\n", debugstr_w(old_path), debugstr_w(new_path));
|
||||
|
||||
if(!old_path || !new_path)
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
if(MoveFileExW(old_path, new_path, MOVEFILE_COPY_ALLOWED))
|
||||
return ERROR_SUCCESS;
|
||||
return GetLastError();
|
||||
|
|
Loading…
Reference in New Issue