2 * Unit test of the SHFileOperation function.
4 * Copyright 2002 Andriy Palamarchuk
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define WINE_NOWINSOCK
29 #include "wine/test.h"
31 #ifndef FOF_NORECURSION
32 #define FOF_NORECURSION 0x1000
35 static CHAR CURR_DIR[MAX_PATH];
36 static const WCHAR UNICODE_PATH[] = {'c',':','\\',0x00c4,'\0','\0'};
37 /* "c:\Ä", or "c:\A" with diaeresis */
38 /* Double-null termination needed for pFrom field of SHFILEOPSTRUCT */
40 static HMODULE hshell32;
41 static int (WINAPI *pSHCreateDirectoryExA)(HWND, LPCSTR, LPSECURITY_ATTRIBUTES);
42 static int (WINAPI *pSHCreateDirectoryExW)(HWND, LPCWSTR, LPSECURITY_ATTRIBUTES);
43 static int (WINAPI *pSHFileOperationW)(LPSHFILEOPSTRUCTW);
44 static int (WINAPI *pSHPathPrepareForWriteA)(HWND, IUnknown*, LPCSTR, DWORD);
45 static int (WINAPI *pSHPathPrepareForWriteW)(HWND, IUnknown*, LPCWSTR, DWORD);
47 static void InitFunctionPointers(void)
49 hshell32 = GetModuleHandleA("shell32.dll");
50 pSHCreateDirectoryExA = (void*)GetProcAddress(hshell32, "SHCreateDirectoryExA");
51 pSHCreateDirectoryExW = (void*)GetProcAddress(hshell32, "SHCreateDirectoryExW");
52 pSHFileOperationW = (void*)GetProcAddress(hshell32, "SHFileOperationW");
53 pSHPathPrepareForWriteA = (void*)GetProcAddress(hshell32, "SHPathPrepareForWriteA");
54 pSHPathPrepareForWriteW = (void*)GetProcAddress(hshell32, "SHPathPrepareForWriteW");
57 /* creates a file with the specified name for tests */
58 static void createTestFile(const CHAR *name)
63 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
64 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
65 WriteFile(file, name, strlen(name), &written, NULL);
66 WriteFile(file, "\n", strlen("\n"), &written, NULL);
70 static void createTestFileW(const WCHAR *name)
74 file = CreateFileW(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
75 ok(file != INVALID_HANDLE_VALUE, "Failure to open file\n");
79 static BOOL file_exists(const CHAR *name)
81 return GetFileAttributesA(name) != INVALID_FILE_ATTRIBUTES;
84 static BOOL file_existsW(LPCWSTR name)
86 return GetFileAttributesW(name) != INVALID_FILE_ATTRIBUTES;
89 static BOOL file_has_content(const CHAR *name, const CHAR *content)
95 file = CreateFileA(name, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
96 if (file == INVALID_HANDLE_VALUE)
98 ReadFile(file, buf, MAX_PATH - 1, &read, NULL);
101 return strcmp(buf, content)==0;
104 /* initializes the tests */
105 static void init_shfo_tests(void)
109 GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
110 len = lstrlenA(CURR_DIR);
112 if(len && (CURR_DIR[len-1] == '\\'))
115 createTestFile("test1.txt");
116 createTestFile("test2.txt");
117 createTestFile("test3.txt");
118 createTestFile("test_5.txt");
119 CreateDirectoryA("test4.txt", NULL);
120 CreateDirectoryA("testdir2", NULL);
121 CreateDirectoryA("testdir2\\nested", NULL);
122 createTestFile("testdir2\\one.txt");
123 createTestFile("testdir2\\nested\\two.txt");
126 /* cleans after tests */
127 static void clean_after_shfo_tests(void)
129 DeleteFileA("test1.txt");
130 DeleteFileA("test2.txt");
131 DeleteFileA("test3.txt");
132 DeleteFileA("test_5.txt");
133 DeleteFileA("one.txt");
134 DeleteFileA("test4.txt\\test1.txt");
135 DeleteFileA("test4.txt\\test2.txt");
136 DeleteFileA("test4.txt\\test3.txt");
137 RemoveDirectoryA("test4.txt");
138 DeleteFileA("testdir2\\one.txt");
139 DeleteFileA("testdir2\\test1.txt");
140 DeleteFileA("testdir2\\test2.txt");
141 DeleteFileA("testdir2\\test3.txt");
142 DeleteFileA("testdir2\\test4.txt\\test1.txt");
143 DeleteFileA("testdir2\\nested\\two.txt");
144 RemoveDirectoryA("testdir2\\test4.txt");
145 RemoveDirectoryA("testdir2\\nested");
146 RemoveDirectoryA("testdir2");
147 RemoveDirectoryA("c:\\testdir3");
148 DeleteFileA("nonexistent\\notreal\\test2.txt");
149 RemoveDirectoryA("nonexistent\\notreal");
150 RemoveDirectoryA("nonexistent");
154 static void test_get_file_info(void)
157 SHFILEINFO shfi, shfi2;
158 char notepad[MAX_PATH];
160 /* Test some flag combinations that MSDN claims are not allowed,
161 * but which work anyway
163 shfi.dwAttributes=0xdeadbeef;
164 rc=SHGetFileInfoA("c:\\nonexistent", FILE_ATTRIBUTE_DIRECTORY,
166 SHGFI_ATTRIBUTES | SHGFI_USEFILEATTRIBUTES);
167 todo_wine ok(rc, "SHGetFileInfoA(c:\\nonexistent | SHGFI_ATTRIBUTES) failed\n");
169 ok(shfi.dwAttributes != 0xdeadbeef, "dwFileAttributes is not set\n");
171 rc=SHGetFileInfoA("c:\\nonexistent", FILE_ATTRIBUTE_DIRECTORY,
173 SHGFI_EXETYPE | SHGFI_USEFILEATTRIBUTES);
174 todo_wine ok(rc == 1, "SHGetFileInfoA(c:\\nonexistent | SHGFI_EXETYPE) returned %d\n", rc);
176 /* Test SHGFI_USEFILEATTRIBUTES support */
177 strcpy(shfi.szDisplayName, "dummy");
178 shfi.iIcon=0xdeadbeef;
179 rc=SHGetFileInfoA("c:\\nonexistent", FILE_ATTRIBUTE_DIRECTORY,
181 SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
182 ok(rc, "SHGetFileInfoA(c:\\nonexistent) failed\n");
185 ok(strcpy(shfi.szDisplayName, "dummy") != 0, "SHGetFileInfoA(c:\\nonexistent) displayname is not set\n");
186 ok(shfi.iIcon != 0xdeadbeef, "SHGetFileInfoA(c:\\nonexistent) iIcon is not set\n");
189 /* Wine does not have a default icon for text files, and Windows 98 fails
190 * if we give it an empty executable. So use notepad.exe as the test
192 if (SearchPath(NULL, "notepad.exe", NULL, sizeof(notepad), notepad, NULL))
194 strcpy(shfi.szDisplayName, "dummy");
195 shfi.iIcon=0xdeadbeef;
196 rc=SHGetFileInfoA(notepad, GetFileAttributes(notepad),
198 SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
199 ok(rc, "SHGetFileInfoA(%s, SHGFI_USEFILEATTRIBUTES) failed\n", notepad);
200 strcpy(shfi2.szDisplayName, "dummy");
201 shfi2.iIcon=0xdeadbeef;
202 rc2=SHGetFileInfoA(notepad, 0,
203 &shfi2, sizeof(shfi2),
205 ok(rc2, "SHGetFileInfoA(%s) failed\n", notepad);
208 ok(lstrcmpi(shfi2.szDisplayName, shfi.szDisplayName) == 0, "wrong display name %s != %s\n", shfi.szDisplayName, shfi2.szDisplayName);
209 ok(shfi2.iIcon == shfi.iIcon, "wrong icon index %d != %d\n", shfi.iIcon, shfi2.iIcon);
213 /* with a directory now */
214 strcpy(shfi.szDisplayName, "dummy");
215 shfi.iIcon=0xdeadbeef;
216 rc=SHGetFileInfoA("test4.txt", GetFileAttributes("test4.txt"),
218 SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
219 ok(rc, "SHGetFileInfoA(test4.txt/, SHGFI_USEFILEATTRIBUTES) failed\n");
220 strcpy(shfi2.szDisplayName, "dummy");
221 shfi2.iIcon=0xdeadbeef;
222 rc2=SHGetFileInfoA("test4.txt", 0,
223 &shfi2, sizeof(shfi2),
225 ok(rc2, "SHGetFileInfoA(test4.txt/) failed\n");
228 ok(lstrcmpi(shfi2.szDisplayName, shfi.szDisplayName) == 0, "wrong display name %s != %s\n", shfi.szDisplayName, shfi2.szDisplayName);
229 ok(shfi2.iIcon == shfi.iIcon, "wrong icon index %d != %d\n", shfi.iIcon, shfi2.iIcon);
235 puts into the specified buffer file names with current directory.
236 files - string with file names, separated by null characters. Ends on a double
239 static void set_curr_dir_path(CHAR *buf, const CHAR* files)
244 strcpy(buf, CURR_DIR);
249 buf += strlen(buf) + 1;
250 files += strlen(files) + 1;
256 /* tests the FO_DELETE action */
257 static void test_delete(void)
259 SHFILEOPSTRUCTA shfo;
261 CHAR buf[sizeof(CURR_DIR)+sizeof("/test?.txt")+1];
263 sprintf(buf, "%s\\%s", CURR_DIR, "test?.txt");
264 buf[strlen(buf) + 1] = '\0';
267 shfo.wFunc = FO_DELETE;
270 shfo.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_SILENT;
271 shfo.hNameMappings = NULL;
272 shfo.lpszProgressTitle = NULL;
274 ok(!SHFileOperationA(&shfo), "Deletion was not successful\n");
275 ok(file_exists("test4.txt"), "Directory should not have been removed\n");
276 ok(!file_exists("test1.txt"), "File should have been removed\n");
278 ret = SHFileOperationA(&shfo);
279 ok(!ret, "Directory exists, but is not removed, ret=%d\n", ret);
280 ok(file_exists("test4.txt"), "Directory should not have been removed\n");
282 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
284 ok(!SHFileOperationA(&shfo), "Directory is not removed\n");
285 ok(!file_exists("test4.txt"), "Directory should have been removed\n");
287 ret = SHFileOperationA(&shfo);
288 ok(!ret, "The requested file does not exist, ret=%d\n", ret);
291 sprintf(buf, "%s\\%s", CURR_DIR, "test4.txt");
292 buf[strlen(buf) + 1] = '\0';
293 ok(MoveFileA("test1.txt", "test4.txt\\test1.txt"), "Filling the subdirectory failed\n");
294 ok(!SHFileOperationA(&shfo), "Directory is not removed\n");
295 ok(!file_exists("test4.txt"), "Directory is not removed\n");
298 shfo.pFrom = "test1.txt\0test4.txt\0";
299 ok(!SHFileOperationA(&shfo), "Directory and a file are not removed\n");
300 ok(!file_exists("test1.txt"), "The file should have been removed\n");
301 ok(!file_exists("test4.txt"), "Directory should have been removed\n");
302 ok(file_exists("test2.txt"), "This file should not have been removed\n");
304 /* FOF_FILESONLY does not delete a dir matching a wildcard */
306 shfo.fFlags |= FOF_FILESONLY;
307 shfo.pFrom = "*.txt\0";
308 ok(!SHFileOperation(&shfo), "Failed to delete files\n");
309 ok(!file_exists("test1.txt"), "test1.txt should have been removed\n");
310 ok(!file_exists("test_5.txt"), "test_5.txt should have been removed\n");
311 ok(file_exists("test4.txt"), "test4.txt should not have been removed\n");
313 /* FOF_FILESONLY only deletes a dir if explicitly specified */
315 shfo.pFrom = "test_?.txt\0test4.txt\0";
316 ok(!SHFileOperation(&shfo), "Failed to delete files and directory\n");
317 ok(!file_exists("test4.txt"), "test4.txt should have been removed\n");
318 ok(!file_exists("test_5.txt"), "test_5.txt should have been removed\n");
319 ok(file_exists("test1.txt"), "test1.txt should not have been removed\n");
321 /* try to delete an invalid filename */
324 shfo.fFlags &= ~FOF_FILESONLY;
325 shfo.fAnyOperationsAborted = FALSE;
326 ret = SHFileOperation(&shfo);
327 ok(ret == ERROR_ACCESS_DENIED, "Expected ERROR_ACCESS_DENIED, got %d\n", ret);
328 ok(!shfo.fAnyOperationsAborted, "Expected no aborted operations\n");
329 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
331 /* try an invalid function */
333 shfo.pFrom = "test1.txt\0";
335 ret = SHFileOperation(&shfo);
336 ok(ret == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret);
337 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
339 /* try an invalid list, only one null terminator */
342 shfo.wFunc = FO_DELETE;
343 ret = SHFileOperation(&shfo);
344 ok(ret == ERROR_ACCESS_DENIED, "Expected ERROR_ACCESS_DENIED, got %d\n", ret);
345 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
347 /* delete a dir, and then a file inside the dir, same as
348 * deleting a nonexistent file
351 shfo.pFrom = "testdir2\0testdir2\\one.txt\0";
352 ret = SHFileOperation(&shfo);
353 ok(ret == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %d\n", ret);
354 ok(!file_exists("testdir2"), "Expected testdir2 to not exist\n");
355 ok(!file_exists("testdir2\\one.txt"), "Expected testdir2\\one.txt to not exist\n");
357 /* try the FOF_NORECURSION flag, continues deleting subdirs */
359 shfo.pFrom = "testdir2\0";
360 shfo.fFlags |= FOF_NORECURSION;
361 ret = SHFileOperation(&shfo);
362 ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
363 ok(!file_exists("testdir2\\one.txt"), "Expected testdir2\\one.txt to not exist\n");
364 ok(!file_exists("testdir2\\nested"), "Expected testdir2\\nested to exist\n");
367 /* tests the FO_RENAME action */
368 static void test_rename(void)
370 SHFILEOPSTRUCTA shfo, shfo2;
371 CHAR from[5*MAX_PATH];
376 shfo.wFunc = FO_RENAME;
379 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
380 shfo.hNameMappings = NULL;
381 shfo.lpszProgressTitle = NULL;
383 set_curr_dir_path(from, "test1.txt\0");
384 set_curr_dir_path(to, "test4.txt\0");
385 ok(SHFileOperationA(&shfo), "File is not renamed moving to other directory "
386 "when specifying directory name only\n");
387 ok(file_exists("test1.txt"), "The file is removed\n");
389 set_curr_dir_path(from, "test3.txt\0");
390 set_curr_dir_path(to, "test4.txt\\test1.txt\0");
391 ok(!SHFileOperationA(&shfo), "File is renamed moving to other directory\n");
392 ok(file_exists("test4.txt\\test1.txt"), "The file is not renamed\n");
394 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
395 set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
396 retval = SHFileOperationA(&shfo); /* W98 returns 0, W2K and newer returns ERROR_GEN_FAILURE, both do nothing */
397 ok(!retval || retval == ERROR_GEN_FAILURE || retval == ERROR_INVALID_TARGET_HANDLE,
398 "Can't rename many files, retval = %d\n", retval);
399 ok(file_exists("test1.txt"), "The file is renamed - many files are specified\n");
401 memcpy(&shfo2, &shfo, sizeof(SHFILEOPSTRUCTA));
402 shfo2.fFlags |= FOF_MULTIDESTFILES;
404 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
405 set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
406 retval = SHFileOperationA(&shfo2); /* W98 returns 0, W2K and newer returns ERROR_GEN_FAILURE, both do nothing */
407 ok(!retval || retval == ERROR_GEN_FAILURE || retval == ERROR_INVALID_TARGET_HANDLE,
408 "Can't rename many files, retval = %d\n", retval);
409 ok(file_exists("test1.txt"), "The file is not renamed - many files are specified\n");
411 set_curr_dir_path(from, "test1.txt\0");
412 set_curr_dir_path(to, "test6.txt\0");
413 retval = SHFileOperationA(&shfo);
414 ok(!retval, "Rename file failed, retval = %d\n", retval);
415 ok(!file_exists("test1.txt"), "The file is not renamed\n");
416 ok(file_exists("test6.txt"), "The file is not renamed\n");
418 set_curr_dir_path(from, "test6.txt\0");
419 set_curr_dir_path(to, "test1.txt\0");
420 retval = SHFileOperationA(&shfo);
421 ok(!retval, "Rename file back failed, retval = %d\n", retval);
423 set_curr_dir_path(from, "test4.txt\0");
424 set_curr_dir_path(to, "test6.txt\0");
425 retval = SHFileOperationA(&shfo);
426 ok(!retval, "Rename dir failed, retval = %d\n", retval);
427 ok(!file_exists("test4.txt"), "The dir is not renamed\n");
428 ok(file_exists("test6.txt"), "The dir is not renamed\n");
430 set_curr_dir_path(from, "test6.txt\0");
431 set_curr_dir_path(to, "test4.txt\0");
432 retval = SHFileOperationA(&shfo);
433 ok(!retval, "Rename dir back failed, retval = %d\n", retval);
435 /* try to rename more than one file to a single file */
436 shfo.pFrom = "test1.txt\0test2.txt\0";
437 shfo.pTo = "a.txt\0";
438 retval = SHFileOperationA(&shfo);
439 ok(retval == ERROR_GEN_FAILURE, "Expected ERROR_GEN_FAILURE, got %d\n", retval);
440 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
441 ok(file_exists("test2.txt"), "Expected test2.txt to exist\n");
443 /* pFrom doesn't exist */
444 shfo.pFrom = "idontexist\0";
445 shfo.pTo = "newfile\0";
446 retval = SHFileOperationA(&shfo);
447 ok(retval == 1026, "Expected 1026, got %d\n", retval);
448 ok(!file_exists("newfile"), "Expected newfile to not exist\n");
450 /* pTo already exist */
451 shfo.pFrom = "test1.txt\0";
452 shfo.pTo = "test2.txt\0";
453 retval = SHFileOperationA(&shfo);
454 ok(retval == ERROR_ALREADY_EXISTS, "Expected ERROR_ALREADY_EXISTS, got %d\n", retval);
456 /* pFrom is valid, but pTo is empty */
457 shfo.pFrom = "test1.txt\0";
459 retval = SHFileOperationA(&shfo);
460 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
461 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
465 retval = SHFileOperationA(&shfo);
466 ok(retval == ERROR_ACCESS_DENIED, "Expected ERROR_ACCESS_DENIED, got %d\n", retval);
468 /* pFrom is NULL, commented out because it crashes on nt 4.0 */
471 retval = SHFileOperationA(&shfo);
472 ok(retval == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", retval);
476 /* tests the FO_COPY action */
477 static void test_copy(void)
479 SHFILEOPSTRUCTA shfo, shfo2;
480 CHAR from[5*MAX_PATH];
482 FILEOP_FLAGS tmp_flags;
487 shfo.wFunc = FO_COPY;
490 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
491 shfo.hNameMappings = NULL;
492 shfo.lpszProgressTitle = NULL;
494 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
495 set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
496 ok(SHFileOperationA(&shfo), "Can't copy many files\n");
497 ok(!file_exists("test6.txt"), "The file is not copied - many files are "
498 "specified as a target\n");
500 memcpy(&shfo2, &shfo, sizeof(SHFILEOPSTRUCTA));
501 shfo2.fFlags |= FOF_MULTIDESTFILES;
503 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
504 set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
505 ok(!SHFileOperationA(&shfo2), "Can't copy many files\n");
506 ok(file_exists("test6.txt"), "The file is copied - many files are "
507 "specified as a target\n");
508 DeleteFileA("test6.txt");
509 DeleteFileA("test7.txt");
510 RemoveDirectoryA("test8.txt");
512 /* number of sources do not correspond to number of targets */
513 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
514 set_curr_dir_path(to, "test6.txt\0test7.txt\0");
515 ok(SHFileOperationA(&shfo2), "Can't copy many files\n");
516 ok(!file_exists("test6.txt"), "The file is not copied - many files are "
517 "specified as a target\n");
519 set_curr_dir_path(from, "test1.txt\0");
520 set_curr_dir_path(to, "test4.txt\0");
521 ok(!SHFileOperationA(&shfo), "Prepare test to check how directories are copied recursively\n");
522 ok(file_exists("test4.txt\\test1.txt"), "The file is copied\n");
524 set_curr_dir_path(from, "test?.txt\0");
525 set_curr_dir_path(to, "testdir2\0");
526 ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n");
527 ok(!file_exists("testdir2\\test4.txt"), "The directory is not copied yet\n");
528 ok(!SHFileOperationA(&shfo), "Files and directories are copied to directory\n");
529 ok(file_exists("testdir2\\test1.txt"), "The file is copied\n");
530 ok(file_exists("testdir2\\test4.txt"), "The directory is copied\n");
531 ok(file_exists("testdir2\\test4.txt\\test1.txt"), "The file in subdirectory is copied\n");
532 clean_after_shfo_tests();
535 shfo.fFlags |= FOF_FILESONLY;
536 ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n");
537 ok(!file_exists("testdir2\\test4.txt"), "The directory is not copied yet\n");
538 ok(!SHFileOperationA(&shfo), "Files are copied to other directory\n");
539 ok(file_exists("testdir2\\test1.txt"), "The file is copied\n");
540 ok(!file_exists("testdir2\\test4.txt"), "The directory is copied\n");
541 clean_after_shfo_tests();
544 set_curr_dir_path(from, "test1.txt\0test2.txt\0");
545 ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n");
546 ok(!file_exists("testdir2\\test2.txt"), "The file is not copied yet\n");
547 ok(!SHFileOperationA(&shfo), "Files are copied to other directory\n");
548 ok(file_exists("testdir2\\test1.txt"), "The file is copied\n");
549 ok(file_exists("testdir2\\test2.txt"), "The file is copied\n");
550 clean_after_shfo_tests();
552 /* Copying multiple files with one not existing as source, fails the
553 entire operation in Win98/ME/2K/XP, but not in 95/NT */
555 tmp_flags = shfo.fFlags;
556 set_curr_dir_path(from, "test1.txt\0test10.txt\0test2.txt\0");
557 ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n");
558 ok(!file_exists("testdir2\\test2.txt"), "The file is not copied yet\n");
559 retval = SHFileOperationA(&shfo);
561 /* Win 95/NT returns success but copies only the files up to the nonexistent source */
562 ok(file_exists("testdir2\\test1.txt"), "The file is not copied\n");
565 /* Win 98/ME/2K/XP fail the entire operation with return code 1026 if one source file does not exist */
566 ok(retval == 1026, "Files are copied to other directory\n");
567 ok(!file_exists("testdir2\\test1.txt"), "The file is copied\n");
569 ok(!file_exists("testdir2\\test2.txt"), "The file is copied\n");
570 shfo.fFlags = tmp_flags;
572 /* copy into a nonexistent directory */
574 shfo.fFlags = FOF_NOCONFIRMMKDIR;
575 set_curr_dir_path(from, "test1.txt\0");
576 set_curr_dir_path(to, "nonexistent\\notreal\\test2.txt\0");
577 retval= SHFileOperation(&shfo);
578 ok(!retval, "Error copying into nonexistent directory\n");
579 ok(file_exists("nonexistent"), "nonexistent not created\n");
580 ok(file_exists("nonexistent\\notreal"), "nonexistent\\notreal not created\n");
581 ok(file_exists("nonexistent\\notreal\\test2.txt"), "Directory not created\n");
582 ok(!file_exists("nonexistent\\notreal\\test1.txt"), "test1.txt should not exist\n");
584 /* a relative dest directory is OK */
585 clean_after_shfo_tests();
587 shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0";
588 shfo.pTo = "testdir2\0";
589 retval = SHFileOperation(&shfo);
590 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
591 ok(file_exists("testdir2\\test1.txt"), "Expected testdir2\\test1 to exist\n");
593 /* try to copy files to a file */
594 clean_after_shfo_tests();
598 set_curr_dir_path(from, "test1.txt\0test2.txt\0");
599 set_curr_dir_path(to, "test3.txt\0");
600 retval = SHFileOperation(&shfo);
601 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
602 ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n");
603 ok(!file_exists("test3.txt\\test2.txt"), "Expected test3.txt\\test2.txt to not exist\n");
605 /* try to copy many files to nonexistent directory */
607 shfo.fAnyOperationsAborted = FALSE;
608 retval = SHFileOperation(&shfo);
609 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
610 ok(DeleteFile("test3.txt\\test1.txt"), "Expected test3.txt\\test1.txt to exist\n");
611 ok(DeleteFile("test3.txt\\test2.txt"), "Expected test3.txt\\test1.txt to exist\n");
612 ok(RemoveDirectory(to), "Expected test3.txt to exist\n");
614 /* send in FOF_MULTIDESTFILES with too many destination files */
616 shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0";
617 shfo.pTo = "testdir2\\a.txt\0testdir2\\b.txt\0testdir2\\c.txt\0testdir2\\d.txt\0";
618 shfo.fFlags |= FOF_NOERRORUI | FOF_MULTIDESTFILES;
619 retval = SHFileOperation(&shfo);
620 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
621 ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n");
622 ok(!file_exists("testdir2\\a.txt"), "Expected testdir2\\a.txt to not exist\n");
624 /* send in FOF_MULTIDESTFILES with too many destination files */
625 shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0";
626 shfo.pTo = "e.txt\0f.txt\0";
627 shfo.fAnyOperationsAborted = FALSE;
628 retval = SHFileOperation(&shfo);
629 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
630 ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n");
631 ok(!file_exists("e.txt"), "Expected e.txt to not exist\n");
633 /* use FOF_MULTIDESTFILES with files and a source directory */
634 shfo.pFrom = "test1.txt\0test2.txt\0test4.txt\0";
635 shfo.pTo = "testdir2\\a.txt\0testdir2\\b.txt\0testdir2\\c.txt\0";
636 shfo.fAnyOperationsAborted = FALSE;
637 retval = SHFileOperation(&shfo);
638 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
639 ok(DeleteFile("testdir2\\a.txt"), "Expected testdir2\\a.txt to exist\n");
640 ok(DeleteFile("testdir2\\b.txt"), "Expected testdir2\\b.txt to exist\n");
641 ok(RemoveDirectory("testdir2\\c.txt"), "Expected testdir2\\c.txt to exist\n");
643 /* try many dest files without FOF_MULTIDESTFILES flag */
644 shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0";
645 shfo.pTo = "a.txt\0b.txt\0c.txt\0";
646 shfo.fAnyOperationsAborted = FALSE;
647 shfo.fFlags &= ~FOF_MULTIDESTFILES;
648 retval = SHFileOperation(&shfo);
649 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
650 ok(!file_exists("a.txt"), "Expected a.txt to not exist\n");
653 shfo.pFrom = "test?.txt\0";
654 shfo.pTo = "testdir2\0";
655 shfo.fFlags &= ~FOF_MULTIDESTFILES;
656 retval = SHFileOperation(&shfo);
657 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
658 ok(file_exists("testdir2\\test1.txt"), "Expected testdir2\\test1.txt to exist\n");
660 /* try a glob with FOF_FILESONLY */
661 clean_after_shfo_tests();
663 shfo.pFrom = "test?.txt\0";
664 shfo.fFlags |= FOF_FILESONLY;
665 retval = SHFileOperation(&shfo);
666 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
667 ok(file_exists("testdir2\\test1.txt"), "Expected testdir2\\test1.txt to exist\n");
668 ok(!file_exists("testdir2\\test4.txt"), "Expected testdir2\\test4.txt to not exist\n");
670 /* try a glob with FOF_MULTIDESTFILES and the same number
671 * of dest files that we would expect
673 clean_after_shfo_tests();
675 shfo.pTo = "testdir2\\a.txt\0testdir2\\b.txt\0testdir2\\c.txt\0testdir2\\d.txt\0";
676 shfo.fFlags &= ~FOF_FILESONLY;
677 shfo.fFlags |= FOF_MULTIDESTFILES;
678 retval = SHFileOperation(&shfo);
679 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
680 ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n");
681 ok(!file_exists("testdir2\\a.txt"), "Expected testdir2\\test1.txt to not exist\n");
682 ok(!RemoveDirectory("b.txt"), "b.txt should not exist\n");
684 /* copy one file to two others, second is ignored */
685 clean_after_shfo_tests();
687 shfo.pFrom = "test1.txt\0";
688 shfo.pTo = "b.txt\0c.txt\0";
689 shfo.fAnyOperationsAborted = FALSE;
690 retval = SHFileOperation(&shfo);
691 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
692 ok(DeleteFile("b.txt"), "Expected b.txt to exist\n");
693 ok(!DeleteFile("c.txt"), "Expected c.txt to not exist\n");
695 /* copy two file to three others, all fail */
696 shfo.pFrom = "test1.txt\0test2.txt\0";
697 shfo.pTo = "b.txt\0c.txt\0d.txt\0";
698 retval = SHFileOperation(&shfo);
699 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
700 ok(shfo.fAnyOperationsAborted, "Expected operations to be aborted\n");
701 ok(!DeleteFile("b.txt"), "Expected b.txt to not exist\n");
703 /* copy one file and one directory to three others */
704 shfo.pFrom = "test1.txt\0test4.txt\0";
705 shfo.pTo = "b.txt\0c.txt\0d.txt\0";
706 shfo.fAnyOperationsAborted = FALSE;
707 retval = SHFileOperation(&shfo);
708 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
709 ok(shfo.fAnyOperationsAborted, "Expected operations to be aborted\n");
710 ok(!DeleteFile("b.txt"), "Expected b.txt to not exist\n");
711 ok(!DeleteFile("c.txt"), "Expected c.txt to not exist\n");
713 /* copy a directory with a file beneath it, plus some files */
714 createTestFile("test4.txt\\a.txt");
715 shfo.pFrom = "test4.txt\0test1.txt\0";
716 shfo.pTo = "testdir2\0";
717 shfo.fFlags &= ~FOF_MULTIDESTFILES;
718 shfo.fAnyOperationsAborted = FALSE;
719 retval = SHFileOperation(&shfo);
720 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
721 ok(DeleteFile("testdir2\\test1.txt"), "Expected newdir\\test1.txt to exist\n");
722 ok(DeleteFile("testdir2\\test4.txt\\a.txt"), "Expected a.txt to exist\n");
723 ok(RemoveDirectory("testdir2\\test4.txt"), "Expected testdir2\\test4.txt to exist\n");
725 /* copy one directory and a file in that dir to another dir */
726 shfo.pFrom = "test4.txt\0test4.txt\\a.txt\0";
727 shfo.pTo = "testdir2\0";
728 retval = SHFileOperation(&shfo);
729 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
730 ok(DeleteFile("testdir2\\test4.txt\\a.txt"), "Expected a.txt to exist\n");
731 ok(DeleteFile("testdir2\\a.txt"), "Expected testdir2\\a.txt to exist\n");
733 /* copy a file in a directory first, and then the directory to a nonexistent dir */
734 shfo.pFrom = "test4.txt\\a.txt\0test4.txt\0";
735 shfo.pTo = "nonexistent\0";
736 retval = SHFileOperation(&shfo);
737 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
738 ok(shfo.fAnyOperationsAborted, "Expected operations to be aborted\n");
739 ok(!file_exists("nonexistent\\test4.txt"), "Expected nonexistent\\test4.txt to not exist\n");
740 DeleteFile("test4.txt\\a.txt");
742 /* destination is same as source file */
743 shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0";
744 shfo.pTo = "b.txt\0test2.txt\0c.txt\0";
745 shfo.fAnyOperationsAborted = FALSE;
746 shfo.fFlags = FOF_NOERRORUI | FOF_MULTIDESTFILES;
747 retval = SHFileOperation(&shfo);
748 ok(retval == ERROR_NO_MORE_SEARCH_HANDLES,
749 "Expected ERROR_NO_MORE_SEARCH_HANDLES, got %d\n", retval);
750 ok(!shfo.fAnyOperationsAborted, "Expected no operations to be aborted\n");
751 ok(DeleteFile("b.txt"), "Expected b.txt to exist\n");
752 ok(!file_exists("c.txt"), "Expected c.txt to not exist\n");
754 /* destination is same as source directory */
755 shfo.pFrom = "test1.txt\0test4.txt\0test3.txt\0";
756 shfo.pTo = "b.txt\0test4.txt\0c.txt\0";
757 shfo.fAnyOperationsAborted = FALSE;
758 retval = SHFileOperation(&shfo);
759 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
760 ok(DeleteFile("b.txt"), "Expected b.txt to exist\n");
761 ok(!file_exists("c.txt"), "Expected c.txt to not exist\n");
763 /* copy a directory into itself, error displayed in UI */
764 shfo.pFrom = "test4.txt\0";
765 shfo.pTo = "test4.txt\\newdir\0";
766 shfo.fFlags &= ~FOF_MULTIDESTFILES;
767 shfo.fAnyOperationsAborted = FALSE;
768 retval = SHFileOperation(&shfo);
769 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
770 ok(!RemoveDirectory("test4.txt\\newdir"), "Expected test4.txt\\newdir to not exist\n");
772 /* copy a directory to itself, error displayed in UI */
773 shfo.pFrom = "test4.txt\0";
774 shfo.pTo = "test4.txt\0";
775 shfo.fAnyOperationsAborted = FALSE;
776 retval = SHFileOperation(&shfo);
777 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
779 /* copy a file into a directory, and the directory into itself */
780 shfo.pFrom = "test1.txt\0test4.txt\0";
781 shfo.pTo = "test4.txt\0";
782 shfo.fAnyOperationsAborted = FALSE;
783 shfo.fFlags |= FOF_NOCONFIRMATION;
784 retval = SHFileOperation(&shfo);
785 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
786 ok(DeleteFile("test4.txt\\test1.txt"), "Expected test4.txt\\test1.txt to exist\n");
788 /* copy a file to a file, and the directory into itself */
789 shfo.pFrom = "test1.txt\0test4.txt\0";
790 shfo.pTo = "test4.txt\\a.txt\0";
791 shfo.fAnyOperationsAborted = FALSE;
792 retval = SHFileOperation(&shfo);
793 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
794 ok(!file_exists("test4.txt\\a.txt"), "Expected test4.txt\\a.txt to not exist\n");
796 /* copy a nonexistent file to a nonexistent directory */
797 shfo.pFrom = "e.txt\0";
798 shfo.pTo = "nonexistent\0";
799 shfo.fAnyOperationsAborted = FALSE;
800 retval = SHFileOperation(&shfo);
801 ok(retval == 1026, "Expected 1026, got %d\n", retval);
802 ok(!file_exists("nonexistent\\e.txt"), "Expected nonexistent\\e.txt to not exist\n");
803 ok(!file_exists("nonexistent"), "Expected nonexistent to not exist\n");
805 /* Overwrite tests */
806 clean_after_shfo_tests();
808 shfo.fFlags = FOF_NOCONFIRMATION;
809 shfo.pFrom = "test1.txt\0";
810 shfo.pTo = "test2.txt\0";
811 shfo.fAnyOperationsAborted = FALSE;
812 /* without FOF_NOCOFIRMATION the confirmation is Yes/No */
813 retval = SHFileOperation(&shfo);
814 ok(retval == 0, "Expected 0, got %d\n", retval);
815 ok(file_has_content("test2.txt", "test1.txt\n"), "The file was not copied\n");
817 shfo.pFrom = "test3.txt\0test1.txt\0";
818 shfo.pTo = "test2.txt\0one.txt\0";
819 shfo.fFlags = FOF_NOCONFIRMATION | FOF_MULTIDESTFILES;
820 /* without FOF_NOCOFIRMATION the confirmation is Yes/Yes to All/No/Cancel */
821 retval = SHFileOperation(&shfo);
822 ok(retval == 0, "Expected 0, got %d\n", retval);
823 ok(file_has_content("test2.txt", "test3.txt\n"), "The file was not copied\n");
825 shfo.pFrom = "one.txt\0";
826 shfo.pTo = "testdir2\0";
827 shfo.fFlags = FOF_NOCONFIRMATION;
828 /* without FOF_NOCOFIRMATION the confirmation is Yes/No */
829 retval = SHFileOperation(&shfo);
830 ok(retval == 0, "Expected 0, got %d\n", retval);
831 ok(file_has_content("testdir2\\one.txt", "test1.txt\n"), "The file was not copied\n");
833 createTestFile("test4.txt\\test1.txt");
834 shfo.pFrom = "test4.txt\0";
835 shfo.pTo = "testdir2\0";
836 shfo.fFlags = FOF_NOCONFIRMATION;
837 ok(!SHFileOperation(&shfo), "First SHFileOperation failed\n");
838 createTestFile("test4.txt\\.\\test1.txt"); /* modify the content of the file */
839 /* without FOF_NOCOFIRMATION the confirmation is "This folder already contains a folder named ..." */
840 retval = SHFileOperation(&shfo);
841 ok(retval == 0, "Expected 0, got %d\n", retval);
842 ok(file_has_content("testdir2\\test4.txt\\test1.txt", "test4.txt\\.\\test1.txt\n"), "The file was not copied\n");
844 createTestFile("one.txt");
846 /* no double-NULL terminator for pFrom */
847 memset(from, 'a', MAX_PATH);
848 lstrcpyA(from, "one.txt");
850 shfo.pTo = "two.txt\0";
851 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
852 retval = SHFileOperation(&shfo);
853 ok(retval == 1148 || retval == 1026, "Expected 1148 or 1026, got %d\n", retval);
854 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
855 ok(!DeleteFileA("two.txt"), "Expected file to not exist\n");
857 createTestFile("one.txt");
859 /* no double-NULL terminator for pTo */
860 memset(to, 'a', MAX_PATH);
861 lstrcpyA(to, "two.txt");
862 shfo.pFrom = "one.txt\0";
864 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
865 retval = SHFileOperation(&shfo);
866 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
867 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
868 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
870 createTestFile("one.txt");
872 /* no FOF_MULTIDESTFILES, two files in pTo */
873 shfo.pFrom = "one.txt\0";
874 shfo.pTo = "two.txt\0three.txt\0";
875 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
876 retval = SHFileOperation(&shfo);
877 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
878 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
879 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
881 createTestFile("one.txt");
883 /* no double-NULL terminator for pFrom and pTo */
884 memset(from, 'a', MAX_PATH);
885 memset(to, 'a', MAX_PATH);
886 lstrcpyA(from, "one.txt");
887 lstrcpyA(to, "two.txt");
890 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
891 retval = SHFileOperation(&shfo);
892 ok(retval == 1148 || retval == 1026, "Expected 1148 or 1026, got %d\n", retval);
893 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
894 ok(!DeleteFileA("two.txt"), "Expected file to not exist\n");
896 createTestFile("one.txt");
898 /* no double-NULL terminator for pTo, FOF_MULTIDESTFILES */
899 memset(to, 'a', MAX_PATH);
900 lstrcpyA(to, "two.txt");
901 shfo.pFrom = "one.txt\0";
903 shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION |
904 FOF_SILENT | FOF_NOERRORUI;
905 retval = SHFileOperation(&shfo);
906 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
907 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
908 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
910 createTestFile("one.txt");
911 createTestFile("two.txt");
913 /* no double-NULL terminator for pTo,
914 * multiple source files,
915 * dest directory does not exist
917 memset(to, 'a', 2 * MAX_PATH);
918 lstrcpyA(to, "threedir");
919 shfo.pFrom = "one.txt\0two.txt\0";
921 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
922 retval = SHFileOperation(&shfo);
923 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
924 ok(!DeleteFileA("threedir\\one.txt"), "Expected file to not exist\n");
925 ok(!DeleteFileA("threedir\\two.txt"), "Expected file to not exist\n");
926 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
927 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
928 ok(!DeleteFileA("threedir"), "Expected file to not exist\n");
929 ok(!RemoveDirectoryA("threedir"), "Expected dir to not exist\n");
931 createTestFile("one.txt");
932 createTestFile("two.txt");
933 CreateDirectoryA("threedir", NULL);
935 /* no double-NULL terminator for pTo,
936 * multiple source files,
937 * dest directory does exist
939 memset(to, 'a', 2 * MAX_PATH);
940 lstrcpyA(to, "threedir");
941 shfo.pFrom = "one.txt\0two.txt\0";
943 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
944 retval = SHFileOperation(&shfo);
945 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
946 ok(DeleteFileA("threedir\\one.txt"), "Expected file to exist\n");
947 ok(DeleteFileA("threedir\\two.txt"), "Expected file to exist\n");
948 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
949 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
950 ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
952 createTestFile("one.txt");
953 createTestFile("two.txt");
955 /* no double-NULL terminator for pTo,
956 * multiple source files, FOF_MULTIDESTFILES
957 * dest dir does not exist
959 memset(to, 'a', 2 * MAX_PATH);
960 lstrcpyA(to, "threedir");
961 shfo.pFrom = "one.txt\0two.txt\0";
963 shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION |
964 FOF_SILENT | FOF_NOERRORUI;
965 retval = SHFileOperation(&shfo);
966 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
967 ok(!DeleteFileA("threedir\\one.txt"), "Expected file to not exist\n");
968 ok(!DeleteFileA("threedir\\two.txt"), "Expected file to not exist\n");
969 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
970 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
971 ok(!RemoveDirectoryA("threedir"), "Expected dir to not exist\n");
973 /* file exists in win2k */
974 DeleteFileA("threedir");
976 createTestFile("one.txt");
977 createTestFile("two.txt");
978 CreateDirectoryA("threedir", NULL);
980 /* no double-NULL terminator for pTo,
981 * multiple source files, FOF_MULTIDESTFILES
982 * dest dir does exist
984 memset(to, 'a', 2 * MAX_PATH);
985 lstrcpyA(to, "threedir");
986 ptr = to + lstrlenA(to) + 1;
987 lstrcpyA(ptr, "fourdir");
988 shfo.pFrom = "one.txt\0two.txt\0";
990 shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION |
991 FOF_SILENT | FOF_NOERRORUI;
992 retval = SHFileOperation(&shfo);
993 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
994 ok(DeleteFileA("threedir\\one.txt"), "Expected file to exist\n");
995 ok(DeleteFileA("threedir\\two.txt"), "Expected file to exist\n");
996 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
997 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
998 ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
999 ok(!DeleteFileA("fourdir"), "Expected file to not exist\n");
1000 ok(!RemoveDirectoryA("fourdir"), "Expected dir to not exist\n");
1002 createTestFile("one.txt");
1003 createTestFile("two.txt");
1004 CreateDirectoryA("threedir", NULL);
1006 /* multiple source files, FOF_MULTIDESTFILES
1007 * multiple dest files, but first dest dir exists
1008 * num files in lists is equal
1010 shfo.pFrom = "one.txt\0two.txt\0";
1011 shfo.pTo = "threedir\0fourdir\0";
1012 shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION |
1013 FOF_SILENT | FOF_NOERRORUI;
1014 retval = SHFileOperation(&shfo);
1015 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
1016 ok(!DeleteFileA("threedir\\one.txt"), "Expected file to not exist\n");
1017 ok(!DeleteFileA("threedir\\two.txt"), "Expected file to not exist\n");
1018 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1019 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1020 ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
1021 ok(!DeleteFileA("fourdir"), "Expected file to not exist\n");
1022 ok(!RemoveDirectoryA("fourdir"), "Expected dit to not exist\n");
1024 createTestFile("one.txt");
1025 createTestFile("two.txt");
1026 CreateDirectoryA("threedir", NULL);
1028 /* multiple source files, FOF_MULTIDESTFILES
1029 * multiple dest files, but first dest dir exists
1030 * num files in lists is not equal
1032 shfo.pFrom = "one.txt\0two.txt\0";
1033 shfo.pTo = "threedir\0fourdir\0five\0";
1034 shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION |
1035 FOF_SILENT | FOF_NOERRORUI;
1036 retval = SHFileOperation(&shfo);
1037 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1038 ok(DeleteFileA("threedir\\one.txt"), "Expected file to exist\n");
1039 ok(DeleteFileA("threedir\\two.txt"), "Expected file to exist\n");
1040 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1041 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1042 ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
1043 ok(!DeleteFileA("fourdir"), "Expected file to not exist\n");
1044 ok(!RemoveDirectoryA("fourdir"), "Expected dit to not exist\n");
1045 ok(!DeleteFileA("five"), "Expected file to not exist\n");
1046 ok(!RemoveDirectoryA("five"), "Expected dit to not exist\n");
1048 createTestFile("aa.txt");
1049 createTestFile("ab.txt");
1050 CreateDirectoryA("one", NULL);
1051 CreateDirectoryA("two", NULL);
1053 /* pFrom has a glob, pTo has more than one dest */
1054 shfo.pFrom = "a*.txt\0";
1055 shfo.pTo = "one\0two\0";
1056 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1057 retval = SHFileOperation(&shfo);
1058 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1059 ok(DeleteFileA("one\\aa.txt"), "Expected file to exist\n");
1060 ok(DeleteFileA("one\\ab.txt"), "Expected file to exist\n");
1061 ok(!DeleteFileA("two\\aa.txt"), "Expected file to not exist\n");
1062 ok(!DeleteFileA("two\\ab.txt"), "Expected file to not exist\n");
1063 ok(DeleteFileA("aa.txt"), "Expected file to exist\n");
1064 ok(DeleteFileA("ab.txt"), "Expected file to exist\n");
1065 ok(RemoveDirectoryA("one"), "Expected dir to exist\n");
1066 ok(RemoveDirectoryA("two"), "Expected dir to exist\n");
1069 /* tests the FO_MOVE action */
1070 static void test_move(void)
1072 SHFILEOPSTRUCTA shfo, shfo2;
1073 CHAR from[5*MAX_PATH];
1074 CHAR to[5*MAX_PATH];
1078 shfo.wFunc = FO_MOVE;
1081 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1082 shfo.hNameMappings = NULL;
1083 shfo.lpszProgressTitle = NULL;
1085 set_curr_dir_path(from, "test1.txt\0");
1086 set_curr_dir_path(to, "test4.txt\0");
1087 ok(!SHFileOperationA(&shfo), "Prepare test to check how directories are moved recursively\n");
1088 ok(!file_exists("test1.txt"), "test1.txt should not exist\n");
1089 ok(file_exists("test4.txt\\test1.txt"), "The file is not moved\n");
1091 set_curr_dir_path(from, "test?.txt\0");
1092 set_curr_dir_path(to, "testdir2\0");
1093 ok(!file_exists("testdir2\\test2.txt"), "The file is not moved yet\n");
1094 ok(!file_exists("testdir2\\test4.txt"), "The directory is not moved yet\n");
1095 ok(!SHFileOperationA(&shfo), "Files and directories are moved to directory\n");
1096 ok(file_exists("testdir2\\test2.txt"), "The file is moved\n");
1097 ok(file_exists("testdir2\\test4.txt"), "The directory is moved\n");
1098 ok(file_exists("testdir2\\test4.txt\\test1.txt"), "The file in subdirectory is moved\n");
1100 clean_after_shfo_tests();
1103 memcpy(&shfo2, &shfo, sizeof(SHFILEOPSTRUCTA));
1104 shfo2.fFlags |= FOF_MULTIDESTFILES;
1106 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
1107 set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
1108 ok(!SHFileOperationA(&shfo2), "Move many files\n");
1109 ok(file_exists("test6.txt"), "The file is moved - many files are "
1110 "specified as a target\n");
1111 DeleteFileA("test6.txt");
1112 DeleteFileA("test7.txt");
1113 RemoveDirectoryA("test8.txt");
1117 /* number of sources do not correspond to number of targets */
1118 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
1119 set_curr_dir_path(to, "test6.txt\0test7.txt\0");
1120 ok(SHFileOperationA(&shfo2), "Can't move many files\n");
1121 ok(!file_exists("test6.txt"), "The file is not moved - many files are "
1122 "specified as a target\n");
1126 set_curr_dir_path(from, "test3.txt\0");
1127 set_curr_dir_path(to, "test4.txt\\test1.txt\0");
1128 ok(!SHFileOperationA(&shfo), "File is moved moving to other directory\n");
1129 ok(file_exists("test4.txt\\test1.txt"), "The file is moved\n");
1131 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
1132 set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
1133 ok(SHFileOperationA(&shfo), "Cannot move many files\n");
1134 ok(file_exists("test1.txt"), "The file is not moved. Many files are specified\n");
1135 ok(file_exists("test4.txt"), "The directory is not moved. Many files are specified\n");
1137 set_curr_dir_path(from, "test1.txt\0");
1138 set_curr_dir_path(to, "test6.txt\0");
1139 ok(!SHFileOperationA(&shfo), "Move file\n");
1140 ok(!file_exists("test1.txt"), "The file is moved\n");
1141 ok(file_exists("test6.txt"), "The file is moved\n");
1142 set_curr_dir_path(from, "test6.txt\0");
1143 set_curr_dir_path(to, "test1.txt\0");
1144 ok(!SHFileOperationA(&shfo), "Move file back\n");
1146 set_curr_dir_path(from, "test4.txt\0");
1147 set_curr_dir_path(to, "test6.txt\0");
1148 ok(!SHFileOperationA(&shfo), "Move dir\n");
1149 ok(!file_exists("test4.txt"), "The dir is moved\n");
1150 ok(file_exists("test6.txt"), "The dir is moved\n");
1151 set_curr_dir_path(from, "test6.txt\0");
1152 set_curr_dir_path(to, "test4.txt\0");
1153 ok(!SHFileOperationA(&shfo), "Move dir back\n");
1155 /* move one file to two others */
1157 shfo.pFrom = "test1.txt\0";
1158 shfo.pTo = "a.txt\0b.txt\0";
1159 retval = SHFileOperationA(&shfo);
1160 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1161 ok(!file_exists("test1.txt"), "Expected test1.txt to not exist\n");
1162 ok(DeleteFile("a.txt"), "Expected a.txt to exist\n");
1163 ok(!file_exists("b.txt"), "Expected b.txt to not exist\n");
1165 /* move two files to one other */
1166 shfo.pFrom = "test2.txt\0test3.txt\0";
1167 shfo.pTo = "test1.txt\0";
1168 retval = SHFileOperationA(&shfo);
1169 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
1170 ok(!file_exists("test1.txt"), "Expected test1.txt to not exist\n");
1171 ok(file_exists("test2.txt"), "Expected test2.txt to exist\n");
1172 ok(file_exists("test3.txt"), "Expected test3.txt to exist\n");
1174 /* move a directory into itself */
1175 shfo.pFrom = "test4.txt\0";
1176 shfo.pTo = "test4.txt\\b.txt\0";
1177 retval = SHFileOperationA(&shfo);
1178 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1179 ok(!RemoveDirectory("test4.txt\\b.txt"), "Expected test4.txt\\b.txt to not exist\n");
1180 ok(file_exists("test4.txt"), "Expected test4.txt to exist\n");
1182 /* move many files without FOF_MULTIDESTFILES */
1183 shfo.pFrom = "test2.txt\0test3.txt\0";
1184 shfo.pTo = "d.txt\0e.txt\0";
1185 retval = SHFileOperationA(&shfo);
1186 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
1187 ok(!DeleteFile("d.txt"), "Expected d.txt to not exist\n");
1188 ok(!DeleteFile("e.txt"), "Expected e.txt to not exist\n");
1190 /* number of sources != number of targets */
1191 shfo.pTo = "d.txt\0";
1192 shfo.fFlags |= FOF_MULTIDESTFILES;
1193 retval = SHFileOperationA(&shfo);
1194 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
1195 ok(!DeleteFile("d.txt"), "Expected d.txt to not exist\n");
1197 /* FO_MOVE does not create dest directories */
1198 shfo.pFrom = "test2.txt\0";
1199 shfo.pTo = "dir1\\dir2\\test2.txt\0";
1200 retval = SHFileOperationA(&shfo);
1201 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
1202 ok(!file_exists("dir1"), "Expected dir1 to not exist\n");
1204 /* try to overwrite an existing file */
1205 shfo.pTo = "test3.txt\0";
1206 retval = SHFileOperationA(&shfo);
1207 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1208 ok(!file_exists("test2.txt"), "Expected test2.txt to not exist\n");
1209 ok(file_exists("test3.txt"), "Expected test3.txt to exist\n");
1212 static void test_sh_create_dir(void)
1214 CHAR path[MAX_PATH];
1217 if(!pSHCreateDirectoryExA)
1219 trace("skipping SHCreateDirectoryExA tests\n");
1223 set_curr_dir_path(path, "testdir2\\test4.txt\0");
1224 ret = pSHCreateDirectoryExA(NULL, path, NULL);
1225 ok(ERROR_SUCCESS == ret, "SHCreateDirectoryEx failed to create directory recursively, ret = %d\n", ret);
1226 ok(file_exists("testdir2"), "The first directory is not created\n");
1227 ok(file_exists("testdir2\\test4.txt"), "The second directory is not created\n");
1229 ret = pSHCreateDirectoryExA(NULL, path, NULL);
1230 ok(ERROR_ALREADY_EXISTS == ret, "SHCreateDirectoryEx should fail to create existing directory, ret = %d\n", ret);
1232 ret = pSHCreateDirectoryExA(NULL, "c:\\testdir3", NULL);
1233 ok(file_exists("c:\\testdir3"), "The directory is not created\n");
1236 static void test_sh_path_prepare(void)
1239 CHAR path[MAX_PATH];
1241 if(!pSHPathPrepareForWriteA)
1243 trace("skipping SHPathPrepareForWriteA tests\n");
1247 /* directory exists, SHPPFW_NONE */
1248 set_curr_dir_path(path, "testdir2\0");
1249 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_NONE);
1250 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
1252 /* directory exists, SHPPFW_IGNOREFILENAME */
1253 set_curr_dir_path(path, "testdir2\\test4.txt\0");
1254 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_IGNOREFILENAME);
1255 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
1257 /* directory exists, SHPPFW_DIRCREATE */
1258 set_curr_dir_path(path, "testdir2\0");
1259 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_DIRCREATE);
1260 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
1262 /* directory exists, SHPPFW_IGNOREFILENAME|SHPPFW_DIRCREATE */
1263 set_curr_dir_path(path, "testdir2\\test4.txt\0");
1264 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_IGNOREFILENAME|SHPPFW_DIRCREATE);
1265 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
1266 ok(!file_exists("nonexistent\\"), "nonexistent\\ exists but shouldn't\n");
1268 /* file exists, SHPPFW_NONE */
1269 set_curr_dir_path(path, "test1.txt\0");
1270 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_NONE);
1271 ok(res == HRESULT_FROM_WIN32(ERROR_DIRECTORY), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_DIRECTORY)\n", res);
1273 /* file exists, SHPPFW_DIRCREATE */
1274 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_DIRCREATE);
1275 ok(res == HRESULT_FROM_WIN32(ERROR_DIRECTORY), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_DIRECTORY)\n", res);
1277 /* file exists, SHPPFW_NONE, trailing \ */
1278 set_curr_dir_path(path, "test1.txt\\\0");
1279 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_NONE);
1280 ok(res == HRESULT_FROM_WIN32(ERROR_DIRECTORY), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_DIRECTORY)\n", res);
1282 /* relative path exists, SHPPFW_DIRCREATE */
1283 res = pSHPathPrepareForWriteA(0, 0, ".\\testdir2", SHPPFW_DIRCREATE);
1284 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
1286 /* relative path doesn't exist, SHPPFW_DIRCREATE -- Windows does not create the directory in this case */
1287 res = pSHPathPrepareForWriteA(0, 0, ".\\testdir2\\test4.txt", SHPPFW_DIRCREATE);
1288 ok(res == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)\n", res);
1289 ok(!file_exists(".\\testdir2\\test4.txt\\"), ".\\testdir2\\test4.txt\\ exists but shouldn't\n");
1291 /* directory doesn't exist, SHPPFW_NONE */
1292 set_curr_dir_path(path, "nonexistent\0");
1293 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_NONE);
1294 ok(res == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)\n", res);
1296 /* directory doesn't exist, SHPPFW_IGNOREFILENAME */
1297 set_curr_dir_path(path, "nonexistent\\notreal\0");
1298 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_IGNOREFILENAME);
1299 ok(res == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)\n", res);
1300 ok(!file_exists("nonexistent\\notreal"), "nonexistent\\notreal exists but shouldn't\n");
1301 ok(!file_exists("nonexistent\\"), "nonexistent\\ exists but shouldn't\n");
1303 /* directory doesn't exist, SHPPFW_IGNOREFILENAME|SHPPFW_DIRCREATE */
1304 set_curr_dir_path(path, "testdir2\\test4.txt\\\0");
1305 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_IGNOREFILENAME|SHPPFW_DIRCREATE);
1306 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
1307 ok(file_exists("testdir2\\test4.txt\\"), "testdir2\\test4.txt doesn't exist but should\n");
1309 /* nested directory doesn't exist, SHPPFW_DIRCREATE */
1310 set_curr_dir_path(path, "nonexistent\\notreal\0");
1311 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_DIRCREATE);
1312 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
1313 ok(file_exists("nonexistent\\notreal"), "nonexistent\\notreal doesn't exist but should\n");
1315 /* SHPPFW_ASKDIRCREATE, SHPPFW_NOWRITECHECK, and SHPPFW_MEDIACHECKONLY are untested */
1317 if(!pSHPathPrepareForWriteW)
1319 skip("Skipping SHPathPrepareForWriteW tests\n");
1322 /* unicode directory doesn't exist, SHPPFW_NONE */
1323 res = pSHPathPrepareForWriteW(0, 0, UNICODE_PATH, SHPPFW_NONE);
1324 ok(res == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "res == %08x, expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)\n", res);
1325 ok(!file_existsW(UNICODE_PATH), "unicode path was created but shouldn't be\n");
1326 RemoveDirectoryW(UNICODE_PATH);
1328 /* unicode directory doesn't exist, SHPPFW_DIRCREATE */
1329 res = pSHPathPrepareForWriteW(0, 0, UNICODE_PATH, SHPPFW_DIRCREATE);
1330 ok(res == S_OK, "res == %08x, expected S_OK\n", res);
1331 ok(file_existsW(UNICODE_PATH), "unicode path should've been created\n");
1333 /* unicode directory exists, SHPPFW_NONE */
1334 res = pSHPathPrepareForWriteW(0, 0, UNICODE_PATH, SHPPFW_NONE);
1335 ok(res == S_OK, "ret == %08x, expected S_OK\n", res);
1337 /* unicode directory exists, SHPPFW_DIRCREATE */
1338 res = pSHPathPrepareForWriteW(0, 0, UNICODE_PATH, SHPPFW_DIRCREATE);
1339 ok(res == S_OK, "ret == %08x, expected S_OK\n", res);
1340 RemoveDirectoryW(UNICODE_PATH);
1343 static void test_unicode(void)
1345 SHFILEOPSTRUCTW shfoW;
1349 if (!pSHFileOperationW)
1351 skip("SHFileOperationW() is missing\n");
1356 shfoW.wFunc = FO_DELETE;
1357 shfoW.pFrom = UNICODE_PATH;
1359 shfoW.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1360 shfoW.hNameMappings = NULL;
1361 shfoW.lpszProgressTitle = NULL;
1363 /* Clean up before start test */
1364 DeleteFileW(UNICODE_PATH);
1365 RemoveDirectoryW(UNICODE_PATH);
1367 /* Make sure we are on a system that supports unicode */
1368 SetLastError(0xdeadbeef);
1369 file = CreateFileW(UNICODE_PATH, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
1370 if (GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
1372 skip("Unicode tests skipped on non-unicode system\n");
1377 /* Try to delete a file with unicode filename */
1378 ok(file_existsW(UNICODE_PATH), "The file does not exist\n");
1379 ret = pSHFileOperationW(&shfoW);
1380 ok(!ret, "File is not removed, ErrorCode: %d\n", ret);
1381 ok(!file_existsW(UNICODE_PATH), "The file should have been removed\n");
1383 /* Try to trash a file with unicode filename */
1384 createTestFileW(UNICODE_PATH);
1385 shfoW.fFlags |= FOF_ALLOWUNDO;
1386 ok(file_existsW(UNICODE_PATH), "The file does not exist\n");
1387 ret = pSHFileOperationW(&shfoW);
1388 ok(!ret, "File is not removed, ErrorCode: %d\n", ret);
1389 ok(!file_existsW(UNICODE_PATH), "The file should have been removed\n");
1391 if(!pSHCreateDirectoryExW)
1393 skip("Skipping SHCreateDirectoryExW tests\n");
1397 /* Try to delete a directory with unicode filename */
1398 ret = pSHCreateDirectoryExW(NULL, UNICODE_PATH, NULL);
1399 ok(!ret, "SHCreateDirectoryExW returned %d\n", ret);
1400 ok(file_existsW(UNICODE_PATH), "The directory is not created\n");
1401 shfoW.fFlags &= ~FOF_ALLOWUNDO;
1402 ret = pSHFileOperationW(&shfoW);
1403 ok(!ret, "Directory is not removed, ErrorCode: %d\n", ret);
1404 ok(!file_existsW(UNICODE_PATH), "The directory should have been removed\n");
1406 /* Try to trash a directory with unicode filename */
1407 ret = pSHCreateDirectoryExW(NULL, UNICODE_PATH, NULL);
1408 ok(!ret, "SHCreateDirectoryExW returned %d\n", ret);
1409 ok(file_existsW(UNICODE_PATH), "The directory was not created\n");
1410 shfoW.fFlags |= FOF_ALLOWUNDO;
1411 ret = pSHFileOperationW(&shfoW);
1412 ok(!ret, "Directory is not removed, ErrorCode: %d\n", ret);
1413 ok(!file_existsW(UNICODE_PATH), "The directory should have been removed\n");
1416 START_TEST(shlfileop)
1418 InitFunctionPointers();
1420 clean_after_shfo_tests();
1423 test_get_file_info();
1424 clean_after_shfo_tests();
1428 clean_after_shfo_tests();
1432 clean_after_shfo_tests();
1436 clean_after_shfo_tests();
1440 clean_after_shfo_tests();
1442 test_sh_create_dir();
1443 clean_after_shfo_tests();
1446 test_sh_path_prepare();
1447 clean_after_shfo_tests();