From 7c3743c12f6b8a7fa015da3c231d1b0817978e4b Mon Sep 17 00:00:00 2001
From: Zhenbo Li <litimetal@gmail.com>
Date: Fri, 14 Aug 2015 21:18:43 +0800
Subject: shell32: Fix SHFileOperation(FO_MOVE) for creating subdirectories.

This patch fixes bug 25207.
---
 dlls/shell32/shlfileop.c       | 6 +++++-
 dlls/shell32/tests/shlfileop.c | 4 ++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/dlls/shell32/shlfileop.c b/dlls/shell32/shlfileop.c
index c843dd7..e7f8107 100644
--- a/dlls/shell32/shlfileop.c
+++ b/dlls/shell32/shlfileop.c
@@ -1427,7 +1427,11 @@ static int move_files(LPSHFILEOPSTRUCTW lpFileOp, const FILE_LIST *flFrom, const
     }
 
     if (!PathFileExistsW(flTo->feFiles[0].szDirectory))
-        return ERROR_CANCELLED;
+    {
+        int ret = SHCreateDirectoryExW(NULL, flTo->feFiles[0].szDirectory, NULL);
+        if (ret)
+            return ret;
+    }
 
     if (lpFileOp->fFlags & FOF_MULTIDESTFILES)
         mismatched = flFrom->dwNumFiles - flTo->dwNumFiles;
diff --git a/dlls/shell32/tests/shlfileop.c b/dlls/shell32/tests/shlfileop.c
index d33ad5b..108d65e 100644
--- a/dlls/shell32/tests/shlfileop.c
+++ b/dlls/shell32/tests/shlfileop.c
@@ -2205,13 +2205,13 @@ static void test_move(void)
         ok(!DeleteFileA("d.txt"), "Expected d.txt to not exist\n");
     }
 
-    /* FO_MOVE does not create dest directories */
+    /* FO_MOVE should create dest directories */
     shfo.pFrom = "test2.txt\0";
     shfo.pTo = "dir1\\dir2\\test2.txt\0";
     retval = SHFileOperationA(&shfo);
     if (dir_exists("dir1"))
     {
-        /* Vista and W2K8 (broken or new behavior ?) */
+        /* New behavior on Vista or later */
         ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
         ok(DeleteFileA("dir1\\dir2\\test2.txt"), "Expected dir1\\dir2\\test2.txt to exist\n");
         RemoveDirectoryA("dir1\\dir2");
-- 
2.5.0

