[SHELL32]
[reactos.git] / reactos / dll / win32 / shell32 / shlfileop.c
index b8e0568..e3bdf6e 100644 (file)
@@ -1087,6 +1087,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)
@@ -1097,6 +1111,14 @@ static HRESULT copy_files(FILE_OPERATION *op, const FILE_LIST *flFrom, FILE_LIST
             if (flFrom->dwNumFiles != 1 && !IsAttribDir(fileDest->attributes))
                 return ERROR_CANCELLED;
 
+            /* Free all but the first entry. */
+            for (i = 1; i < flTo->dwNumFiles; i++)
+            {
+                HeapFree(GetProcessHeap(), 0, flTo->feFiles[i].szDirectory);
+                HeapFree(GetProcessHeap(), 0, flTo->feFiles[i].szFilename);
+                HeapFree(GetProcessHeap(), 0, flTo->feFiles[i].szFullPath);
+            }
+
             flTo->dwNumFiles = 1;
         }
         else if (IsAttribDir(fileDest->attributes))