Commit b609e252 authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

shell32: Use the current directory when copying to an empty destination.

parent 71e4af50
......@@ -1182,6 +1182,20 @@ static HRESULT copy_files(FILE_OPERATION *op, const FILE_LIST *flFrom, FILE_LIST
if (flFrom->bAnyDontExist)
return ERROR_SHELL_INTERNAL_FILE_NOT_FOUND;
if (flTo->dwNumFiles == 0)
{
/* If the destination is empty, SHFileOperation should use the current directory */
WCHAR curdir[MAX_PATH+1];
GetCurrentDirectoryW(MAX_PATH, curdir);
curdir[lstrlenW(curdir)+1] = 0;
destroy_file_list(flTo);
ZeroMemory(flTo, sizeof(FILE_LIST));
parse_file_list(flTo, curdir);
fileDest = &flTo->feFiles[0];
}
if (op->req->fFlags & FOF_MULTIDESTFILES)
{
if (flFrom->bAnyFromWildcard)
......
......@@ -1720,6 +1720,18 @@ static void test_copy(void)
ok(DeleteFileA("ab.txt"), "Expected file to exist\n");
ok(RemoveDirectoryA("one"), "Expected dir to exist\n");
ok(RemoveDirectoryA("two"), "Expected dir to exist\n");
/* pTo is an empty string */
CreateDirectoryA("dir", NULL);
createTestFile("dir\\abcdefgh.abc");
shfo.pFrom = "dir\\abcdefgh.abc\0";
shfo.pTo = "\0";
shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
retval = SHFileOperation(&shfo);
ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
ok(DeleteFileA("dir\\abcdefgh.abc"), "Expected file to exist\n");
ok(DeleteFileA("abcdefgh.abc"), "Expected file to exist\n");
ok(RemoveDirectoryA("dir"), "Expected dir to exist\n");
}
/* tests the FO_MOVE action */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment