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

Alexandre Julliard julliard at winehq.org
Mon Feb 8 11:06:06 CST 2010


Module: wine
Branch: master
Commit: b609e25204f6fdb74b6ee67ce6f348e2dda7afee
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=b609e25204f6fdb74b6ee67ce6f348e2dda7afee

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Mon Feb  1 17:42:31 2010 -0600

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

---

 dlls/shell32/shlfileop.c       |   14 ++++++++++++++
 dlls/shell32/tests/shlfileop.c |   12 ++++++++++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/dlls/shell32/shlfileop.c b/dlls/shell32/shlfileop.c
index a768c15..0b08f52 100644
--- a/dlls/shell32/shlfileop.c
+++ b/dlls/shell32/shlfileop.c
@@ -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)
diff --git a/dlls/shell32/tests/shlfileop.c b/dlls/shell32/tests/shlfileop.c
index 3e9f9c7..49ef8cb 100644
--- a/dlls/shell32/tests/shlfileop.c
+++ b/dlls/shell32/tests/shlfileop.c
@@ -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 */




More information about the wine-cvs mailing list