Skip to content
Snippets Groups Projects
Commit c4bba67a authored by Rolf Kalbermatter's avatar Rolf Kalbermatter Committed by Alexandre Julliard
Browse files

Fix a return value in SHFileOperation and add some extra tests to

internal helper functions necessary to deal with shortcomings of
kernel32 functions for the time being.
parent 2999165c
No related merge requests found
...@@ -258,7 +258,11 @@ static DWORD SHNotifyCreateDirectoryW(LPCWSTR path, LPSECURITY_ATTRIBUTES sec) ...@@ -258,7 +258,11 @@ static DWORD SHNotifyCreateDirectoryW(LPCWSTR path, LPSECURITY_ATTRIBUTES sec)
implementation does create directories with wildcard characters implementation does create directories with wildcard characters
without objection!! Once this is fixed, this here can go away. */ without objection!! Once this is fixed, this here can go away. */
SetLastError(ERROR_INVALID_NAME); SetLastError(ERROR_INVALID_NAME);
#ifdef W98_FO_FUNCTION /* W98 */
return ERROR_FILE_NOT_FOUND;
#else
return ERROR_INVALID_NAME; return ERROR_INVALID_NAME;
#endif
} }
if (CreateDirectoryW(path, sec)) if (CreateDirectoryW(path, sec))
...@@ -413,6 +417,19 @@ static DWORD SHNotifyMoveFileW(LPCWSTR src, LPCWSTR dest, BOOL bRename) ...@@ -413,6 +417,19 @@ static DWORD SHNotifyMoveFileW(LPCWSTR src, LPCWSTR dest, BOOL bRename)
TRACE("(%s %s %s)\n", debugstr_w(src), debugstr_w(dest), bRename ? "renameIfExists" : ""); TRACE("(%s %s %s)\n", debugstr_w(src), debugstr_w(dest), bRename ? "renameIfExists" : "");
if (StrPBrkW(dest, wWildcardChars))
{
/* FIXME: This test is currently necessary since our MoveFile
implementation does create files with wildcard characters
without objection!! Once this is fixed, this here can go away. */
SetLastError(ERROR_INVALID_NAME);
#ifdef W98_FO_FUNCTION /* W98 */
return ERROR_FILE_NOT_FOUND;
#else
return ERROR_INVALID_NAME;
#endif
}
ret = MoveFileW(src, dest); ret = MoveFileW(src, dest);
if (!ret) if (!ret)
{ {
...@@ -946,16 +963,11 @@ DWORD WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp) ...@@ -946,16 +963,11 @@ DWORD WINAPI SHFileOperationW(LPSHFILEOPSTRUCTW lpFileOp)
if (FO_RENAME == FuncSwitch) if (FO_RENAME == FuncSwitch)
{ {
/* temporary only for FO_RENAME */ /* temporary only for FO_RENAME */
/* ??? b_Mask = (NULL != strrbrk(pFrom,"*?")); */
if (b_MultiTo || b_MultiFrom || (b_Mask && !b_ToInvalidTail)) if (b_MultiTo || b_MultiFrom || (b_Mask && !b_ToInvalidTail))
{ {
/* no work, only RC=0 */ #ifndef W98_FO_FUNCTION
/* ??? nFileOp.fAnyOperationsAborted = TRUE; */ retCode = ERROR_GEN_FAILURE; /* W2K ERROR_GEN_FAILURE, W98 returns no error */
/*#define W98_FO_RENEME */
#ifdef W98_FO_RENEME
goto shfileop_normal;
#endif #endif
retCode = 0x1; /* 1 value unknown, W98 returns no error */
goto shfileop_error; goto shfileop_error;
} }
} }
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
#define WINE_NOWINSOCK
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "wtypes.h" #include "wtypes.h"
...@@ -153,6 +154,7 @@ void test_rename() ...@@ -153,6 +154,7 @@ void test_rename()
SHFILEOPSTRUCTA shfo, shfo2; SHFILEOPSTRUCTA shfo, shfo2;
CHAR from[MAX_PATH]; CHAR from[MAX_PATH];
CHAR to[MAX_PATH]; CHAR to[MAX_PATH];
DWORD retval;
shfo.hwnd = NULL; shfo.hwnd = NULL;
shfo.wFunc = FO_RENAME; shfo.wFunc = FO_RENAME;
...@@ -175,7 +177,8 @@ void test_rename() ...@@ -175,7 +177,8 @@ void test_rename()
set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0"); set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0"); set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
ok(SHFileOperationA(&shfo), "Can't rename many files"); retval = SHFileOperationA(&shfo); /* W98 returns 0, W2K and newer returns ERROR_GEN_FAILURE, both do nothing */
ok(!retval || retval == ERROR_GEN_FAILURE, "Can't rename many files, retval = %lx", retval);
ok(file_exists(".\\test1.txt"), "The file is not renamed - many files are specified "); ok(file_exists(".\\test1.txt"), "The file is not renamed - many files are specified ");
memcpy(&shfo2, &shfo, sizeof(SHFILEOPSTRUCTA)); memcpy(&shfo2, &shfo, sizeof(SHFILEOPSTRUCTA));
...@@ -183,14 +186,15 @@ void test_rename() ...@@ -183,14 +186,15 @@ void test_rename()
set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0"); set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0"); set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
ok(SHFileOperationA(&shfo2), "Can't rename many files"); retval = SHFileOperationA(&shfo2); /* W98 returns 0, W2K and newer returns ERROR_GEN_FAILURE, both do nothing */
ok(!retval || retval == ERROR_GEN_FAILURE, "Can't rename many files, retval = %lx", retval);
ok(file_exists(".\\test1.txt"), "The file is not renamed - many files are specified "); ok(file_exists(".\\test1.txt"), "The file is not renamed - many files are specified ");
set_curr_dir_path(from, "test1.txt\0"); set_curr_dir_path(from, "test1.txt\0");
set_curr_dir_path(to, "test6.txt\0"); set_curr_dir_path(to, "test6.txt\0");
ok(!SHFileOperationA(&shfo), "Rename file"); ok(!SHFileOperationA(&shfo), "Rename file");
ok(!file_exists(".\\test1.txt"), "The file is renamed"); ok(!file_exists(".\\test1.txt"), "The file is renamed");
ok(file_exists(".\\test6.txt"), "The file is renamed "); ok(file_exists(".\\test6.txt"), "The file is renamed");
set_curr_dir_path(from, "test6.txt\0"); set_curr_dir_path(from, "test6.txt\0");
set_curr_dir_path(to, "test1.txt\0"); set_curr_dir_path(to, "test1.txt\0");
ok(!SHFileOperationA(&shfo), "Rename file back"); ok(!SHFileOperationA(&shfo), "Rename file back");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment