Module: wine Branch: master Commit: da8a801a582a32b6577c3ac8a58d713c058fdc9e URL: https://source.winehq.org/git/wine.git/?a=commit;h=da8a801a582a32b6577c3ac8a... Author: Daniel Lehman <dlehman25(a)gmail.com> Date: Tue May 8 20:50:20 2018 -0700 shell32: Convert / to \ when parsing file list. Signed-off-by: Daniel Lehman <dlehman25(a)gmail.com> Signed-off-by: Alexandre Julliard <julliard(a)winehq.org> --- dlls/shell32/shlfileop.c | 3 +++ dlls/shell32/tests/shlfileop.c | 46 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/dlls/shell32/shlfileop.c b/dlls/shell32/shlfileop.c index 5d93334..4507b72 100644 --- a/dlls/shell32/shlfileop.c +++ b/dlls/shell32/shlfileop.c @@ -1005,6 +1005,7 @@ static HRESULT parse_file_list(FILE_LIST *flList, LPCWSTR szFiles) { LPCWSTR ptr = szFiles; WCHAR szCurFile[MAX_PATH]; + WCHAR *p; DWORD i = 0; if (!szFiles) @@ -1039,6 +1040,8 @@ static HRESULT parse_file_list(FILE_LIST *flList, LPCWSTR szFiles) flList->feFiles[i].bFromRelative = FALSE; } + for (p = szCurFile; *p; p++) if (*p == '/') *p = '\\'; + /* parse wildcard files if they are in the filename */ if (StrPBrkW(szCurFile, wWildcardChars)) { diff --git a/dlls/shell32/tests/shlfileop.c b/dlls/shell32/tests/shlfileop.c index 6a220fa..8fb4dcf 100644 --- a/dlls/shell32/tests/shlfileop.c +++ b/dlls/shell32/tests/shlfileop.c @@ -1869,6 +1869,28 @@ static void test_copy(void) ok(retval != ERROR_SUCCESS, "Unexpected ERROR_SUCCESS\n"); ok(!shfo.fAnyOperationsAborted, "Didn't expect aborted operations\n"); ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError()); + + /* test with / */ + CreateDirectoryA("dir", NULL); + CreateDirectoryA("dir\\subdir", NULL); + createTestFile("dir\\subdir\\aa.txt"); + shfo.pFrom = "dir/subdir/aa.txt\0"; + shfo.pTo = "dir\\destdir/aa.txt\0"; + shfo.fFlags = FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_SILENT | FOF_NOERRORUI; + retval = SHFileOperationA(&shfo); + if (dir_exists("dir\\destdir")) + { + ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval); + ok(DeleteFileA("dir\\destdir\\aa.txt"), "Expected file to exist\n"); + ok(RemoveDirectoryA("dir\\destdir"), "Expected dir to exist\n"); + } + else + { + expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* WinXp, Win2k */); + } + ok(DeleteFileA("dir\\subdir\\aa.txt"), "Expected file to exist\n"); + ok(RemoveDirectoryA("dir\\subdir"), "Expected dir to exist\n"); + ok(RemoveDirectoryA("dir"), "Expected dir to exist\n"); } /* tests the FO_MOVE action */ @@ -1921,6 +1943,30 @@ static void test_move(void) clean_after_shfo_tests(); init_shfo_tests(); + /* same tests above, but with / */ + set_curr_dir_path(from, "testdir2/*.*\0"); + set_curr_dir_path(to, "test4.txt\0"); + retval = SHFileOperationA(&shfo); + ok(retval == ERROR_SUCCESS || + broken(retval == ERROR_FILE_NOT_FOUND), /* WinXp, Win2k3 */ + "Expected ERROR_SUCCESS, got %d\n", retval); + if (retval == ERROR_SUCCESS) + { + ok(!shfo.fAnyOperationsAborted, "fAnyOperationsAborted %d\n", shfo.fAnyOperationsAborted); + + ok(dir_exists("testdir2"), "dir should not be moved\n"); + ok(!file_exists("testdir2\\one.txt"), "file should be moved\n"); + ok(!dir_exists("testdir2\\nested"), "dir should be moved\n"); + ok(!file_exists("testdir2\\nested\\two.txt"), "file should be moved\n"); + + ok(file_exists("test4.txt\\one.txt"), "file should exist\n"); + ok(dir_exists("test4.txt\\nested"), "dir should exist\n"); + ok(file_exists("test4.txt\\nested\\two.txt"), "file should exist\n"); + } + + clean_after_shfo_tests(); + init_shfo_tests(); + shfo.hwnd = NULL; shfo.wFunc = FO_MOVE; shfo.pFrom = from;