webservices: Implement WsReadValue.
[wine.git] / dlls / shell32 / tests / shlfileop.c
blob0e502fc34918a32074b93b348ff7f44991e2d6de
1 /*
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
21 #include <stdarg.h>
22 #include <stdio.h>
24 #define WINE_NOWINSOCK
25 #include <windows.h>
26 #include "shellapi.h"
27 #include "shlobj.h"
29 #include "wine/test.h"
31 #ifndef FOF_NORECURSION
32 #define FOF_NORECURSION 0x1000
33 #endif
35 /* Error codes could be pre-Win32 */
36 #define DE_SAMEFILE 0x71
37 #define DE_MANYSRC1DEST 0x72
38 #define DE_DIFFDIR 0x73
39 #define DE_OPCANCELLED 0x75
40 #define DE_DESTSUBTREE 0x76
41 #define DE_INVALIDFILES 0x7C
42 #define DE_DESTSAMETREE 0x7D
43 #define DE_FLDDESTISFILE 0x7E
44 #define DE_FILEDESTISFLD 0x80
45 #define expect_retval(ret, ret_prewin32)\
46 ok(retval == ret ||\
47 broken(retval == ret_prewin32),\
48 "Expected %d, got %d\n", ret, retval)
50 static BOOL old_shell32 = FALSE;
52 static CHAR CURR_DIR[MAX_PATH];
53 static const WCHAR UNICODE_PATH[] = {'c',':','\\',0x00ae,'\0','\0'};
54 /* "c:\®" can be used in all codepages */
55 /* Double-null termination needed for pFrom field of SHFILEOPSTRUCT */
57 static HMODULE hshell32;
58 static int (WINAPI *pSHCreateDirectoryExA)(HWND, LPCSTR, LPSECURITY_ATTRIBUTES);
59 static int (WINAPI *pSHCreateDirectoryExW)(HWND, LPCWSTR, LPSECURITY_ATTRIBUTES);
60 static int (WINAPI *pSHFileOperationW)(LPSHFILEOPSTRUCTW);
61 static DWORD_PTR (WINAPI *pSHGetFileInfoW)(LPCWSTR, DWORD , SHFILEINFOW*, UINT, UINT);
62 static int (WINAPI *pSHPathPrepareForWriteA)(HWND, IUnknown*, LPCSTR, DWORD);
63 static int (WINAPI *pSHPathPrepareForWriteW)(HWND, IUnknown*, LPCWSTR, DWORD);
65 static void InitFunctionPointers(void)
67 hshell32 = GetModuleHandleA("shell32.dll");
68 pSHCreateDirectoryExA = (void*)GetProcAddress(hshell32, "SHCreateDirectoryExA");
69 pSHCreateDirectoryExW = (void*)GetProcAddress(hshell32, "SHCreateDirectoryExW");
70 pSHFileOperationW = (void*)GetProcAddress(hshell32, "SHFileOperationW");
71 pSHGetFileInfoW = (void*)GetProcAddress(hshell32, "SHGetFileInfoW");
72 pSHPathPrepareForWriteA = (void*)GetProcAddress(hshell32, "SHPathPrepareForWriteA");
73 pSHPathPrepareForWriteW = (void*)GetProcAddress(hshell32, "SHPathPrepareForWriteW");
76 /* creates a file with the specified name for tests */
77 static void createTestFile(const CHAR *name)
79 HANDLE file;
80 DWORD written;
82 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
83 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
84 WriteFile(file, name, strlen(name), &written, NULL);
85 WriteFile(file, "\n", strlen("\n"), &written, NULL);
86 CloseHandle(file);
89 static void createTestFileW(const WCHAR *name)
91 HANDLE file;
93 file = CreateFileW(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
94 ok(file != INVALID_HANDLE_VALUE, "Failure to open file\n");
95 CloseHandle(file);
98 static BOOL file_exists(const CHAR *name)
100 return GetFileAttributesA(name) != INVALID_FILE_ATTRIBUTES;
103 static BOOL dir_exists(const CHAR *name)
105 DWORD attr;
106 BOOL dir;
108 attr = GetFileAttributesA(name);
109 dir = ((attr & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY);
111 return ((attr != INVALID_FILE_ATTRIBUTES) && dir);
114 static BOOL file_existsW(LPCWSTR name)
116 return GetFileAttributesW(name) != INVALID_FILE_ATTRIBUTES;
119 static BOOL file_has_content(const CHAR *name, const CHAR *content)
121 CHAR buf[MAX_PATH];
122 HANDLE file;
123 DWORD read;
125 file = CreateFileA(name, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
126 if (file == INVALID_HANDLE_VALUE)
127 return FALSE;
128 ReadFile(file, buf, MAX_PATH - 1, &read, NULL);
129 buf[read] = 0;
130 CloseHandle(file);
131 return strcmp(buf, content)==0;
134 /* initializes the tests */
135 static void init_shfo_tests(void)
137 int len;
139 GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
140 len = lstrlenA(CURR_DIR);
142 if(len && (CURR_DIR[len-1] == '\\'))
143 CURR_DIR[len-1] = 0;
145 createTestFile("test1.txt");
146 createTestFile("test2.txt");
147 createTestFile("test3.txt");
148 createTestFile("test_5.txt");
149 CreateDirectoryA("test4.txt", NULL);
150 CreateDirectoryA("testdir2", NULL);
151 CreateDirectoryA("testdir2\\nested", NULL);
152 createTestFile("testdir2\\one.txt");
153 createTestFile("testdir2\\nested\\two.txt");
156 /* cleans after tests */
157 static void clean_after_shfo_tests(void)
159 DeleteFileA("test1.txt");
160 DeleteFileA("test2.txt");
161 DeleteFileA("test3.txt");
162 DeleteFileA("test_5.txt");
163 DeleteFileA("one.txt");
164 DeleteFileA("test4.txt\\test1.txt");
165 DeleteFileA("test4.txt\\test2.txt");
166 DeleteFileA("test4.txt\\test3.txt");
167 DeleteFileA("test4.txt\\one.txt");
168 DeleteFileA("test4.txt\\nested\\two.txt");
169 RemoveDirectoryA("test4.txt\\nested");
170 RemoveDirectoryA("test4.txt");
171 DeleteFileA("testdir2\\one.txt");
172 DeleteFileA("testdir2\\test1.txt");
173 DeleteFileA("testdir2\\test2.txt");
174 DeleteFileA("testdir2\\test3.txt");
175 DeleteFileA("testdir2\\test4.txt\\test1.txt");
176 DeleteFileA("testdir2\\nested\\two.txt");
177 RemoveDirectoryA("testdir2\\test4.txt");
178 RemoveDirectoryA("testdir2\\nested");
179 RemoveDirectoryA("testdir2");
180 RemoveDirectoryA("c:\\testdir3");
181 DeleteFileA("nonexistent\\notreal\\test2.txt");
182 RemoveDirectoryA("nonexistent\\notreal");
183 RemoveDirectoryA("nonexistent");
187 static void test_get_file_info(void)
189 DWORD rc, rc2;
190 SHFILEINFOA shfi, shfi2;
191 SHFILEINFOW shfiw;
192 char notepad[MAX_PATH];
194 /* Test whether fields of SHFILEINFOA are always cleared */
195 memset(&shfi, 0xcf, sizeof(shfi));
196 rc=SHGetFileInfoA("", 0, &shfi, sizeof(shfi), 0);
197 ok(rc == 1, "SHGetFileInfoA('' | 0) should return 1, got 0x%x\n", rc);
198 todo_wine ok(shfi.hIcon == 0, "SHGetFileInfoA('' | 0) did not clear hIcon\n");
199 todo_wine ok(shfi.szDisplayName[0] == 0, "SHGetFileInfoA('' | 0) did not clear szDisplayName[0]\n");
200 todo_wine ok(shfi.szTypeName[0] == 0, "SHGetFileInfoA('' | 0) did not clear szTypeName[0]\n");
201 ok(shfi.iIcon == 0xcfcfcfcf ||
202 broken(shfi.iIcon != 0xcfcfcfcf), /* NT4 doesn't clear but sets this field */
203 "SHGetFileInfoA('' | 0) should not clear iIcon\n");
204 ok(shfi.dwAttributes == 0xcfcfcfcf ||
205 broken(shfi.dwAttributes != 0xcfcfcfcf), /* NT4 doesn't clear but sets this field */
206 "SHGetFileInfoA('' | 0) should not clear dwAttributes\n");
208 if (pSHGetFileInfoW)
210 HANDLE unset_icon;
211 /* Test whether fields of SHFILEINFOW are always cleared */
212 memset(&shfiw, 0xcf, sizeof(shfiw));
213 memset(&unset_icon, 0xcf, sizeof(unset_icon));
214 rc=pSHGetFileInfoW(NULL, 0, &shfiw, sizeof(shfiw), 0);
215 ok(!rc, "SHGetFileInfoW(NULL | 0) should fail\n");
216 ok(shfiw.hIcon == unset_icon, "SHGetFileInfoW(NULL | 0) should not clear hIcon\n");
217 ok(shfiw.szDisplayName[0] == 0xcfcf, "SHGetFileInfoW(NULL | 0) should not clear szDisplayName[0]\n");
218 ok(shfiw.szTypeName[0] == 0xcfcf, "SHGetFileInfoW(NULL | 0) should not clear szTypeName[0]\n");
219 ok(shfiw.iIcon == 0xcfcfcfcf, "SHGetFileInfoW(NULL | 0) should not clear iIcon\n");
220 ok(shfiw.dwAttributes == 0xcfcfcfcf, "SHGetFileInfoW(NULL | 0) should not clear dwAttributes\n");
222 else
223 win_skip("SHGetFileInfoW is not available\n");
226 /* Test some flag combinations that MSDN claims are not allowed,
227 * but which work anyway
229 memset(&shfi, 0xcf, sizeof(shfi));
230 rc=SHGetFileInfoA("c:\\nonexistent", FILE_ATTRIBUTE_DIRECTORY,
231 &shfi, sizeof(shfi),
232 SHGFI_ATTRIBUTES | SHGFI_USEFILEATTRIBUTES);
233 ok(rc == 1, "SHGetFileInfoA(c:\\nonexistent | SHGFI_ATTRIBUTES) should return 1, got 0x%x\n", rc);
234 if (rc)
235 ok(shfi.dwAttributes != 0xcfcfcfcf, "dwFileAttributes is not set\n");
236 todo_wine ok(shfi.hIcon == 0, "SHGetFileInfoA(c:\\nonexistent | SHGFI_ATTRIBUTES) did not clear hIcon\n");
237 todo_wine ok(shfi.szDisplayName[0] == 0, "SHGetFileInfoA(c:\\nonexistent | SHGFI_ATTRIBUTES) did not clear szDisplayName[0]\n");
238 todo_wine ok(shfi.szTypeName[0] == 0, "SHGetFileInfoA(c:\\nonexistent | SHGFI_ATTRIBUTES) did not clear szTypeName[0]\n");
239 ok(shfi.iIcon == 0xcfcfcfcf ||
240 broken(shfi.iIcon != 0xcfcfcfcf), /* NT4 doesn't clear but sets this field */
241 "SHGetFileInfoA(c:\\nonexistent | SHGFI_ATTRIBUTES) should not clear iIcon\n");
243 rc=SHGetFileInfoA("c:\\nonexistent", FILE_ATTRIBUTE_DIRECTORY,
244 &shfi, sizeof(shfi),
245 SHGFI_EXETYPE | SHGFI_USEFILEATTRIBUTES);
246 todo_wine ok(rc == 1, "SHGetFileInfoA(c:\\nonexistent | SHGFI_EXETYPE) should return 1, got 0x%x\n", rc);
248 /* Test SHGFI_USEFILEATTRIBUTES support */
249 strcpy(shfi.szDisplayName, "dummy");
250 shfi.iIcon=0xdeadbeef;
251 rc=SHGetFileInfoA("c:\\nonexistent", FILE_ATTRIBUTE_DIRECTORY,
252 &shfi, sizeof(shfi),
253 SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
254 ok(rc == 1, "SHGetFileInfoA(c:\\nonexistent) should return 1, got 0x%x\n", rc);
255 if (rc)
257 ok(strcmp(shfi.szDisplayName, "dummy"), "SHGetFileInfoA(c:\\nonexistent) displayname is not set\n");
258 ok(shfi.iIcon != 0xdeadbeef, "SHGetFileInfoA(c:\\nonexistent) iIcon is not set\n");
261 /* Wine does not have a default icon for text files, and Windows 98 fails
262 * if we give it an empty executable. So use notepad.exe as the test
264 if (SearchPathA(NULL, "notepad.exe", NULL, sizeof(notepad), notepad, NULL))
266 strcpy(shfi.szDisplayName, "dummy");
267 shfi.iIcon=0xdeadbeef;
268 rc=SHGetFileInfoA(notepad, GetFileAttributesA(notepad),
269 &shfi, sizeof(shfi),
270 SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
271 ok(rc == 1, "SHGetFileInfoA(%s, SHGFI_USEFILEATTRIBUTES) should return 1, got 0x%x\n", notepad, rc);
272 strcpy(shfi2.szDisplayName, "dummy");
273 shfi2.iIcon=0xdeadbeef;
274 rc2=SHGetFileInfoA(notepad, 0,
275 &shfi2, sizeof(shfi2),
276 SHGFI_ICONLOCATION);
277 ok(rc2 == 1, "SHGetFileInfoA(%s) failed %x\n", notepad, rc2);
278 if (rc && rc2)
280 ok(lstrcmpiA(shfi2.szDisplayName, shfi.szDisplayName) == 0, "wrong display name %s != %s\n", shfi.szDisplayName, shfi2.szDisplayName);
281 ok(shfi2.iIcon == shfi.iIcon, "wrong icon index %d != %d\n", shfi.iIcon, shfi2.iIcon);
285 /* with a directory now */
286 strcpy(shfi.szDisplayName, "dummy");
287 shfi.iIcon=0xdeadbeef;
288 rc=SHGetFileInfoA("test4.txt", GetFileAttributesA("test4.txt"),
289 &shfi, sizeof(shfi),
290 SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
291 ok(rc == 1, "SHGetFileInfoA(test4.txt/, SHGFI_USEFILEATTRIBUTES) should return 1, got 0x%x\n", rc);
292 strcpy(shfi2.szDisplayName, "dummy");
293 shfi2.iIcon=0xdeadbeef;
294 rc2=SHGetFileInfoA("test4.txt", 0,
295 &shfi2, sizeof(shfi2),
296 SHGFI_ICONLOCATION);
297 ok(rc2 == 1, "SHGetFileInfoA(test4.txt/) should return 1, got 0x%x\n", rc2);
298 if (rc && rc2)
300 ok(lstrcmpiA(shfi2.szDisplayName, shfi.szDisplayName) == 0, "wrong display name %s != %s\n", shfi.szDisplayName, shfi2.szDisplayName);
301 ok(shfi2.iIcon == shfi.iIcon, "wrong icon index %d != %d\n", shfi.iIcon, shfi2.iIcon);
303 /* with drive root directory */
304 strcpy(shfi.szDisplayName, "dummy");
305 strcpy(shfi.szTypeName, "dummy");
306 shfi.hIcon=(HICON) 0xdeadbeef;
307 shfi.iIcon=0xdeadbeef;
308 shfi.dwAttributes=0xdeadbeef;
309 rc=SHGetFileInfoA("c:\\", 0, &shfi, sizeof(shfi),
310 SHGFI_TYPENAME | SHGFI_DISPLAYNAME | SHGFI_ICON | SHGFI_SMALLICON);
311 ok(rc == 1, "SHGetFileInfoA(c:\\) should return 1, got 0x%x\n", rc);
312 ok(strcmp(shfi.szDisplayName, "dummy") != 0, "display name was expected to change\n");
313 ok(strcmp(shfi.szTypeName, "dummy") != 0, "type name was expected to change\n");
314 ok(shfi.hIcon != (HICON) 0xdeadbeef, "hIcon was expected to change\n");
315 ok(shfi.iIcon != 0xdeadbeef, "iIcon was expected to change\n");
318 static void test_get_file_info_iconlist(void)
320 /* Test retrieving a handle to the system image list, and
321 * what that returns for hIcon
323 HRESULT hr;
324 HIMAGELIST hSysImageList;
325 LPITEMIDLIST pidList;
326 SHFILEINFOA shInfoa;
327 SHFILEINFOW shInfow;
329 hr = SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidList);
330 if (FAILED(hr)) {
331 skip("can't get desktop pidl\n");
332 return;
335 memset(&shInfoa, 0xcf, sizeof(shInfoa));
336 hSysImageList = (HIMAGELIST) SHGetFileInfoA((const char *)pidList, 0,
337 &shInfoa, sizeof(shInfoa),
338 SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_PIDL);
339 ok((hSysImageList != INVALID_HANDLE_VALUE) && (hSysImageList > (HIMAGELIST) 0xffff), "Can't get handle for CSIDL_DESKTOP imagelist\n");
340 todo_wine ok(shInfoa.hIcon == 0, "SHGetFileInfoA(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) did not clear hIcon\n");
341 todo_wine ok(shInfoa.szTypeName[0] == 0, "SHGetFileInfoA(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) did not clear szTypeName[0]\n");
342 ok(shInfoa.iIcon != 0xcfcfcfcf, "SHGetFileInfoA(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) should set iIcon\n");
343 ok(shInfoa.dwAttributes == 0xcfcfcfcf ||
344 shInfoa.dwAttributes == 0 || /* Vista */
345 broken(shInfoa.dwAttributes != 0xcfcfcfcf), /* NT4 doesn't clear but sets this field */
346 "SHGetFileInfoA(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL), unexpected dwAttributes\n");
347 CloseHandle(hSysImageList);
349 if (!pSHGetFileInfoW)
351 win_skip("SHGetFileInfoW is not available\n");
352 ILFree(pidList);
353 return;
356 memset(&shInfow, 0xcf, sizeof(shInfow));
357 hSysImageList = (HIMAGELIST) pSHGetFileInfoW((const WCHAR *)pidList, 0,
358 &shInfow, sizeof(shInfow),
359 SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_PIDL);
360 if (!hSysImageList)
362 win_skip("SHGetFileInfoW is not implemented\n");
363 return;
365 ok((hSysImageList != INVALID_HANDLE_VALUE) && (hSysImageList > (HIMAGELIST) 0xffff), "Can't get handle for CSIDL_DESKTOP imagelist\n");
366 todo_wine ok(shInfow.hIcon == 0, "SHGetFileInfoW(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) did not clear hIcon\n");
367 ok(shInfow.szTypeName[0] == 0, "SHGetFileInfoW(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) did not clear szTypeName[0]\n");
368 ok(shInfow.iIcon != 0xcfcfcfcf, "SHGetFileInfoW(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) should set iIcon\n");
369 ok(shInfow.dwAttributes == 0xcfcfcfcf ||
370 shInfoa.dwAttributes == 0, /* Vista */
371 "SHGetFileInfoW(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) unexpected dwAttributes\n");
372 CloseHandle(hSysImageList);
374 /* Various suposidly invalid flag testing */
375 memset(&shInfow, 0xcf, sizeof(shInfow));
376 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
377 SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON);
378 ok(hr != 0, "SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON Failed\n");
379 ok(shInfow.iIcon!=0xcfcfcfcf, "Icon Index Missing\n");
380 ok(shInfow.dwAttributes==0xcfcfcfcf ||
381 shInfoa.dwAttributes==0, /* Vista */
382 "unexpected dwAttributes\n");
384 memset(&shInfow, 0xcf, sizeof(shInfow));
385 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
386 SHGFI_ICON|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON);
387 ok(hr != 0, " SHGFI_ICON|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON Failed\n");
388 ok(shInfow.iIcon!=0xcfcfcfcf, "Icon Index Missing\n");
389 ok(shInfow.hIcon!=(HICON)0xcfcfcfcf && shInfow.hIcon!=0,"hIcon invalid\n");
390 if (shInfow.hIcon!=(HICON)0xcfcfcfcf) DestroyIcon(shInfow.hIcon);
391 todo_wine ok(shInfow.dwAttributes==0,"dwAttributes not set\n");
393 memset(&shInfow, 0xcf, sizeof(shInfow));
394 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
395 SHGFI_ICON|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_LARGEICON);
396 ok(hr != 0, "SHGFI_ICON|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_LARGEICON Failed\n");
397 ok(shInfow.iIcon!=0xcfcfcfcf, "Icon Index Missing\n");
398 ok(shInfow.hIcon!=(HICON)0xcfcfcfcf && shInfow.hIcon!=0,"hIcon invalid\n");
399 if (shInfow.hIcon != (HICON)0xcfcfcfcf) DestroyIcon(shInfow.hIcon);
400 todo_wine ok(shInfow.dwAttributes==0,"dwAttributes not set\n");
402 memset(&shInfow, 0xcf, sizeof(shInfow));
403 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
404 SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_LARGEICON);
405 ok(hr != 0, "SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_LARGEICON Failed\n");
406 ok(shInfow.iIcon!=0xcfcfcfcf, "Icon Index Missing\n");
407 ok(shInfow.dwAttributes==0xcfcfcfcf ||
408 shInfoa.dwAttributes==0, /* Vista */
409 "unexpected dwAttributes\n");
411 memset(&shInfow, 0xcf, sizeof(shInfow));
412 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
413 SHGFI_OPENICON|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON);
414 ok(hr != 0, "SHGFI_OPENICON|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON Failed\n");
415 todo_wine ok(shInfow.iIcon==0xcfcfcfcf, "Icon Index Modified\n");
416 ok(shInfow.dwAttributes==0xcfcfcfcf,"dwAttributes modified\n");
418 memset(&shInfow, 0xcf, sizeof(shInfow));
419 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
420 SHGFI_SHELLICONSIZE|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON);
421 ok(hr != 0, "SHGFI_SHELLICONSIZE|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON Failed\n");
422 todo_wine ok(shInfow.iIcon==0xcfcfcfcf, "Icon Index Modified\n");
423 ok(shInfow.dwAttributes==0xcfcfcfcf,"dwAttributes modified\n");
425 memset(&shInfow, 0xcf, sizeof(shInfow));
426 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
427 SHGFI_SHELLICONSIZE|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON);
428 ok(hr != 0, "SHGFI_SHELLICONSIZE|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON Failed\n");
429 todo_wine ok(shInfow.iIcon==0xcfcfcfcf, "Icon Index Modified\n");
430 ok(shInfow.dwAttributes==0xcfcfcfcf,"dwAttributes modified\n");
432 memset(&shInfow, 0xcf, sizeof(shInfow));
433 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
434 SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|
435 SHGFI_ATTRIBUTES);
436 ok(hr != 0, "SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|SHGFI_ATTRIBUTES Failed\n");
437 ok(shInfow.iIcon!=0xcfcfcfcf, "Icon Index Missing\n");
438 ok(shInfow.dwAttributes!=0xcfcfcfcf,"dwAttributes not set\n");
440 memset(&shInfow, 0xcf, sizeof(shInfow));
441 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
442 SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|
443 SHGFI_EXETYPE);
444 todo_wine ok(hr != 0, "SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|SHGFI_EXETYPE Failed\n");
445 ok(shInfow.iIcon!=0xcfcfcfcf, "Icon Index Missing\n");
446 ok(shInfow.dwAttributes==0xcfcfcfcf ||
447 shInfoa.dwAttributes==0, /* Vista */
448 "unexpected dwAttributes\n");
450 memset(&shInfow, 0xcf, sizeof(shInfow));
451 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
452 SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|SHGFI_EXETYPE);
453 todo_wine ok(hr != 0, "SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|SHGFI_EXETYPE Failed\n");
454 todo_wine ok(shInfow.iIcon==0xcfcfcfcf, "Icon Index Modified\n");
455 ok(shInfow.dwAttributes==0xcfcfcfcf,"dwAttributes modified\n");
457 memset(&shInfow, 0xcf, sizeof(shInfow));
458 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
459 SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|SHGFI_ATTRIBUTES);
460 ok(hr != 0, "SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|SHGFI_ATTRIBUTES Failed\n");
461 todo_wine ok(shInfow.iIcon==0xcfcfcfcf, "Icon Index Modified\n");
462 ok(shInfow.dwAttributes!=0xcfcfcfcf,"dwAttributes not set\n");
464 memset(&shInfow, 0xcf, sizeof(shInfow));
465 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
466 SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|
467 SHGFI_ATTRIBUTES);
468 ok(hr != 0, "SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_ATTRIBUTES Failed\n");
469 ok(shInfow.iIcon!=0xcfcfcfcf, "Icon Index Missing\n");
470 ok(shInfow.dwAttributes!=0xcfcfcfcf,"dwAttributes not set\n");
472 memset(&shInfow, 0xcf, sizeof(shInfow));
473 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
474 SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_EXETYPE);
475 todo_wine ok(hr != 0, "SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_EXETYPE Failed\n");
476 ok(shInfow.iIcon!=0xcfcfcfcf, "Icon Index Missing\n");
477 ok(shInfow.dwAttributes==0xcfcfcfcf ||
478 shInfoa.dwAttributes==0, /* Vista */
479 "unexpected dwAttributes\n");
481 memset(&shInfow, 0xcf, sizeof(shInfow));
482 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
483 SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_EXETYPE);
484 todo_wine ok(hr != 0, "SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_EXETYPE Failed\n");
485 todo_wine ok(shInfow.iIcon==0xcfcfcfcf, "Icon Index Modified\n");
486 ok(shInfow.dwAttributes==0xcfcfcfcf,"dwAttributes modified\n");
488 memset(&shInfow, 0xcf, sizeof(shInfow));
489 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
490 SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_ATTRIBUTES);
491 ok(hr != 0, "SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_ATTRIBUTES Failed\n");
492 todo_wine ok(shInfow.iIcon==0xcfcfcfcf, "Icon Index Modified\n");
493 ok(shInfow.dwAttributes!=0xcfcfcfcf,"dwAttributes not set\n");
495 ILFree(pidList);
500 puts into the specified buffer file names with current directory.
501 files - string with file names, separated by null characters. Ends on a double
502 null characters
504 static void set_curr_dir_path(CHAR *buf, const CHAR* files)
506 buf[0] = 0;
507 while (files[0])
509 strcpy(buf, CURR_DIR);
510 buf += strlen(buf);
511 buf[0] = '\\';
512 buf++;
513 strcpy(buf, files);
514 buf += strlen(buf) + 1;
515 files += strlen(files) + 1;
517 buf[0] = 0;
521 /* tests the FO_DELETE action */
522 static void test_delete(void)
524 SHFILEOPSTRUCTA shfo;
525 DWORD ret;
526 CHAR buf[sizeof(CURR_DIR)+sizeof("/test?.txt")+1];
528 sprintf(buf, "%s\\%s", CURR_DIR, "test?.txt");
529 buf[strlen(buf) + 1] = '\0';
531 shfo.hwnd = NULL;
532 shfo.wFunc = FO_DELETE;
533 shfo.pFrom = buf;
534 shfo.pTo = NULL;
535 shfo.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_SILENT;
536 shfo.hNameMappings = NULL;
537 shfo.lpszProgressTitle = NULL;
539 ok(!SHFileOperationA(&shfo), "Deletion was not successful\n");
540 ok(dir_exists("test4.txt"), "Directory should not have been removed\n");
541 ok(!file_exists("test1.txt"), "File should have been removed\n");
542 ok(!file_exists("test2.txt"), "File should have been removed\n");
543 ok(!file_exists("test3.txt"), "File should have been removed\n");
545 ret = SHFileOperationA(&shfo);
546 ok(ret == ERROR_SUCCESS, "Directory exists, but is not removed, ret=%d\n", ret);
547 ok(dir_exists("test4.txt"), "Directory should not have been removed\n");
549 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
551 ok(!SHFileOperationA(&shfo), "Directory is not removed\n");
552 ok(!dir_exists("test4.txt"), "Directory should have been removed\n");
554 ret = SHFileOperationA(&shfo);
555 ok(!ret, "The requested file does not exist, ret=%d\n", ret);
557 init_shfo_tests();
558 sprintf(buf, "%s\\%s", CURR_DIR, "test4.txt");
559 buf[strlen(buf) + 1] = '\0';
560 ok(MoveFileA("test1.txt", "test4.txt\\test1.txt"), "Filling the subdirectory failed\n");
561 ok(!SHFileOperationA(&shfo), "Directory is not removed\n");
562 ok(!dir_exists("test4.txt"), "Directory is not removed\n");
564 init_shfo_tests();
565 shfo.pFrom = "test1.txt\0test4.txt\0";
566 ok(!SHFileOperationA(&shfo), "Directory and a file are not removed\n");
567 ok(!file_exists("test1.txt"), "The file should have been removed\n");
568 ok(!dir_exists("test4.txt"), "Directory should have been removed\n");
569 ok(file_exists("test2.txt"), "This file should not have been removed\n");
571 /* FOF_FILESONLY does not delete a dir matching a wildcard */
572 init_shfo_tests();
573 shfo.fFlags |= FOF_FILESONLY;
574 shfo.pFrom = "*.txt\0";
575 ok(!SHFileOperationA(&shfo), "Failed to delete files\n");
576 ok(!file_exists("test1.txt"), "test1.txt should have been removed\n");
577 ok(!file_exists("test_5.txt"), "test_5.txt should have been removed\n");
578 ok(dir_exists("test4.txt"), "test4.txt should not have been removed\n");
580 /* FOF_FILESONLY only deletes a dir if explicitly specified */
581 init_shfo_tests();
582 shfo.pFrom = "test_?.txt\0test4.txt\0";
583 ok(!SHFileOperationA(&shfo), "Failed to delete files and directory\n");
584 ok(!dir_exists("test4.txt") ||
585 broken(dir_exists("test4.txt")), /* NT4 */
586 "test4.txt should have been removed\n");
587 ok(!file_exists("test_5.txt"), "test_5.txt should have been removed\n");
588 ok(file_exists("test1.txt"), "test1.txt should not have been removed\n");
590 /* try to delete an invalid filename */
591 if (0) {
592 /* this crashes on win9x */
593 init_shfo_tests();
594 shfo.pFrom = "\0";
595 shfo.fFlags &= ~FOF_FILESONLY;
596 shfo.fAnyOperationsAborted = FALSE;
597 ret = SHFileOperationA(&shfo);
598 ok(ret == ERROR_ACCESS_DENIED, "Expected ERROR_ACCESS_DENIED, got %d\n", ret);
599 ok(!shfo.fAnyOperationsAborted, "Expected no aborted operations\n");
600 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
603 /* try an invalid function */
604 init_shfo_tests();
605 shfo.pFrom = "test1.txt\0";
606 shfo.wFunc = 0;
607 ret = SHFileOperationA(&shfo);
608 ok(ret == ERROR_INVALID_PARAMETER ||
609 broken(ret == ERROR_SUCCESS), /* Win9x, NT4 */
610 "Expected ERROR_INVALID_PARAMETER, got %d\n", ret);
611 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
613 /* try an invalid list, only one null terminator */
614 if (0) {
615 /* this crashes on win9x */
616 init_shfo_tests();
617 shfo.pFrom = "";
618 shfo.wFunc = FO_DELETE;
619 ret = SHFileOperationA(&shfo);
620 ok(ret == ERROR_ACCESS_DENIED, "Expected ERROR_ACCESS_DENIED, got %d\n", ret);
621 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
624 /* delete a nonexistent file */
625 shfo.pFrom = "nonexistent.txt\0";
626 shfo.wFunc = FO_DELETE;
627 ret = SHFileOperationA(&shfo);
628 ok(ret == 1026 ||
629 ret == ERROR_FILE_NOT_FOUND || /* Vista */
630 broken(ret == ERROR_SUCCESS), /* NT4 */
631 "Expected 1026 or ERROR_FILE_NOT_FOUND, got %d\n", ret);
633 /* delete a dir, and then a file inside the dir, same as
634 * deleting a nonexistent file
636 if (ret != ERROR_FILE_NOT_FOUND)
638 /* Vista would throw up a dialog box that we can't suppress */
639 init_shfo_tests();
640 shfo.pFrom = "testdir2\0testdir2\\one.txt\0";
641 ret = SHFileOperationA(&shfo);
642 ok(ret == ERROR_PATH_NOT_FOUND ||
643 broken(ret == ERROR_SUCCESS), /* NT4 */
644 "Expected ERROR_PATH_NOT_FOUND, got %d\n", ret);
645 ok(!dir_exists("testdir2"), "Expected testdir2 to not exist\n");
646 ok(!file_exists("testdir2\\one.txt"), "Expected testdir2\\one.txt to not exist\n");
648 else
649 skip("Test would show a dialog box\n");
651 /* delete an existent file and a nonexistent file */
652 init_shfo_tests();
653 shfo.pFrom = "test1.txt\0nonexistent.txt\0test2.txt\0";
654 shfo.wFunc = FO_DELETE;
655 ret = SHFileOperationA(&shfo);
656 ok(ret == 1026 ||
657 ret == ERROR_FILE_NOT_FOUND || /* Vista */
658 broken(ret == ERROR_SUCCESS), /* NT4 */
659 "Expected 1026 or ERROR_FILE_NOT_FOUND, got %d\n", ret);
660 todo_wine
661 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
662 ok(file_exists("test2.txt"), "Expected test2.txt to exist\n");
664 /* delete a nonexistent file in an existent dir or a nonexistent dir */
665 init_shfo_tests();
666 shfo.pFrom = "testdir2\\nonexistent.txt\0";
667 ret = SHFileOperationA(&shfo);
668 ok(ret == ERROR_FILE_NOT_FOUND || /* Vista */
669 broken(ret == 0x402) || /* XP */
670 broken(ret == ERROR_SUCCESS), /* NT4 */
671 "Expected 0x402 or ERROR_FILE_NOT_FOUND, got %x\n", ret);
672 shfo.pFrom = "nonexistent\\one.txt\0";
673 ret = SHFileOperationA(&shfo);
674 ok(ret == DE_INVALIDFILES || /* Vista or later */
675 broken(ret == 0x402), /* XP */
676 "Expected 0x402 or DE_INVALIDFILES, got %x\n", ret);
678 /* try the FOF_NORECURSION flag, continues deleting subdirs */
679 init_shfo_tests();
680 shfo.pFrom = "testdir2\0";
681 shfo.fFlags |= FOF_NORECURSION;
682 ret = SHFileOperationA(&shfo);
683 ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
684 ok(!file_exists("testdir2\\one.txt"), "Expected testdir2\\one.txt to not exist\n");
685 ok(!dir_exists("testdir2\\nested"), "Expected testdir2\\nested to not exist\n");
688 /* tests the FO_RENAME action */
689 static void test_rename(void)
691 SHFILEOPSTRUCTA shfo, shfo2;
692 CHAR from[5*MAX_PATH];
693 CHAR to[5*MAX_PATH];
694 DWORD retval;
696 shfo.hwnd = NULL;
697 shfo.wFunc = FO_RENAME;
698 shfo.pFrom = from;
699 shfo.pTo = to;
700 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
701 shfo.hNameMappings = NULL;
702 shfo.lpszProgressTitle = NULL;
704 set_curr_dir_path(from, "test1.txt\0");
705 set_curr_dir_path(to, "test4.txt\0");
706 retval = SHFileOperationA(&shfo);
707 ok(retval == ERROR_ALREADY_EXISTS ||
708 retval == DE_FILEDESTISFLD || /* Vista */
709 broken(retval == ERROR_INVALID_NAME), /* Win9x, NT4 */
710 "Expected ERROR_ALREADY_EXISTS or DE_FILEDESTISFLD, got %d\n", retval);
711 ok(file_exists("test1.txt"), "The file is renamed\n");
713 set_curr_dir_path(from, "test3.txt\0");
714 set_curr_dir_path(to, "test4.txt\\test1.txt\0");
715 retval = SHFileOperationA(&shfo);
716 if (retval == DE_DIFFDIR)
718 /* Vista and W2K8 (broken or new behavior ?) */
719 ok(!file_exists("test4.txt\\test1.txt"), "The file is renamed\n");
721 else
723 ok(retval == ERROR_SUCCESS, "File is renamed moving to other directory\n");
724 ok(file_exists("test4.txt\\test1.txt"), "The file is not renamed\n");
727 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
728 set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
729 retval = SHFileOperationA(&shfo);
730 ok(retval == ERROR_GEN_FAILURE ||
731 retval == DE_MANYSRC1DEST || /* Vista */
732 broken(retval == ERROR_SUCCESS), /* Win9x */
733 "Expected ERROR_GEN_FAILURE or DE_MANYSRC1DEST , got %d\n", retval);
734 ok(file_exists("test1.txt"), "The file is renamed - many files are specified\n");
736 memcpy(&shfo2, &shfo, sizeof(SHFILEOPSTRUCTA));
737 shfo2.fFlags |= FOF_MULTIDESTFILES;
739 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
740 set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
741 retval = SHFileOperationA(&shfo2);
742 ok(retval == ERROR_GEN_FAILURE ||
743 retval == DE_MANYSRC1DEST || /* Vista */
744 broken(retval == ERROR_SUCCESS), /* Win9x */
745 "Expected ERROR_GEN_FAILURE or DE_MANYSRC1DEST files, got %d\n", retval);
746 ok(file_exists("test1.txt"), "The file is not renamed - many files are specified\n");
748 set_curr_dir_path(from, "test1.txt\0");
749 set_curr_dir_path(to, "test6.txt\0");
750 retval = SHFileOperationA(&shfo);
751 ok(retval == ERROR_SUCCESS, "Rename file failed, retval = %d\n", retval);
752 ok(!file_exists("test1.txt"), "The file is not renamed\n");
753 ok(file_exists("test6.txt"), "The file is not renamed\n");
755 set_curr_dir_path(from, "test6.txt\0");
756 set_curr_dir_path(to, "test1.txt\0");
757 retval = SHFileOperationA(&shfo);
758 ok(retval == ERROR_SUCCESS, "Rename file back failed, retval = %d\n", retval);
760 set_curr_dir_path(from, "test4.txt\0");
761 set_curr_dir_path(to, "test6.txt\0");
762 retval = SHFileOperationA(&shfo);
763 ok(retval == ERROR_SUCCESS, "Rename dir failed, retval = %d\n", retval);
764 ok(!dir_exists("test4.txt"), "The dir is not renamed\n");
765 ok(dir_exists("test6.txt"), "The dir is not renamed\n");
767 set_curr_dir_path(from, "test6.txt\0");
768 set_curr_dir_path(to, "test4.txt\0");
769 retval = SHFileOperationA(&shfo);
770 ok(retval == ERROR_SUCCESS, "Rename dir back failed, retval = %d\n", retval);
771 ok(dir_exists("test4.txt"), "The dir is not renamed\n");
773 /* try to rename more than one file to a single file */
774 shfo.pFrom = "test1.txt\0test2.txt\0";
775 shfo.pTo = "a.txt\0";
776 retval = SHFileOperationA(&shfo);
777 ok(retval == ERROR_GEN_FAILURE ||
778 retval == DE_MANYSRC1DEST || /* Vista */
779 broken(retval == ERROR_SUCCESS), /* Win9x */
780 "Expected ERROR_GEN_FAILURE or DE_MANYSRC1DEST, got %d\n", retval);
781 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
782 ok(file_exists("test2.txt"), "Expected test2.txt to exist\n");
783 ok(!file_exists("a.txt"), "Expected a.txt to not exist\n");
785 /* pFrom doesn't exist */
786 shfo.pFrom = "idontexist\0";
787 shfo.pTo = "newfile\0";
788 retval = SHFileOperationA(&shfo);
789 ok(retval == 1026 ||
790 retval == ERROR_FILE_NOT_FOUND || /* Vista */
791 broken(retval == ERROR_SUCCESS), /* NT4 */
792 "Expected 1026 or ERROR_FILE_NOT_FOUND, got %d\n", retval);
793 ok(!file_exists("newfile"), "Expected newfile to not exist\n");
795 /* pTo already exist */
796 shfo.pFrom = "test1.txt\0";
797 shfo.pTo = "test2.txt\0";
798 if (old_shell32)
799 shfo.fFlags |= FOF_NOCONFIRMMKDIR;
800 retval = SHFileOperationA(&shfo);
801 if (retval == ERROR_SUCCESS)
803 /* Vista and W2K8 (broken or new behavior ?) */
804 createTestFile("test1.txt");
806 else
808 ok(retval == ERROR_ALREADY_EXISTS ||
809 broken(retval == DE_OPCANCELLED) || /* NT4 */
810 broken(retval == ERROR_INVALID_NAME), /* Win9x */
811 "Expected ERROR_ALREADY_EXISTS, got %d\n", retval);
814 /* pFrom is valid, but pTo is empty */
815 shfo.pFrom = "test1.txt\0";
816 shfo.pTo = "\0";
817 retval = SHFileOperationA(&shfo);
818 ok(retval == ERROR_CANCELLED ||
819 retval == DE_DIFFDIR || /* Vista */
820 broken(retval == DE_OPCANCELLED) || /* Win9x */
821 broken(retval == 65652), /* NT4 */
822 "Expected ERROR_CANCELLED or DE_DIFFDIR\n");
823 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
825 /* pFrom is empty */
826 shfo.pFrom = "\0";
827 retval = SHFileOperationA(&shfo);
828 ok(retval == ERROR_ACCESS_DENIED ||
829 retval == DE_MANYSRC1DEST || /* Vista */
830 broken(retval == ERROR_SUCCESS), /* Win9x */
831 "Expected ERROR_ACCESS_DENIED or DE_MANYSRC1DEST, got %d\n", retval);
833 /* pFrom is NULL, commented out because it crashes on nt 4.0 */
834 if (0)
836 shfo.pFrom = NULL;
837 retval = SHFileOperationA(&shfo);
838 ok(retval == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", retval);
842 /* tests the FO_COPY action */
843 static void test_copy(void)
845 SHFILEOPSTRUCTA shfo, shfo2;
846 CHAR from[5*MAX_PATH];
847 CHAR to[5*MAX_PATH];
848 FILEOP_FLAGS tmp_flags;
849 DWORD retval;
850 LPSTR ptr;
851 BOOL on_nt4 = FALSE;
852 BOOL ret;
854 if (old_shell32)
856 win_skip("Too many differences for old shell32\n");
857 return;
860 shfo.hwnd = NULL;
861 shfo.wFunc = FO_COPY;
862 shfo.pFrom = from;
863 shfo.pTo = to;
864 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
865 shfo.hNameMappings = NULL;
866 shfo.lpszProgressTitle = NULL;
868 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
869 set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
870 retval = SHFileOperationA(&shfo);
871 if (dir_exists("test6.txt"))
873 /* Vista and W2K8 (broken or new behavior ?) */
874 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
875 ok(DeleteFileA("test6.txt\\test1.txt"), "The file is not copied - many files "
876 "are specified as a target\n");
877 DeleteFileA("test6.txt\\test2.txt");
878 RemoveDirectoryA("test6.txt\\test4.txt");
879 RemoveDirectoryA("test6.txt");
881 else
883 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
884 ok(!file_exists("test6.txt"), "The file is copied - many files are "
885 "specified as a target\n");
888 memcpy(&shfo2, &shfo, sizeof(SHFILEOPSTRUCTA));
889 shfo2.fFlags |= FOF_MULTIDESTFILES;
891 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
892 set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
893 ok(!SHFileOperationA(&shfo2), "Can't copy many files\n");
894 ok(file_exists("test6.txt"), "The file is not copied - many files are "
895 "specified as a target\n");
896 DeleteFileA("test6.txt");
897 DeleteFileA("test7.txt");
898 RemoveDirectoryA("test8.txt");
900 /* number of sources does not correspond to number of targets */
901 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
902 set_curr_dir_path(to, "test6.txt\0test7.txt\0");
903 retval = SHFileOperationA(&shfo2);
904 if (dir_exists("test6.txt"))
906 /* Vista and W2K8 (broken or new behavior?) */
907 ok(retval == DE_DESTSAMETREE, "Expected DE_DESTSAMETREE, got %d\n", retval);
908 ok(DeleteFileA("test6.txt\\test1.txt"), "The file is not copied - many files "
909 "are specified as a target\n");
910 RemoveDirectoryA("test6.txt");
911 ok(DeleteFileA("test7.txt\\test2.txt"), "The file is not copied - many files "
912 "are specified as a target\n");
913 RemoveDirectoryA("test7.txt");
915 else
917 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
918 ok(!file_exists("test6.txt"), "The file is copied - many files are "
919 "specified as a target\n");
922 set_curr_dir_path(from, "test1.txt\0");
923 set_curr_dir_path(to, "test4.txt\0");
924 ok(!SHFileOperationA(&shfo), "Prepare test to check how directories are copied recursively\n");
925 ok(file_exists("test4.txt\\test1.txt"), "The file is copied\n");
927 set_curr_dir_path(from, "test?.txt\0");
928 set_curr_dir_path(to, "testdir2\0");
929 ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n");
930 ok(!file_exists("testdir2\\test4.txt"), "The directory is not copied yet\n");
931 ok(!SHFileOperationA(&shfo), "Files and directories are copied to directory\n");
932 ok(file_exists("testdir2\\test1.txt"), "The file is copied\n");
933 ok(file_exists("testdir2\\test4.txt"), "The directory is copied\n");
934 ok(file_exists("testdir2\\test4.txt\\test1.txt"), "The file in subdirectory is copied\n");
935 clean_after_shfo_tests();
937 init_shfo_tests();
938 shfo.fFlags |= FOF_FILESONLY;
939 ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n");
940 ok(!file_exists("testdir2\\test4.txt"), "The directory is not copied yet\n");
941 ok(!SHFileOperationA(&shfo), "Files are copied to other directory\n");
942 ok(file_exists("testdir2\\test1.txt"), "The file is copied\n");
943 ok(!file_exists("testdir2\\test4.txt"), "The directory is copied\n");
944 clean_after_shfo_tests();
946 init_shfo_tests();
947 set_curr_dir_path(from, "test1.txt\0test2.txt\0");
948 ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n");
949 ok(!file_exists("testdir2\\test2.txt"), "The file is not copied yet\n");
950 ok(!SHFileOperationA(&shfo), "Files are copied to other directory\n");
951 ok(file_exists("testdir2\\test1.txt"), "The file is copied\n");
952 ok(file_exists("testdir2\\test2.txt"), "The file is copied\n");
953 clean_after_shfo_tests();
955 /* Copying multiple files with one not existing as source, fails the
956 entire operation in Win98/ME/2K/XP, but not in 95/NT */
957 init_shfo_tests();
958 tmp_flags = shfo.fFlags;
959 set_curr_dir_path(from, "test1.txt\0test10.txt\0test2.txt\0");
960 ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n");
961 ok(!file_exists("testdir2\\test2.txt"), "The file is not copied yet\n");
962 retval = SHFileOperationA(&shfo);
963 if (retval == ERROR_SUCCESS)
964 /* Win 95/NT returns success but copies only the files up to the nonexistent source */
965 ok(file_exists("testdir2\\test1.txt"), "The file is not copied\n");
966 else
968 /* Failure if one source file does not exist */
969 ok(retval == 1026 || /* Win 98/ME/2K/XP */
970 retval == ERROR_FILE_NOT_FOUND, /* Vista and W2K8 */
971 "Files are copied to other directory\n");
972 ok(!file_exists("testdir2\\test1.txt"), "The file is copied\n");
974 ok(!file_exists("testdir2\\test2.txt"), "The file is copied\n");
975 shfo.fFlags = tmp_flags;
977 /* copy into a nonexistent directory */
978 init_shfo_tests();
979 shfo.fFlags = FOF_NOCONFIRMMKDIR;
980 set_curr_dir_path(from, "test1.txt\0");
981 set_curr_dir_path(to, "nonexistent\\notreal\\test2.txt\0");
982 retval= SHFileOperationA(&shfo);
983 ok(!retval, "Error copying into nonexistent directory\n");
984 ok(file_exists("nonexistent"), "nonexistent not created\n");
985 ok(file_exists("nonexistent\\notreal"), "nonexistent\\notreal not created\n");
986 ok(file_exists("nonexistent\\notreal\\test2.txt"), "Directory not created\n");
987 ok(!file_exists("nonexistent\\notreal\\test1.txt"), "test1.txt should not exist\n");
989 /* a relative dest directory is OK */
990 clean_after_shfo_tests();
991 init_shfo_tests();
992 shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0";
993 shfo.pTo = "testdir2\0";
994 retval = SHFileOperationA(&shfo);
995 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
996 ok(file_exists("testdir2\\test1.txt"), "Expected testdir2\\test1 to exist\n");
998 /* try to overwrite an existing write protected file */
999 clean_after_shfo_tests();
1000 init_shfo_tests();
1001 tmp_flags = shfo.fFlags;
1002 shfo.pFrom = "test1.txt\0";
1003 shfo.pTo = "test2.txt\0";
1004 /* suppress the error-dialog in win9x here */
1005 shfo.fFlags = FOF_NOERRORUI | FOF_NOCONFIRMATION | FOF_SILENT;
1006 ret = SetFileAttributesA(shfo.pTo, FILE_ATTRIBUTE_READONLY);
1007 ok(ret, "Failure to set file attributes (error %x)\n", GetLastError());
1008 retval = CopyFileA(shfo.pFrom, shfo.pTo, FALSE);
1009 ok(!retval && GetLastError() == ERROR_ACCESS_DENIED, "CopyFileA should have fail with ERROR_ACCESS_DENIED\n");
1010 retval = SHFileOperationA(&shfo);
1011 /* Does not work on Win95, Win95B, NT4WS and NT4SRV */
1012 ok(!retval || broken(retval == DE_OPCANCELLED), "SHFileOperationA failed to copy (error %x)\n", retval);
1013 /* Set back normal attributes to make the file deletion succeed */
1014 ret = SetFileAttributesA(shfo.pTo, FILE_ATTRIBUTE_NORMAL);
1015 ok(ret, "Failure to set file attributes (error %x)\n", GetLastError());
1016 shfo.fFlags = tmp_flags;
1018 /* try to copy files to a file */
1019 clean_after_shfo_tests();
1020 init_shfo_tests();
1021 shfo.pFrom = from;
1022 shfo.pTo = to;
1023 /* suppress the error-dialog in win9x here */
1024 shfo.fFlags |= FOF_NOERRORUI;
1025 set_curr_dir_path(from, "test1.txt\0test2.txt\0");
1026 set_curr_dir_path(to, "test3.txt\0");
1027 shfo.fAnyOperationsAborted = 0xdeadbeef;
1028 retval = SHFileOperationA(&shfo);
1029 ok(shfo.fAnyOperationsAborted != 0xdeadbeef ||
1030 broken(shfo.fAnyOperationsAborted == 0xdeadbeef), /* NT4 */
1031 "Expected TRUE/FALSE fAnyOperationsAborted not 0xdeadbeef\n");
1032 if (retval == DE_FLDDESTISFILE || /* Vista and W2K8 */
1033 retval == DE_INVALIDFILES) /* Win7 */
1035 /* Most likely new behavior */
1036 ok(!shfo.fAnyOperationsAborted, "Didn't expect aborted operations\n");
1038 else
1040 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
1041 ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n");
1043 ok(!file_exists("test3.txt\\test2.txt"), "Expected test3.txt\\test2.txt to not exist\n");
1045 /* try to copy many files to nonexistent directory */
1046 DeleteFileA(to);
1047 shfo.fFlags &= ~FOF_NOERRORUI;
1048 shfo.fAnyOperationsAborted = 0xdeadbeef;
1049 retval = SHFileOperationA(&shfo);
1050 ok(!shfo.fAnyOperationsAborted ||
1051 broken(shfo.fAnyOperationsAborted == 0xdeadbeef), /* NT4 */
1052 "Didn't expect aborted operations\n");
1053 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1054 ok(DeleteFileA("test3.txt\\test1.txt"), "Expected test3.txt\\test1.txt to exist\n");
1055 ok(DeleteFileA("test3.txt\\test2.txt"), "Expected test3.txt\\test1.txt to exist\n");
1056 ok(RemoveDirectoryA(to), "Expected test3.txt to exist\n");
1058 /* send in FOF_MULTIDESTFILES with too many destination files */
1059 init_shfo_tests();
1060 shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0";
1061 shfo.pTo = "testdir2\\a.txt\0testdir2\\b.txt\0testdir2\\c.txt\0testdir2\\d.txt\0";
1062 shfo.fFlags |= FOF_NOERRORUI | FOF_MULTIDESTFILES;
1063 shfo.fAnyOperationsAborted = 0xdeadbeef;
1064 retval = SHFileOperationA(&shfo);
1065 ok(shfo.fAnyOperationsAborted != 0xdeadbeef ||
1066 broken(shfo.fAnyOperationsAborted == 0xdeadbeef), /* NT4 */
1067 "Expected TRUE/FALSE fAnyOperationsAborted not 0xdeadbeef\n");
1068 if (dir_exists("testdir2\\a.txt"))
1070 /* Vista and W2K8 (broken or new behavior ?) */
1071 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1072 ok(!shfo.fAnyOperationsAborted, "Didn't expect aborted operations\n");
1073 ok(DeleteFileA("testdir2\\a.txt\\test1.txt"), "Expected testdir2\\a.txt\\test1.txt to exist\n");
1074 RemoveDirectoryA("testdir2\\a.txt");
1075 ok(DeleteFileA("testdir2\\b.txt\\test2.txt"), "Expected testdir2\\b.txt\\test2.txt to exist\n");
1076 RemoveDirectoryA("testdir2\\b.txt");
1077 ok(DeleteFileA("testdir2\\c.txt\\test3.txt"), "Expected testdir2\\c.txt\\test3.txt to exist\n");
1078 RemoveDirectoryA("testdir2\\c.txt");
1079 ok(!file_exists("testdir2\\d.txt"), "Expected testdir2\\d.txt to not exist\n");
1081 else
1083 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
1084 ok(shfo.fAnyOperationsAborted ||
1085 broken(!shfo.fAnyOperationsAborted), /* NT4 */
1086 "Expected aborted operations\n");
1087 ok(!file_exists("testdir2\\a.txt"), "Expected testdir2\\a.txt to not exist\n");
1090 /* send in FOF_MULTIDESTFILES with too many destination files */
1091 shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0";
1092 shfo.pTo = "e.txt\0f.txt\0";
1093 shfo.fAnyOperationsAborted = 0xdeadbeef;
1094 retval = SHFileOperationA(&shfo);
1095 ok(shfo.fAnyOperationsAborted != 0xdeadbeef ||
1096 broken(shfo.fAnyOperationsAborted == 0xdeadbeef), /* NT4 */
1097 "Expected TRUE/FALSE fAnyOperationsAborted not 0xdeadbeef\n");
1098 if (dir_exists("e.txt"))
1100 /* Vista and W2K8 (broken or new behavior ?) */
1101 ok(!shfo.fAnyOperationsAborted, "Didn't expect aborted operations\n");
1102 ok(retval == DE_SAMEFILE, "Expected DE_SAMEFILE, got %d\n", retval);
1103 ok(DeleteFileA("e.txt\\test1.txt"), "Expected e.txt\\test1.txt to exist\n");
1104 RemoveDirectoryA("e.txt");
1105 ok(DeleteFileA("f.txt\\test2.txt"), "Expected f.txt\\test2.txt to exist\n");
1106 RemoveDirectoryA("f.txt");
1108 else
1110 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
1111 ok(shfo.fAnyOperationsAborted ||
1112 broken(!shfo.fAnyOperationsAborted), /* NT4 */
1113 "Expected aborted operations\n");
1114 ok(!file_exists("e.txt"), "Expected e.txt to not exist\n");
1117 /* use FOF_MULTIDESTFILES with files and a source directory */
1118 shfo.pFrom = "test1.txt\0test2.txt\0test4.txt\0";
1119 shfo.pTo = "testdir2\\a.txt\0testdir2\\b.txt\0testdir2\\c.txt\0";
1120 shfo.fAnyOperationsAborted = 0xdeadbeef;
1121 retval = SHFileOperationA(&shfo);
1122 ok(!shfo.fAnyOperationsAborted ||
1123 broken(shfo.fAnyOperationsAborted == 0xdeadbeef), /* NT4 */
1124 "Didn't expect aborted operations\n");
1125 ok(retval == ERROR_SUCCESS ||
1126 broken(retval == 0x100a1), /* WinMe */
1127 "Expected ERROR_SUCCESS, got %d\n", retval);
1128 ok(DeleteFileA("testdir2\\a.txt"), "Expected testdir2\\a.txt to exist\n");
1129 ok(DeleteFileA("testdir2\\b.txt"), "Expected testdir2\\b.txt to exist\n");
1130 if (retval == ERROR_SUCCESS)
1131 ok(RemoveDirectoryA("testdir2\\c.txt"), "Expected testdir2\\c.txt to exist\n");
1133 /* try many dest files without FOF_MULTIDESTFILES flag */
1134 shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0";
1135 shfo.pTo = "a.txt\0b.txt\0c.txt\0";
1136 shfo.fAnyOperationsAborted = 0xdeadbeef;
1137 shfo.fFlags &= ~FOF_MULTIDESTFILES;
1138 retval = SHFileOperationA(&shfo);
1139 ok(shfo.fAnyOperationsAborted != 0xdeadbeef ||
1140 broken(shfo.fAnyOperationsAborted == 0xdeadbeef), /* NT4 */
1141 "Expected TRUE/FALSE fAnyOperationsAborted not 0xdeadbeef\n");
1142 if (dir_exists("a.txt"))
1144 /* Vista and W2K8 (broken or new behavior ?) */
1145 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1146 ok(!shfo.fAnyOperationsAborted, "Didn't expect aborted operations\n");
1147 ok(DeleteFileA("a.txt\\test1.txt"), "Expected a.txt\\test1.txt to exist\n");
1148 ok(DeleteFileA("a.txt\\test2.txt"), "Expected a.txt\\test2.txt to exist\n");
1149 ok(DeleteFileA("a.txt\\test3.txt"), "Expected a.txt\\test3.txt to exist\n");
1150 RemoveDirectoryA("a.txt");
1152 else
1155 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
1156 ok(shfo.fAnyOperationsAborted ||
1157 broken(!shfo.fAnyOperationsAborted), /* NT4 */
1158 "Expected aborted operations\n");
1159 ok(!file_exists("a.txt"), "Expected a.txt to not exist\n");
1162 /* try a glob */
1163 shfo.pFrom = "test?.txt\0";
1164 shfo.pTo = "testdir2\0";
1165 shfo.fFlags &= ~FOF_MULTIDESTFILES;
1166 retval = SHFileOperationA(&shfo);
1167 ok(retval == ERROR_SUCCESS ||
1168 broken(retval == 0x100a1), /* WinMe */
1169 "Expected ERROR_SUCCESS, got %d\n", retval);
1170 ok(file_exists("testdir2\\test1.txt"), "Expected testdir2\\test1.txt to exist\n");
1172 /* try a glob with FOF_FILESONLY */
1173 clean_after_shfo_tests();
1174 init_shfo_tests();
1175 shfo.pFrom = "test?.txt\0";
1176 shfo.fFlags |= FOF_FILESONLY;
1177 retval = SHFileOperationA(&shfo);
1178 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1179 ok(file_exists("testdir2\\test1.txt"), "Expected testdir2\\test1.txt to exist\n");
1180 ok(!dir_exists("testdir2\\test4.txt"), "Expected testdir2\\test4.txt to not exist\n");
1182 /* try a glob with FOF_MULTIDESTFILES and the same number
1183 * of dest files that we would expect
1185 clean_after_shfo_tests();
1186 init_shfo_tests();
1187 shfo.pTo = "testdir2\\a.txt\0testdir2\\b.txt\0testdir2\\c.txt\0testdir2\\d.txt\0";
1188 shfo.fFlags &= ~FOF_FILESONLY;
1189 shfo.fFlags |= FOF_MULTIDESTFILES;
1190 retval = SHFileOperationA(&shfo);
1191 if (dir_exists("testdir2\\a.txt"))
1193 /* Vista and W2K8 (broken or new behavior ?) */
1194 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1195 ok(DeleteFileA("testdir2\\a.txt\\test1.txt"), "Expected testdir2\\a.txt\\test1.txt to exist\n");
1196 ok(DeleteFileA("testdir2\\a.txt\\test2.txt"), "Expected testdir2\\a.txt\\test2.txt to exist\n");
1197 ok(DeleteFileA("testdir2\\a.txt\\test3.txt"), "Expected testdir2\\a.txt\\test3.txt to exist\n");
1198 ok(RemoveDirectoryA("testdir2\\a.txt\\test4.txt"), "Expected testdir2\\a.txt\\test4.txt to exist\n");
1199 RemoveDirectoryA("testdir2\\a.txt");
1201 else
1203 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
1204 ok(shfo.fAnyOperationsAborted ||
1205 broken(!shfo.fAnyOperationsAborted), /* NT4 */
1206 "Expected aborted operations\n");
1207 ok(!file_exists("testdir2\\a.txt"), "Expected testdir2\\test1.txt to not exist\n");
1209 ok(!RemoveDirectoryA("b.txt"), "b.txt should not exist\n");
1211 /* copy one file to two others, second is ignored */
1212 clean_after_shfo_tests();
1213 init_shfo_tests();
1214 shfo.pFrom = "test1.txt\0";
1215 shfo.pTo = "b.txt\0c.txt\0";
1216 shfo.fAnyOperationsAborted = 0xdeadbeef;
1217 retval = SHFileOperationA(&shfo);
1218 ok(!shfo.fAnyOperationsAborted ||
1219 broken(shfo.fAnyOperationsAborted == 0xdeadbeef), /* NT4 */
1220 "Didn't expect aborted operations\n");
1221 if (retval == DE_OPCANCELLED)
1223 /* NT4 fails and doesn't copy any files */
1224 ok(!file_exists("b.txt"), "Expected b.txt to not exist\n");
1225 /* Needed to skip some tests */
1226 win_skip("Skipping some tests on NT4\n");
1227 on_nt4 = TRUE;
1229 else
1231 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1232 ok(DeleteFileA("b.txt"), "Expected b.txt to exist\n");
1234 ok(!DeleteFileA("c.txt"), "Expected c.txt to not exist\n");
1236 /* copy two file to three others, all fail */
1237 shfo.pFrom = "test1.txt\0test2.txt\0";
1238 shfo.pTo = "b.txt\0c.txt\0d.txt\0";
1239 shfo.fAnyOperationsAborted = 0xdeadbeef;
1240 retval = SHFileOperationA(&shfo);
1241 if (dir_exists("b.txt"))
1243 /* Vista and W2K8 (broken or new behavior ?) */
1244 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1245 ok(!shfo.fAnyOperationsAborted, "Didn't expect aborted operations\n");
1246 ok(DeleteFileA("b.txt\\test1.txt"), "Expected b.txt\\test1.txt to exist\n");
1247 RemoveDirectoryA("b.txt");
1248 ok(DeleteFileA("c.txt\\test2.txt"), "Expected c.txt\\test2.txt to exist\n");
1249 RemoveDirectoryA("c.txt");
1251 else
1253 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
1254 ok(shfo.fAnyOperationsAborted ||
1255 broken(shfo.fAnyOperationsAborted == 0xdeadbeef), /* NT4 */
1256 "Expected aborted operations\n");
1257 ok(!DeleteFileA("b.txt"), "Expected b.txt to not exist\n");
1260 /* copy one file and one directory to three others */
1261 shfo.pFrom = "test1.txt\0test4.txt\0";
1262 shfo.pTo = "b.txt\0c.txt\0d.txt\0";
1263 shfo.fAnyOperationsAborted = 0xdeadbeef;
1264 retval = SHFileOperationA(&shfo);
1265 if (dir_exists("b.txt"))
1267 /* Vista and W2K8 (broken or new behavior ?) */
1268 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1269 ok(!shfo.fAnyOperationsAborted, "Didn't expect aborted operations\n");
1270 ok(DeleteFileA("b.txt\\test1.txt"), "Expected b.txt\\test1.txt to exist\n");
1271 RemoveDirectoryA("b.txt");
1272 ok(RemoveDirectoryA("c.txt\\test4.txt"), "Expected c.txt\\test4.txt to exist\n");
1273 RemoveDirectoryA("c.txt");
1275 else
1277 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
1278 ok(shfo.fAnyOperationsAborted ||
1279 broken(shfo.fAnyOperationsAborted == 0xdeadbeef), /* NT4 */
1280 "Expected aborted operations\n");
1281 ok(!DeleteFileA("b.txt"), "Expected b.txt to not exist\n");
1282 ok(!DeleteFileA("c.txt"), "Expected c.txt to not exist\n");
1285 /* copy a directory with a file beneath it, plus some files */
1286 createTestFile("test4.txt\\a.txt");
1287 shfo.pFrom = "test4.txt\0test1.txt\0";
1288 shfo.pTo = "testdir2\0";
1289 shfo.fFlags &= ~FOF_MULTIDESTFILES;
1290 shfo.fAnyOperationsAborted = FALSE;
1291 retval = SHFileOperationA(&shfo);
1292 ok(retval == ERROR_SUCCESS ||
1293 broken(retval == 0x100a1), /* WinMe */
1294 "Expected ERROR_SUCCESS, got %d\n", retval);
1295 if (retval == ERROR_SUCCESS)
1297 ok(DeleteFileA("testdir2\\test1.txt"), "Expected testdir2\\test1.txt to exist\n");
1298 ok(DeleteFileA("testdir2\\test4.txt\\a.txt"), "Expected a.txt to exist\n");
1299 ok(RemoveDirectoryA("testdir2\\test4.txt"), "Expected testdir2\\test4.txt to exist\n");
1302 /* copy one directory and a file in that dir to another dir */
1303 shfo.pFrom = "test4.txt\0test4.txt\\a.txt\0";
1304 shfo.pTo = "testdir2\0";
1305 retval = SHFileOperationA(&shfo);
1306 ok(retval == ERROR_SUCCESS ||
1307 broken(retval == 0x100a1), /* WinMe */
1308 "Expected ERROR_SUCCESS, got %d\n", retval);
1309 if (retval == ERROR_SUCCESS)
1311 ok(DeleteFileA("testdir2\\test4.txt\\a.txt"), "Expected a.txt to exist\n");
1312 ok(DeleteFileA("testdir2\\a.txt"), "Expected testdir2\\a.txt to exist\n");
1315 /* copy a file in a directory first, and then the directory to a nonexistent dir */
1316 shfo.pFrom = "test4.txt\\a.txt\0test4.txt\0";
1317 shfo.pTo = "nonexistent\0";
1318 retval = SHFileOperationA(&shfo);
1319 if (dir_exists("nonexistent"))
1321 /* Vista and W2K8 (broken or new behavior ?) */
1322 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1323 ok(DeleteFileA("nonexistent\\test4.txt\\a.txt"), "Expected nonexistent\\test4.txt\\a.txt to exist\n");
1324 RemoveDirectoryA("nonexistent\\test4.txt");
1325 ok(DeleteFileA("nonexistent\\a.txt"), "Expected nonexistent\\a.txt to exist\n");
1326 RemoveDirectoryA("nonexistent");
1328 else
1330 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
1331 ok(shfo.fAnyOperationsAborted ||
1332 broken(!shfo.fAnyOperationsAborted), /* NT4 */
1333 "Expected aborted operations\n");
1334 ok(!file_exists("nonexistent\\test4.txt"), "Expected nonexistent\\test4.txt to not exist\n");
1336 DeleteFileA("test4.txt\\a.txt");
1338 /* destination is same as source file */
1339 shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0";
1340 shfo.pTo = "b.txt\0test2.txt\0c.txt\0";
1341 shfo.fAnyOperationsAborted = FALSE;
1342 shfo.fFlags = FOF_NOERRORUI | FOF_MULTIDESTFILES;
1343 retval = SHFileOperationA(&shfo);
1344 if (retval == DE_OPCANCELLED)
1346 /* NT4 fails and doesn't copy any files */
1347 ok(!file_exists("b.txt"), "Expected b.txt to not exist\n");
1349 else
1351 ok(retval == DE_SAMEFILE, "Expected DE_SAMEFILE, got %d\n", retval);
1352 ok(DeleteFileA("b.txt"), "Expected b.txt to exist\n");
1354 ok(!shfo.fAnyOperationsAborted, "Expected no operations to be aborted\n");
1355 ok(!file_exists("c.txt"), "Expected c.txt to not exist\n");
1357 /* destination is same as source directory */
1358 shfo.pFrom = "test1.txt\0test4.txt\0test3.txt\0";
1359 shfo.pTo = "b.txt\0test4.txt\0c.txt\0";
1360 shfo.fAnyOperationsAborted = FALSE;
1361 retval = SHFileOperationA(&shfo);
1362 if (retval == DE_OPCANCELLED)
1364 /* NT4 fails and doesn't copy any files */
1365 ok(!file_exists("b.txt"), "Expected b.txt to not exist\n");
1367 else
1369 ok(retval == ERROR_SUCCESS ||
1370 retval == DE_DESTSAMETREE, /* Vista */
1371 "Expected ERROR_SUCCESS or DE_DESTSAMETREE, got %d\n", retval);
1372 ok(DeleteFileA("b.txt"), "Expected b.txt to exist\n");
1374 ok(!file_exists("c.txt"), "Expected c.txt to not exist\n");
1376 /* copy a directory into itself, error displayed in UI */
1377 shfo.pFrom = "test4.txt\0";
1378 shfo.pTo = "test4.txt\\newdir\0";
1379 shfo.fFlags &= ~FOF_MULTIDESTFILES;
1380 shfo.fAnyOperationsAborted = FALSE;
1381 retval = SHFileOperationA(&shfo);
1382 ok(retval == ERROR_SUCCESS ||
1383 retval == DE_DESTSUBTREE, /* Vista */
1384 "Expected ERROR_SUCCESS or DE_DESTSUBTREE, got %d\n", retval);
1385 ok(!RemoveDirectoryA("test4.txt\\newdir"), "Expected test4.txt\\newdir to not exist\n");
1387 /* copy a directory to itself, error displayed in UI */
1388 shfo.pFrom = "test4.txt\0";
1389 shfo.pTo = "test4.txt\0";
1390 shfo.fAnyOperationsAborted = FALSE;
1391 retval = SHFileOperationA(&shfo);
1392 ok(retval == ERROR_SUCCESS ||
1393 retval == DE_DESTSUBTREE, /* Vista */
1394 "Expected ERROR_SUCCESS or DE_DESTSUBTREE, got %d\n", retval);
1396 /* copy a file into a directory, and the directory into itself */
1397 shfo.pFrom = "test1.txt\0test4.txt\0";
1398 shfo.pTo = "test4.txt\0";
1399 shfo.fAnyOperationsAborted = FALSE;
1400 shfo.fFlags |= FOF_NOCONFIRMATION;
1401 retval = SHFileOperationA(&shfo);
1402 ok(retval == ERROR_SUCCESS ||
1403 retval == DE_DESTSUBTREE, /* Vista */
1404 "Expected ERROR_SUCCESS or DE_DESTSUBTREE, got %d\n", retval);
1405 ok(DeleteFileA("test4.txt\\test1.txt"), "Expected test4.txt\\test1.txt to exist\n");
1407 /* copy a file to a file, and the directory into itself */
1408 shfo.pFrom = "test1.txt\0test4.txt\0";
1409 shfo.pTo = "test4.txt\\a.txt\0";
1410 shfo.fAnyOperationsAborted = FALSE;
1411 retval = SHFileOperationA(&shfo);
1412 if (dir_exists("test4.txt\\a.txt"))
1414 /* Vista and W2K8 (broken or new behavior ?) */
1415 ok(retval == DE_DESTSUBTREE, "Expected DE_DESTSUBTREE, got %d\n", retval);
1416 ok(DeleteFileA("test4.txt\\a.txt\\test1.txt"), "Expected test4.txt\\a.txt\\test1.txt to exist\n");
1417 RemoveDirectoryA("test4.txt\\a.txt");
1419 else
1421 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
1422 ok(!file_exists("test4.txt\\a.txt"), "Expected test4.txt\\a.txt to not exist\n");
1425 /* copy a nonexistent file to a nonexistent directory */
1426 shfo.pFrom = "e.txt\0";
1427 shfo.pTo = "nonexistent\0";
1428 shfo.fAnyOperationsAborted = FALSE;
1429 retval = SHFileOperationA(&shfo);
1430 ok(retval == 1026 ||
1431 retval == ERROR_FILE_NOT_FOUND || /* Vista */
1432 broken(retval == ERROR_SUCCESS), /* NT4 */
1433 "Expected 1026 or ERROR_FILE_NOT_FOUND, got %d\n", retval);
1434 ok(!file_exists("nonexistent\\e.txt"), "Expected nonexistent\\e.txt to not exist\n");
1435 ok(!file_exists("nonexistent"), "Expected nonexistent to not exist\n");
1437 /* Overwrite tests */
1438 clean_after_shfo_tests();
1439 init_shfo_tests();
1440 if (!on_nt4)
1442 /* NT4 would throw up some dialog boxes and doesn't copy files that are needed
1443 * in subsequent tests.
1445 shfo.fFlags = FOF_NOCONFIRMATION;
1446 shfo.pFrom = "test1.txt\0";
1447 shfo.pTo = "test2.txt\0";
1448 shfo.fAnyOperationsAborted = 0xdeadbeef;
1449 /* without FOF_NOCONFIRMATION the confirmation is Yes/No */
1450 retval = SHFileOperationA(&shfo);
1451 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1452 ok(!shfo.fAnyOperationsAborted, "Didn't expect aborted operations\n");
1453 ok(file_has_content("test2.txt", "test1.txt\n"), "The file was not copied\n");
1455 shfo.pFrom = "test3.txt\0test1.txt\0";
1456 shfo.pTo = "test2.txt\0one.txt\0";
1457 shfo.fFlags = FOF_NOCONFIRMATION | FOF_MULTIDESTFILES;
1458 /* without FOF_NOCONFIRMATION the confirmation is Yes/Yes to All/No/Cancel */
1459 retval = SHFileOperationA(&shfo);
1460 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1461 ok(file_has_content("test2.txt", "test3.txt\n"), "The file was not copied\n");
1463 shfo.pFrom = "one.txt\0";
1464 shfo.pTo = "testdir2\0";
1465 shfo.fFlags = FOF_NOCONFIRMATION;
1466 /* without FOF_NOCONFIRMATION the confirmation is Yes/No */
1467 retval = SHFileOperationA(&shfo);
1468 ok(retval == 0, "Expected 0, got %d\n", retval);
1469 ok(file_has_content("testdir2\\one.txt", "test1.txt\n"), "The file was not copied\n");
1472 createTestFile("test4.txt\\test1.txt");
1473 shfo.pFrom = "test4.txt\0";
1474 shfo.pTo = "testdir2\0";
1475 /* WinMe needs FOF_NOERRORUI */
1476 shfo.fFlags = FOF_NOCONFIRMATION | FOF_NOERRORUI;
1477 retval = SHFileOperationA(&shfo);
1478 ok(retval == ERROR_SUCCESS ||
1479 broken(retval == 0x100a1), /* WinMe */
1480 "Expected ERROR_SUCCESS, got %d\n", retval);
1481 shfo.fFlags = FOF_NOCONFIRMATION;
1482 if (ERROR_SUCCESS)
1484 createTestFile("test4.txt\\.\\test1.txt"); /* modify the content of the file */
1485 /* without FOF_NOCONFIRMATION the confirmation is "This folder already contains a folder named ..." */
1486 retval = SHFileOperationA(&shfo);
1487 ok(retval == 0, "Expected 0, got %d\n", retval);
1488 ok(file_has_content("testdir2\\test4.txt\\test1.txt", "test4.txt\\.\\test1.txt\n"), "The file was not copied\n");
1491 createTestFile("one.txt");
1493 /* pFrom contains bogus 2nd name longer than MAX_PATH */
1494 memset(from, 'a', MAX_PATH*2);
1495 memset(from+MAX_PATH*2, 0, 2);
1496 lstrcpyA(from, "one.txt");
1497 shfo.pFrom = from;
1498 shfo.pTo = "two.txt\0";
1499 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1500 retval = SHFileOperationA(&shfo);
1501 ok(retval == 1148 || retval == 1026 ||
1502 retval == ERROR_ACCESS_DENIED || /* win2k */
1503 retval == DE_INVALIDFILES, /* Vista */
1504 "Unexpected return value, got %d\n", retval);
1505 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1506 if (dir_exists("two.txt"))
1507 /* Vista and W2K8 (broken or new behavior ?) */
1508 ok(RemoveDirectoryA("two.txt"), "Expected two.txt to exist\n");
1509 else
1510 ok(!DeleteFileA("two.txt"), "Expected file to not exist\n");
1512 createTestFile("one.txt");
1514 /* pTo contains bogus 2nd name longer than MAX_PATH */
1515 memset(to, 'a', MAX_PATH*2);
1516 memset(to+MAX_PATH*2, 0, 2);
1517 lstrcpyA(to, "two.txt");
1518 shfo.pFrom = "one.txt\0";
1519 shfo.pTo = to;
1520 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1521 retval = SHFileOperationA(&shfo);
1522 if (retval == DE_OPCANCELLED)
1524 /* NT4 fails and doesn't copy any files */
1525 ok(!file_exists("two.txt"), "Expected two.txt to not exist\n");
1527 else
1529 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1530 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1532 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1534 createTestFile("one.txt");
1536 /* no FOF_MULTIDESTFILES, two files in pTo */
1537 shfo.pFrom = "one.txt\0";
1538 shfo.pTo = "two.txt\0three.txt\0";
1539 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1540 retval = SHFileOperationA(&shfo);
1541 if (retval == DE_OPCANCELLED)
1543 /* NT4 fails and doesn't copy any files */
1544 ok(!file_exists("two.txt"), "Expected two.txt to not exist\n");
1546 else
1548 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1549 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1551 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1553 createTestFile("one.txt");
1555 /* both pFrom and pTo contain bogus 2nd names longer than MAX_PATH */
1556 memset(from, 'a', MAX_PATH*2);
1557 memset(from+MAX_PATH*2, 0, 2);
1558 memset(to, 'a', MAX_PATH*2);
1559 memset(to+MAX_PATH*2, 0, 2);
1560 lstrcpyA(from, "one.txt");
1561 lstrcpyA(to, "two.txt");
1562 shfo.pFrom = from;
1563 shfo.pTo = to;
1564 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1565 retval = SHFileOperationA(&shfo);
1566 ok(retval == 1148 || retval == 1026 ||
1567 retval == ERROR_ACCESS_DENIED || /* win2k */
1568 retval == DE_INVALIDFILES, /* Vista */
1569 "Unexpected return value, got %d\n", retval);
1570 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1571 if (dir_exists("two.txt"))
1572 /* Vista and W2K8 (broken or new behavior ?) */
1573 ok(RemoveDirectoryA("two.txt"), "Expected two.txt to exist\n");
1574 else
1575 ok(!DeleteFileA("two.txt"), "Expected file to not exist\n");
1577 createTestFile("one.txt");
1579 /* pTo contains bogus 2nd name longer than MAX_PATH, FOF_MULTIDESTFILES */
1580 memset(to, 'a', MAX_PATH*2);
1581 memset(to+MAX_PATH*2, 0, 2);
1582 lstrcpyA(to, "two.txt");
1583 shfo.pFrom = "one.txt\0";
1584 shfo.pTo = to;
1585 shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION |
1586 FOF_SILENT | FOF_NOERRORUI;
1587 retval = SHFileOperationA(&shfo);
1588 if (retval == DE_OPCANCELLED)
1590 /* NT4 fails and doesn't copy any files */
1591 ok(!file_exists("two.txt"), "Expected two.txt to not exist\n");
1593 else
1595 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1596 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1598 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1600 createTestFile("one.txt");
1601 createTestFile("two.txt");
1603 /* pTo contains bogus 2nd name longer than MAX_PATH,
1604 * multiple source files,
1605 * dest directory does not exist
1607 memset(to, 'a', 2 * MAX_PATH);
1608 memset(to+MAX_PATH*2, 0, 2);
1609 lstrcpyA(to, "threedir");
1610 shfo.pFrom = "one.txt\0two.txt\0";
1611 shfo.pTo = to;
1612 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1613 retval = SHFileOperationA(&shfo);
1614 if (dir_exists("threedir"))
1616 /* Vista and W2K8 (broken or new behavior ?) */
1617 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1618 ok(DeleteFileA("threedir\\one.txt"), "Expected file to exist\n");
1619 ok(DeleteFileA("threedir\\two.txt"), "Expected file to exist\n");
1620 ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
1622 else
1624 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
1625 ok(!DeleteFileA("threedir\\one.txt"), "Expected file to not exist\n");
1626 ok(!DeleteFileA("threedir\\two.txt"), "Expected file to not exist\n");
1627 ok(!DeleteFileA("threedir"), "Expected file to not exist\n");
1628 ok(!RemoveDirectoryA("threedir"), "Expected dir to not exist\n");
1630 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1631 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1633 createTestFile("one.txt");
1634 createTestFile("two.txt");
1635 CreateDirectoryA("threedir", NULL);
1637 /* pTo contains bogus 2nd name longer than MAX_PATH,
1638 * multiple source files,
1639 * dest directory does exist
1641 memset(to, 'a', 2 * MAX_PATH);
1642 memset(to+MAX_PATH*2, 0, 2);
1643 lstrcpyA(to, "threedir");
1644 shfo.pFrom = "one.txt\0two.txt\0";
1645 shfo.pTo = to;
1646 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1647 retval = SHFileOperationA(&shfo);
1648 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1649 ok(DeleteFileA("threedir\\one.txt"), "Expected file to exist\n");
1650 ok(DeleteFileA("threedir\\two.txt"), "Expected file to exist\n");
1651 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1652 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1653 ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
1655 if (0) {
1656 /* this crashes on win9x */
1657 createTestFile("one.txt");
1658 createTestFile("two.txt");
1660 /* pTo contains bogus 2nd name longer than MAX_PATH,
1661 * multiple source files, FOF_MULTIDESTFILES
1662 * dest dir does not exist
1665 memset(to, 'a', 2 * MAX_PATH);
1666 memset(to+MAX_PATH*2, 0, 2);
1667 lstrcpyA(to, "threedir");
1668 shfo.pFrom = "one.txt\0two.txt\0";
1669 shfo.pTo = to;
1670 shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION |
1671 FOF_SILENT | FOF_NOERRORUI;
1672 retval = SHFileOperationA(&shfo);
1673 ok(retval == ERROR_CANCELLED ||
1674 retval == ERROR_SUCCESS, /* win2k3 */
1675 "Expected ERROR_CANCELLED or ERROR_SUCCESS, got %d\n", retval);
1676 ok(!DeleteFileA("threedir\\one.txt"), "Expected file to not exist\n");
1677 ok(!DeleteFileA("threedir\\two.txt"), "Expected file to not exist\n");
1678 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1679 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1680 ok(!RemoveDirectoryA("threedir"), "Expected dir to not exist\n");
1682 /* file exists in win2k */
1683 DeleteFileA("threedir");
1687 createTestFile("one.txt");
1688 createTestFile("two.txt");
1689 CreateDirectoryA("threedir", NULL);
1691 /* pTo contains bogus 2nd name longer than MAX_PATH,
1692 * multiple source files, FOF_MULTIDESTFILES
1693 * dest dir does exist
1695 memset(to, 'a', 2 * MAX_PATH);
1696 memset(to+MAX_PATH*2, 0, 2);
1697 lstrcpyA(to, "threedir");
1698 ptr = to + lstrlenA(to) + 1;
1699 lstrcpyA(ptr, "fourdir");
1700 shfo.pFrom = "one.txt\0two.txt\0";
1701 shfo.pTo = to;
1702 shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION |
1703 FOF_SILENT | FOF_NOERRORUI;
1704 retval = SHFileOperationA(&shfo);
1705 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1706 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1707 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1708 ok(DeleteFileA("threedir\\one.txt"), "Expected file to exist\n");
1709 if (dir_exists("fourdir"))
1711 /* Vista and W2K8 (broken or new behavior ?) */
1712 ok(!DeleteFileA("threedir\\two.txt"), "Expected file to not exist\n");
1713 ok(DeleteFileA("fourdir\\two.txt"), "Expected file to exist\n");
1714 RemoveDirectoryA("fourdir");
1716 else
1718 ok(DeleteFileA("threedir\\two.txt"), "Expected file to exist\n");
1719 ok(!DeleteFileA("fourdir"), "Expected file to not exist\n");
1720 ok(!RemoveDirectoryA("fourdir"), "Expected dir to not exist\n");
1722 ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
1724 createTestFile("one.txt");
1725 createTestFile("two.txt");
1726 CreateDirectoryA("threedir", NULL);
1728 /* multiple source files, FOF_MULTIDESTFILES
1729 * multiple dest files, but first dest dir exists
1730 * num files in lists is equal
1732 shfo.pFrom = "one.txt\0two.txt\0";
1733 shfo.pTo = "threedir\0fourdir\0";
1734 shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION |
1735 FOF_SILENT | FOF_NOERRORUI;
1736 retval = SHFileOperationA(&shfo);
1737 ok(retval == ERROR_CANCELLED ||
1738 retval == DE_FILEDESTISFLD || /* Vista */
1739 broken(retval == DE_OPCANCELLED), /* Win9x, NT4 */
1740 "Expected ERROR_CANCELLED or DE_FILEDESTISFLD. got %d\n", retval);
1741 if (file_exists("threedir\\threedir"))
1743 /* NT4 */
1744 ok(DeleteFileA("threedir\\threedir"), "Expected file to exist\n");
1746 ok(!DeleteFileA("threedir\\one.txt"), "Expected file to not exist\n");
1747 ok(!DeleteFileA("threedir\\two.txt"), "Expected file to not exist\n");
1748 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1749 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1750 ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
1751 ok(!DeleteFileA("fourdir"), "Expected file to not exist\n");
1752 ok(!RemoveDirectoryA("fourdir"), "Expected dir to not exist\n");
1754 createTestFile("one.txt");
1755 createTestFile("two.txt");
1756 CreateDirectoryA("threedir", NULL);
1758 /* multiple source files, FOF_MULTIDESTFILES
1759 * multiple dest files, but first dest dir exists
1760 * num files in lists is not equal
1762 shfo.pFrom = "one.txt\0two.txt\0";
1763 shfo.pTo = "threedir\0fourdir\0five\0";
1764 shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION |
1765 FOF_SILENT | FOF_NOERRORUI;
1766 retval = SHFileOperationA(&shfo);
1767 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1768 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1769 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1770 ok(DeleteFileA("threedir\\one.txt"), "Expected file to exist\n");
1771 if (dir_exists("fourdir"))
1773 /* Vista and W2K8 (broken or new behavior ?) */
1774 ok(!DeleteFileA("threedir\\two.txt"), "Expected file to not exist\n");
1775 ok(DeleteFileA("fourdir\\two.txt"), "Expected file to exist\n");
1776 RemoveDirectoryA("fourdir");
1778 else
1780 ok(DeleteFileA("threedir\\two.txt"), "Expected file to exist\n");
1781 ok(!DeleteFileA("fourdir"), "Expected file to not exist\n");
1782 ok(!RemoveDirectoryA("fourdir"), "Expected dir to not exist\n");
1784 ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
1785 ok(!DeleteFileA("five"), "Expected file to not exist\n");
1786 ok(!RemoveDirectoryA("five"), "Expected dir to not exist\n");
1788 createTestFile("aa.txt");
1789 createTestFile("ab.txt");
1790 CreateDirectoryA("one", NULL);
1791 CreateDirectoryA("two", NULL);
1793 /* pFrom has a glob, pTo has more than one dest */
1794 shfo.pFrom = "a*.txt\0";
1795 shfo.pTo = "one\0two\0";
1796 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1797 retval = SHFileOperationA(&shfo);
1798 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1799 ok(DeleteFileA("one\\aa.txt"), "Expected file to exist\n");
1800 ok(DeleteFileA("one\\ab.txt"), "Expected file to exist\n");
1801 ok(!DeleteFileA("two\\aa.txt"), "Expected file to not exist\n");
1802 ok(!DeleteFileA("two\\ab.txt"), "Expected file to not exist\n");
1803 ok(DeleteFileA("aa.txt"), "Expected file to exist\n");
1804 ok(DeleteFileA("ab.txt"), "Expected file to exist\n");
1805 ok(RemoveDirectoryA("one"), "Expected dir to exist\n");
1806 ok(RemoveDirectoryA("two"), "Expected dir to exist\n");
1808 /* pTo is an empty string */
1809 CreateDirectoryA("dir", NULL);
1810 createTestFile("dir\\abcdefgh.abc");
1811 shfo.pFrom = "dir\\abcdefgh.abc\0";
1812 shfo.pTo = "\0";
1813 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1814 retval = SHFileOperationA(&shfo);
1815 ok(retval == ERROR_SUCCESS ||
1816 broken(retval == DE_OPCANCELLED), /* NT4 */
1817 "Expected ERROR_SUCCESS, got %d\n", retval);
1818 if (retval == ERROR_SUCCESS)
1819 ok(DeleteFileA("abcdefgh.abc"), "Expected file to exist\n");
1820 ok(DeleteFileA("dir\\abcdefgh.abc"), "Expected file to exist\n");
1821 ok(RemoveDirectoryA("dir"), "Expected dir to exist\n");
1823 /* Check last error after a successful file operation. */
1824 clean_after_shfo_tests();
1825 init_shfo_tests();
1826 shfo.pFrom = "test1.txt\0";
1827 shfo.pTo = "testdir2\0";
1828 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1829 SetLastError(0xdeadbeef);
1830 retval = SHFileOperationA(&shfo);
1831 ok(retval == ERROR_SUCCESS, "File copy failed with %d\n", retval);
1832 ok(!shfo.fAnyOperationsAborted, "Didn't expect aborted operations\n");
1833 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
1835 /* Check last error after a failed file operation. */
1836 clean_after_shfo_tests();
1837 init_shfo_tests();
1838 shfo.pFrom = "nonexistent\0";
1839 shfo.pTo = "testdir2\0";
1840 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1841 SetLastError(0xdeadbeef);
1842 retval = SHFileOperationA(&shfo);
1843 ok(retval != ERROR_SUCCESS, "Unexpected ERROR_SUCCESS\n");
1844 ok(!shfo.fAnyOperationsAborted, "Didn't expect aborted operations\n");
1845 ok(GetLastError() == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", GetLastError());
1848 /* tests the FO_MOVE action */
1849 static void test_move(void)
1851 SHFILEOPSTRUCTA shfo, shfo2;
1852 CHAR from[5*MAX_PATH];
1853 CHAR to[5*MAX_PATH];
1854 DWORD retval;
1856 clean_after_shfo_tests();
1857 init_shfo_tests();
1859 shfo.hwnd = NULL;
1860 shfo.wFunc = FO_MOVE;
1861 shfo.pFrom = from;
1862 shfo.pTo = to;
1863 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR;
1864 shfo.hNameMappings = NULL;
1865 shfo.lpszProgressTitle = NULL;
1866 shfo.fAnyOperationsAborted = FALSE;
1868 set_curr_dir_path(from, "testdir2\\*.*\0");
1869 set_curr_dir_path(to, "test4.txt\\*.*\0");
1870 retval = SHFileOperationA(&shfo);
1871 ok(retval != 0, "SHFileOperation should fail\n");
1872 ok(!shfo.fAnyOperationsAborted, "fAnyOperationsAborted %d\n", shfo.fAnyOperationsAborted);
1874 ok(file_exists("testdir2"), "dir should not be moved\n");
1875 ok(file_exists("testdir2\\one.txt"), "file should not be moved\n");
1876 ok(file_exists("testdir2\\nested"), "dir should not be moved\n");
1877 ok(file_exists("testdir2\\nested\\two.txt"), "file should not be moved\n");
1879 set_curr_dir_path(from, "testdir2\\*.*\0");
1880 set_curr_dir_path(to, "test4.txt\0");
1881 retval = SHFileOperationA(&shfo);
1882 ok(!retval, "SHFileOperation error %#x\n", retval);
1883 ok(!shfo.fAnyOperationsAborted, "fAnyOperationsAborted %d\n", shfo.fAnyOperationsAborted);
1885 ok(file_exists("testdir2"), "dir should not be moved\n");
1886 ok(!file_exists("testdir2\\one.txt"), "file should be moved\n");
1887 ok(!file_exists("testdir2\\nested"), "dir should be moved\n");
1888 ok(!file_exists("testdir2\\nested\\two.txt"), "file should be moved\n");
1890 ok(file_exists("test4.txt"), "dir should exist\n");
1891 ok(file_exists("test4.txt\\one.txt"), "file should exist\n");
1892 ok(file_exists("test4.txt\\nested"), "dir should exist\n");
1893 ok(file_exists("test4.txt\\nested\\two.txt"), "file should exist\n");
1895 clean_after_shfo_tests();
1896 init_shfo_tests();
1898 shfo.hwnd = NULL;
1899 shfo.wFunc = FO_MOVE;
1900 shfo.pFrom = from;
1901 shfo.pTo = to;
1902 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1903 shfo.hNameMappings = NULL;
1904 shfo.lpszProgressTitle = NULL;
1906 set_curr_dir_path(from, "test1.txt\0");
1907 set_curr_dir_path(to, "test4.txt\0");
1908 ok(!SHFileOperationA(&shfo), "Prepare test to check how directories are moved recursively\n");
1909 ok(!file_exists("test1.txt"), "test1.txt should not exist\n");
1910 ok(file_exists("test4.txt\\test1.txt"), "The file is not moved\n");
1912 set_curr_dir_path(from, "test?.txt\0");
1913 set_curr_dir_path(to, "testdir2\0");
1914 ok(!file_exists("testdir2\\test2.txt"), "The file is not moved yet\n");
1915 ok(!file_exists("testdir2\\test4.txt"), "The directory is not moved yet\n");
1916 ok(!SHFileOperationA(&shfo), "Files and directories are moved to directory\n");
1917 ok(file_exists("testdir2\\test2.txt"), "The file is moved\n");
1918 ok(file_exists("testdir2\\test4.txt"), "The directory is moved\n");
1919 ok(file_exists("testdir2\\test4.txt\\test1.txt"), "The file in subdirectory is moved\n");
1921 clean_after_shfo_tests();
1922 init_shfo_tests();
1924 memcpy(&shfo2, &shfo, sizeof(SHFILEOPSTRUCTA));
1925 shfo2.fFlags |= FOF_MULTIDESTFILES;
1927 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
1928 set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
1929 if (old_shell32)
1930 shfo2.fFlags |= FOF_NOCONFIRMMKDIR;
1931 ok(!SHFileOperationA(&shfo2), "Move many files\n");
1932 ok(DeleteFileA("test6.txt"), "The file is not moved - many files are "
1933 "specified as a target\n");
1934 ok(DeleteFileA("test7.txt"), "The file is not moved\n");
1935 ok(RemoveDirectoryA("test8.txt"), "The directory is not moved\n");
1937 init_shfo_tests();
1939 /* number of sources does not correspond to number of targets,
1940 include directories */
1941 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
1942 set_curr_dir_path(to, "test6.txt\0test7.txt\0");
1943 retval = SHFileOperationA(&shfo2);
1944 if (dir_exists("test6.txt"))
1946 if (retval == ERROR_SUCCESS)
1948 /* Old shell32 */
1949 DeleteFileA("test6.txt\\test1.txt");
1950 DeleteFileA("test6.txt\\test2.txt");
1951 RemoveDirectoryA("test6.txt\\test4.txt");
1952 RemoveDirectoryA("test6.txt");
1954 else
1956 /* Vista and W2K8 (broken or new behavior ?) */
1957 ok(retval == DE_DESTSAMETREE, "Expected DE_DESTSAMETREE, got %d\n", retval);
1958 ok(DeleteFileA("test6.txt\\test1.txt"), "The file is not moved\n");
1959 RemoveDirectoryA("test6.txt");
1960 ok(DeleteFileA("test7.txt\\test2.txt"), "The file is not moved\n");
1961 RemoveDirectoryA("test7.txt");
1964 else
1966 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
1967 ok(!file_exists("test6.txt"), "The file is not moved - many files are "
1968 "specified as a target\n");
1971 init_shfo_tests();
1972 /* number of sources does not correspond to number of targets,
1973 files only,
1974 from exceeds to */
1975 set_curr_dir_path(from, "test1.txt\0test2.txt\0test3.txt\0");
1976 set_curr_dir_path(to, "test6.txt\0test7.txt\0");
1977 retval = SHFileOperationA(&shfo2);
1978 if (dir_exists("test6.txt"))
1980 if (retval == ERROR_SUCCESS)
1982 /* Old shell32 */
1983 DeleteFileA("test6.txt\\test1.txt");
1984 DeleteFileA("test6.txt\\test2.txt");
1985 RemoveDirectoryA("test6.txt\\test4.txt");
1986 RemoveDirectoryA("test6.txt");
1988 else
1990 /* Vista and W2K8 (broken or new behavior ?) */
1991 ok(retval == DE_SAMEFILE, "Expected DE_SAMEFILE, got %d\n", retval);
1992 ok(DeleteFileA("test6.txt\\test1.txt"), "The file is not moved\n");
1993 RemoveDirectoryA("test6.txt");
1994 ok(DeleteFileA("test7.txt\\test2.txt"), "The file is not moved\n");
1995 RemoveDirectoryA("test7.txt");
1996 ok(file_exists("test3.txt"), "File should not be moved\n");
1999 else
2001 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
2002 ok(!file_exists("test6.txt"), "The file is not moved - many files are "
2003 "specified as a target\n");
2006 init_shfo_tests();
2007 /* number of sources does not correspond to number of targets,
2008 files only,
2009 too exceeds from */
2010 set_curr_dir_path(from, "test1.txt\0test2.txt\0");
2011 set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
2012 retval = SHFileOperationA(&shfo2);
2013 if (dir_exists("test6.txt"))
2015 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
2016 ok(DeleteFileA("test6.txt\\test1.txt"),"The file is not moved\n");
2017 ok(DeleteFileA("test7.txt\\test2.txt"),"The file is not moved\n");
2018 ok(!dir_exists("test8.txt") && !file_exists("test8.txt"),
2019 "Directory should not be created\n");
2020 RemoveDirectoryA("test6.txt");
2021 RemoveDirectoryA("test7.txt");
2023 else
2025 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* WinXp, Win2k */);
2026 ok(!file_exists("test6.txt"), "The file is not moved - many files are "
2027 "specified as a target\n");
2030 init_shfo_tests();
2031 /* number of sources does not correspond to number of targets,
2032 target directories */
2033 set_curr_dir_path(from, "test1.txt\0test2.txt\0test3.txt\0");
2034 set_curr_dir_path(to, "test4.txt\0test5.txt\0");
2035 retval = SHFileOperationA(&shfo2);
2036 if (dir_exists("test5.txt"))
2038 ok(retval == DE_SAMEFILE, "Expected DE_SAMEFILE, got %d\n", retval);
2039 ok(DeleteFileA("test4.txt\\test1.txt"),"The file is not moved\n");
2040 ok(DeleteFileA("test5.txt\\test2.txt"),"The file is not moved\n");
2041 ok(file_exists("test3.txt"), "The file is not moved\n");
2042 RemoveDirectoryA("test4.txt");
2043 RemoveDirectoryA("test5.txt");
2045 else
2047 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
2048 ok(DeleteFileA("test4.txt\\test1.txt"),"The file is not moved\n");
2049 ok(DeleteFileA("test4.txt\\test2.txt"),"The file is not moved\n");
2050 ok(DeleteFileA("test4.txt\\test3.txt"),"The file is not moved\n");
2054 init_shfo_tests();
2055 /* 0 incoming files */
2056 set_curr_dir_path(from, "\0\0");
2057 set_curr_dir_path(to, "test6.txt\0\0");
2058 retval = SHFileOperationA(&shfo2);
2059 ok(retval == ERROR_SUCCESS || retval == ERROR_ACCESS_DENIED
2060 , "Expected ERROR_SUCCESS || ERROR_ACCESS_DENIED, got %d\n", retval);
2061 ok(!file_exists("test6.txt"), "The file should not exist\n");
2063 init_shfo_tests();
2064 /* 0 outgoing files */
2065 set_curr_dir_path(from, "test1\0\0");
2066 set_curr_dir_path(to, "\0\0");
2067 retval = SHFileOperationA(&shfo2);
2068 ok(retval == ERROR_FILE_NOT_FOUND ||
2069 broken(retval == 1026)
2070 , "Expected ERROR_FILE_NOT_FOUND, got %d\n", retval);
2071 ok(!file_exists("test6.txt"), "The file should not exist\n");
2073 init_shfo_tests();
2075 set_curr_dir_path(from, "test3.txt\0");
2076 set_curr_dir_path(to, "test4.txt\\test1.txt\0");
2077 ok(!SHFileOperationA(&shfo), "Can't move file to other directory\n");
2078 ok(file_exists("test4.txt\\test1.txt"), "The file is not moved\n");
2080 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
2081 set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
2082 if (old_shell32)
2083 shfo.fFlags |= FOF_NOCONFIRMMKDIR;
2084 retval = SHFileOperationA(&shfo);
2085 if (dir_exists("test6.txt"))
2087 /* Old shell32 */
2088 /* Vista and W2K8 (broken or new behavior ?) */
2089 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
2090 ok(DeleteFileA("test6.txt\\test1.txt"), "The file is not moved. Many files are specified\n");
2091 ok(DeleteFileA("test6.txt\\test2.txt"), "The file is not moved. Many files are specified\n");
2092 ok(DeleteFileA("test6.txt\\test4.txt\\test1.txt"), "The file is not moved. Many files are specified\n");
2093 ok(RemoveDirectoryA("test6.txt\\test4.txt"), "The directory is not moved. Many files are specified\n");
2094 RemoveDirectoryA("test6.txt");
2095 init_shfo_tests();
2097 else
2099 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
2100 ok(file_exists("test1.txt"), "The file is moved. Many files are specified\n");
2101 ok(dir_exists("test4.txt"), "The directory is moved. Many files are specified\n");
2104 set_curr_dir_path(from, "test1.txt\0");
2105 set_curr_dir_path(to, "test6.txt\0");
2106 ok(!SHFileOperationA(&shfo), "Move file failed\n");
2107 ok(!file_exists("test1.txt"), "The file is not moved\n");
2108 ok(file_exists("test6.txt"), "The file is not moved\n");
2109 set_curr_dir_path(from, "test6.txt\0");
2110 set_curr_dir_path(to, "test1.txt\0");
2111 ok(!SHFileOperationA(&shfo), "Move file back failed\n");
2113 set_curr_dir_path(from, "test4.txt\0");
2114 set_curr_dir_path(to, "test6.txt\0");
2115 ok(!SHFileOperationA(&shfo), "Move dir failed\n");
2116 ok(!dir_exists("test4.txt"), "The dir is not moved\n");
2117 ok(dir_exists("test6.txt"), "The dir is moved\n");
2118 set_curr_dir_path(from, "test6.txt\0");
2119 set_curr_dir_path(to, "test4.txt\0");
2120 ok(!SHFileOperationA(&shfo), "Move dir back failed\n");
2122 /* move one file to two others */
2123 init_shfo_tests();
2124 shfo.pFrom = "test1.txt\0";
2125 shfo.pTo = "a.txt\0b.txt\0";
2126 retval = SHFileOperationA(&shfo);
2127 if (retval == DE_OPCANCELLED)
2129 /* NT4 fails and doesn't move any files */
2130 ok(!file_exists("a.txt"), "Expected a.txt to not exist\n");
2131 DeleteFileA("test1.txt");
2133 else
2135 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
2136 if (old_shell32)
2138 DeleteFileA("a.txt\\a.txt");
2139 RemoveDirectoryA("a.txt");
2141 else
2142 ok(DeleteFileA("a.txt"), "Expected a.txt to exist\n");
2143 ok(!file_exists("test1.txt"), "Expected test1.txt to not exist\n");
2145 ok(!file_exists("b.txt"), "Expected b.txt to not exist\n");
2147 /* move two files to one other */
2148 shfo.pFrom = "test2.txt\0test3.txt\0";
2149 shfo.pTo = "test1.txt\0";
2150 retval = SHFileOperationA(&shfo);
2151 if (dir_exists("test1.txt"))
2153 /* Old shell32 */
2154 /* Vista and W2K8 (broken or new behavior ?) */
2155 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
2156 ok(DeleteFileA("test1.txt\\test2.txt"), "Expected test1.txt\\test2.txt to exist\n");
2157 ok(DeleteFileA("test1.txt\\test3.txt"), "Expected test1.txt\\test3.txt to exist\n");
2158 RemoveDirectoryA("test1.txt");
2159 createTestFile("test2.txt");
2160 createTestFile("test3.txt");
2162 else
2164 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
2165 ok(!file_exists("test1.txt"), "Expected test1.txt to not exist\n");
2166 ok(file_exists("test2.txt"), "Expected test2.txt to exist\n");
2167 ok(file_exists("test3.txt"), "Expected test3.txt to exist\n");
2170 /* move a directory into itself */
2171 shfo.pFrom = "test4.txt\0";
2172 shfo.pTo = "test4.txt\\b.txt\0";
2173 retval = SHFileOperationA(&shfo);
2174 ok(retval == ERROR_SUCCESS ||
2175 retval == DE_DESTSUBTREE, /* Vista */
2176 "Expected ERROR_SUCCESS or DE_DESTSUBTREE, got %d\n", retval);
2177 ok(!RemoveDirectoryA("test4.txt\\b.txt"), "Expected test4.txt\\b.txt to not exist\n");
2178 ok(dir_exists("test4.txt"), "Expected test4.txt to exist\n");
2180 /* move many files without FOF_MULTIDESTFILES */
2181 shfo.pFrom = "test2.txt\0test3.txt\0";
2182 shfo.pTo = "d.txt\0e.txt\0";
2183 retval = SHFileOperationA(&shfo);
2184 if (dir_exists("d.txt"))
2186 /* Old shell32 */
2187 /* Vista and W2K8 (broken or new behavior ?) */
2188 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
2189 ok(DeleteFileA("d.txt\\test2.txt"), "Expected d.txt\\test2.txt to exist\n");
2190 ok(DeleteFileA("d.txt\\test3.txt"), "Expected d.txt\\test3.txt to exist\n");
2191 RemoveDirectoryA("d.txt");
2192 createTestFile("test2.txt");
2193 createTestFile("test3.txt");
2195 else
2197 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
2198 ok(!DeleteFileA("d.txt"), "Expected d.txt to not exist\n");
2199 ok(!DeleteFileA("e.txt"), "Expected e.txt to not exist\n");
2202 /* number of sources != number of targets */
2203 shfo.pTo = "d.txt\0";
2204 shfo.fFlags |= FOF_MULTIDESTFILES;
2205 retval = SHFileOperationA(&shfo);
2206 if (dir_exists("d.txt"))
2208 if (old_shell32)
2210 DeleteFileA("d.txt\\test2.txt");
2211 DeleteFileA("d.txt\\test3.txt");
2212 RemoveDirectoryA("d.txt");
2213 createTestFile("test2.txt");
2215 else
2217 /* Vista and W2K8 (broken or new behavior ?) */
2218 ok(retval == DE_SAMEFILE,
2219 "Expected DE_SAMEFILE, got %d\n", retval);
2220 ok(DeleteFileA("d.txt\\test2.txt"), "Expected d.txt\\test2.txt to exist\n");
2221 ok(!file_exists("d.txt\\test3.txt"), "Expected d.txt\\test3.txt to not exist\n");
2222 RemoveDirectoryA("d.txt");
2223 createTestFile("test2.txt");
2226 else
2228 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
2229 ok(!DeleteFileA("d.txt"), "Expected d.txt to not exist\n");
2232 /* FO_MOVE does not create dest directories */
2233 shfo.pFrom = "test2.txt\0";
2234 shfo.pTo = "dir1\\dir2\\test2.txt\0";
2235 retval = SHFileOperationA(&shfo);
2236 if (dir_exists("dir1"))
2238 /* Vista and W2K8 (broken or new behavior ?) */
2239 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
2240 ok(DeleteFileA("dir1\\dir2\\test2.txt"), "Expected dir1\\dir2\\test2.txt to exist\n");
2241 RemoveDirectoryA("dir1\\dir2");
2242 RemoveDirectoryA("dir1");
2243 createTestFile("test2.txt");
2245 else
2247 expect_retval(ERROR_CANCELLED, DE_OPCANCELLED /* Win9x, NT4 */);
2250 /* try to overwrite an existing file */
2251 shfo.pTo = "test3.txt\0";
2252 retval = SHFileOperationA(&shfo);
2253 if (retval == DE_OPCANCELLED)
2255 /* NT4 fails and doesn't move any files */
2256 ok(file_exists("test2.txt"), "Expected test2.txt to exist\n");
2258 else
2260 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
2261 ok(!file_exists("test2.txt"), "Expected test2.txt to not exist\n");
2262 if (old_shell32)
2264 DeleteFileA("test3.txt\\test3.txt");
2265 RemoveDirectoryA("test3.txt");
2267 else
2268 ok(file_exists("test3.txt"), "Expected test3.txt to exist\n");
2272 static void test_sh_create_dir(void)
2274 CHAR path[MAX_PATH];
2275 int ret;
2277 if(!pSHCreateDirectoryExA)
2279 win_skip("skipping SHCreateDirectoryExA tests\n");
2280 return;
2283 set_curr_dir_path(path, "testdir2\\test4.txt\0");
2284 ret = pSHCreateDirectoryExA(NULL, path, NULL);
2285 ok(ERROR_SUCCESS == ret, "SHCreateDirectoryEx failed to create directory recursively, ret = %d\n", ret);
2286 ok(file_exists("testdir2"), "The first directory is not created\n");
2287 ok(file_exists("testdir2\\test4.txt"), "The second directory is not created\n");
2289 ret = pSHCreateDirectoryExA(NULL, path, NULL);
2290 ok(ERROR_ALREADY_EXISTS == ret, "SHCreateDirectoryEx should fail to create existing directory, ret = %d\n", ret);
2292 ret = pSHCreateDirectoryExA(NULL, "c:\\testdir3", NULL);
2293 ok(ERROR_SUCCESS == ret, "SHCreateDirectoryEx failed to create directory, ret = %d\n", ret);
2294 ok(file_exists("c:\\testdir3"), "The directory is not created\n");
2297 static void test_sh_path_prepare(void)
2299 HRESULT res;
2300 CHAR path[MAX_PATH];
2301 CHAR UNICODE_PATH_A[MAX_PATH];
2302 BOOL UsedDefaultChar;
2304 if(!pSHPathPrepareForWriteA)
2306 win_skip("skipping SHPathPrepareForWriteA tests\n");
2307 return;
2310 /* directory exists, SHPPFW_NONE */
2311 set_curr_dir_path(path, "testdir2\0");
2312 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_NONE);
2313 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
2315 /* directory exists, SHPPFW_IGNOREFILENAME */
2316 set_curr_dir_path(path, "testdir2\\test4.txt\0");
2317 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_IGNOREFILENAME);
2318 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
2320 /* directory exists, SHPPFW_DIRCREATE */
2321 set_curr_dir_path(path, "testdir2\0");
2322 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_DIRCREATE);
2323 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
2325 /* directory exists, SHPPFW_IGNOREFILENAME|SHPPFW_DIRCREATE */
2326 set_curr_dir_path(path, "testdir2\\test4.txt\0");
2327 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_IGNOREFILENAME|SHPPFW_DIRCREATE);
2328 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
2329 ok(!file_exists("nonexistent\\"), "nonexistent\\ exists but shouldn't\n");
2331 /* file exists, SHPPFW_NONE */
2332 set_curr_dir_path(path, "test1.txt\0");
2333 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_NONE);
2334 ok(res == HRESULT_FROM_WIN32(ERROR_DIRECTORY) ||
2335 res == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) || /* WinMe */
2336 res == HRESULT_FROM_WIN32(ERROR_INVALID_NAME), /* Vista */
2337 "Unexpected result : 0x%08x\n", res);
2339 /* file exists, SHPPFW_DIRCREATE */
2340 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_DIRCREATE);
2341 ok(res == HRESULT_FROM_WIN32(ERROR_DIRECTORY) ||
2342 res == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) || /* WinMe */
2343 res == HRESULT_FROM_WIN32(ERROR_INVALID_NAME), /* Vista */
2344 "Unexpected result : 0x%08x\n", res);
2346 /* file exists, SHPPFW_NONE, trailing \ */
2347 set_curr_dir_path(path, "test1.txt\\\0");
2348 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_NONE);
2349 ok(res == HRESULT_FROM_WIN32(ERROR_DIRECTORY) ||
2350 res == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND) || /* WinMe */
2351 res == HRESULT_FROM_WIN32(ERROR_INVALID_NAME), /* Vista */
2352 "Unexpected result : 0x%08x\n", res);
2354 /* relative path exists, SHPPFW_DIRCREATE */
2355 res = pSHPathPrepareForWriteA(0, 0, ".\\testdir2", SHPPFW_DIRCREATE);
2356 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
2358 /* relative path doesn't exist, SHPPFW_DIRCREATE -- Windows does not create the directory in this case */
2359 res = pSHPathPrepareForWriteA(0, 0, ".\\testdir2\\test4.txt", SHPPFW_DIRCREATE);
2360 ok(res == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)\n", res);
2361 ok(!file_exists(".\\testdir2\\test4.txt\\"), ".\\testdir2\\test4.txt\\ exists but shouldn't\n");
2363 /* directory doesn't exist, SHPPFW_NONE */
2364 set_curr_dir_path(path, "nonexistent\0");
2365 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_NONE);
2366 ok(res == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)\n", res);
2368 /* directory doesn't exist, SHPPFW_IGNOREFILENAME */
2369 set_curr_dir_path(path, "nonexistent\\notreal\0");
2370 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_IGNOREFILENAME);
2371 ok(res == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)\n", res);
2372 ok(!file_exists("nonexistent\\notreal"), "nonexistent\\notreal exists but shouldn't\n");
2373 ok(!file_exists("nonexistent\\"), "nonexistent\\ exists but shouldn't\n");
2375 /* directory doesn't exist, SHPPFW_IGNOREFILENAME|SHPPFW_DIRCREATE */
2376 set_curr_dir_path(path, "testdir2\\test4.txt\\\0");
2377 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_IGNOREFILENAME|SHPPFW_DIRCREATE);
2378 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
2379 ok(file_exists("testdir2\\test4.txt\\"), "testdir2\\test4.txt doesn't exist but should\n");
2381 /* nested directory doesn't exist, SHPPFW_DIRCREATE */
2382 set_curr_dir_path(path, "nonexistent\\notreal\0");
2383 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_DIRCREATE);
2384 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
2385 ok(file_exists("nonexistent\\notreal"), "nonexistent\\notreal doesn't exist but should\n");
2387 /* SHPPFW_ASKDIRCREATE, SHPPFW_NOWRITECHECK, and SHPPFW_MEDIACHECKONLY are untested */
2389 if(!pSHPathPrepareForWriteW)
2391 win_skip("Skipping SHPathPrepareForWriteW tests\n");
2392 return;
2395 SetLastError(0xdeadbeef);
2396 UsedDefaultChar = FALSE;
2397 if (WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, UNICODE_PATH, -1, UNICODE_PATH_A, sizeof(UNICODE_PATH_A), NULL, &UsedDefaultChar) == 0)
2399 win_skip("Could not convert Unicode path name to multibyte (%d)\n", GetLastError());
2400 return;
2402 if (UsedDefaultChar)
2404 win_skip("Could not find unique multibyte representation for directory name using default codepage\n");
2405 return;
2408 /* unicode directory doesn't exist, SHPPFW_NONE */
2409 RemoveDirectoryA(UNICODE_PATH_A);
2410 res = pSHPathPrepareForWriteW(0, 0, UNICODE_PATH, SHPPFW_NONE);
2411 ok(res == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "res == %08x, expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)\n", res);
2412 ok(!file_exists(UNICODE_PATH_A), "unicode path was created but shouldn't be\n");
2413 RemoveDirectoryA(UNICODE_PATH_A);
2415 /* unicode directory doesn't exist, SHPPFW_DIRCREATE */
2416 res = pSHPathPrepareForWriteW(0, 0, UNICODE_PATH, SHPPFW_DIRCREATE);
2417 ok(res == S_OK, "res == %08x, expected S_OK\n", res);
2418 ok(file_exists(UNICODE_PATH_A), "unicode path should've been created\n");
2420 /* unicode directory exists, SHPPFW_NONE */
2421 res = pSHPathPrepareForWriteW(0, 0, UNICODE_PATH, SHPPFW_NONE);
2422 ok(res == S_OK, "ret == %08x, expected S_OK\n", res);
2424 /* unicode directory exists, SHPPFW_DIRCREATE */
2425 res = pSHPathPrepareForWriteW(0, 0, UNICODE_PATH, SHPPFW_DIRCREATE);
2426 ok(res == S_OK, "ret == %08x, expected S_OK\n", res);
2427 RemoveDirectoryA(UNICODE_PATH_A);
2430 static void test_sh_new_link_info(void)
2432 BOOL ret, mustcopy=TRUE;
2433 CHAR linkto[MAX_PATH];
2434 CHAR destdir[MAX_PATH];
2435 CHAR result[MAX_PATH];
2436 CHAR result2[MAX_PATH];
2438 /* source file does not exist */
2439 set_curr_dir_path(linkto, "nosuchfile.txt\0");
2440 set_curr_dir_path(destdir, "testdir2\0");
2441 ret = SHGetNewLinkInfoA(linkto, destdir, result, &mustcopy, 0);
2442 ok(ret == FALSE ||
2443 broken(ret == lstrlenA(result) + 1), /* NT4 */
2444 "SHGetNewLinkInfoA succeeded\n");
2445 ok(mustcopy == FALSE, "mustcopy should be FALSE\n");
2447 /* dest dir does not exist */
2448 set_curr_dir_path(linkto, "test1.txt\0");
2449 set_curr_dir_path(destdir, "nosuchdir\0");
2450 ret = SHGetNewLinkInfoA(linkto, destdir, result, &mustcopy, 0);
2451 ok(ret == TRUE ||
2452 broken(ret == lstrlenA(result) + 1), /* NT4 */
2453 "SHGetNewLinkInfoA failed, err=%i\n", GetLastError());
2454 ok(mustcopy == FALSE, "mustcopy should be FALSE\n");
2456 /* source file exists */
2457 set_curr_dir_path(linkto, "test1.txt\0");
2458 set_curr_dir_path(destdir, "testdir2\0");
2459 ret = SHGetNewLinkInfoA(linkto, destdir, result, &mustcopy, 0);
2460 ok(ret == TRUE ||
2461 broken(ret == lstrlenA(result) + 1), /* NT4 */
2462 "SHGetNewLinkInfoA failed, err=%i\n", GetLastError());
2463 ok(mustcopy == FALSE, "mustcopy should be FALSE\n");
2464 ok(CompareStringA(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, destdir,
2465 lstrlenA(destdir), result, lstrlenA(destdir)) == CSTR_EQUAL,
2466 "%s does not start with %s\n", result, destdir);
2467 ok(lstrlenA(result) > 4 && lstrcmpiA(result+lstrlenA(result)-4, ".lnk") == 0,
2468 "%s does not end with .lnk\n", result);
2470 /* preferred target name already exists */
2471 createTestFile(result);
2472 ret = SHGetNewLinkInfoA(linkto, destdir, result2, &mustcopy, 0);
2473 ok(ret == TRUE ||
2474 broken(ret == lstrlenA(result2) + 1), /* NT4 */
2475 "SHGetNewLinkInfoA failed, err=%i\n", GetLastError());
2476 ok(mustcopy == FALSE, "mustcopy should be FALSE\n");
2477 ok(CompareStringA(LOCALE_SYSTEM_DEFAULT, NORM_IGNORECASE, destdir,
2478 lstrlenA(destdir), result2, lstrlenA(destdir)) == CSTR_EQUAL,
2479 "%s does not start with %s\n", result2, destdir);
2480 ok(lstrlenA(result2) > 4 && lstrcmpiA(result2+lstrlenA(result2)-4, ".lnk") == 0,
2481 "%s does not end with .lnk\n", result2);
2482 ok(lstrcmpiA(result, result2) != 0, "%s and %s are the same\n", result, result2);
2483 DeleteFileA(result);
2486 static void test_unicode(void)
2488 SHFILEOPSTRUCTW shfoW;
2489 int ret;
2490 HANDLE file;
2491 static const WCHAR UNICODE_PATH_TO[] = {'c',':','\\',0x00ae,0x00ae,'\0'};
2493 if (!pSHFileOperationW)
2495 skip("SHFileOperationW() is missing\n");
2496 return;
2499 shfoW.hwnd = NULL;
2500 shfoW.wFunc = FO_DELETE;
2501 shfoW.pFrom = UNICODE_PATH;
2502 shfoW.pTo = NULL;
2503 shfoW.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
2504 shfoW.hNameMappings = NULL;
2505 shfoW.lpszProgressTitle = NULL;
2507 /* Clean up before start test */
2508 DeleteFileW(UNICODE_PATH);
2509 RemoveDirectoryW(UNICODE_PATH);
2511 /* Make sure we are on a system that supports unicode */
2512 SetLastError(0xdeadbeef);
2513 file = CreateFileW(UNICODE_PATH, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
2514 if (GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
2516 skip("Unicode tests skipped on non-unicode system\n");
2517 return;
2519 CloseHandle(file);
2521 /* Try to delete a file with unicode filename */
2522 ok(file_existsW(UNICODE_PATH), "The file does not exist\n");
2523 ret = pSHFileOperationW(&shfoW);
2524 ok(!ret, "File is not removed, ErrorCode: %d\n", ret);
2525 ok(!file_existsW(UNICODE_PATH), "The file should have been removed\n");
2527 /* Try to trash a file with unicode filename */
2528 createTestFileW(UNICODE_PATH);
2529 shfoW.fFlags |= FOF_ALLOWUNDO;
2530 ok(file_existsW(UNICODE_PATH), "The file does not exist\n");
2531 ret = pSHFileOperationW(&shfoW);
2532 ok(!ret, "File is not removed, ErrorCode: %d\n", ret);
2533 ok(!file_existsW(UNICODE_PATH), "The file should have been removed\n");
2535 if(!pSHCreateDirectoryExW)
2537 skip("Skipping SHCreateDirectoryExW tests\n");
2538 return;
2541 /* Try to delete a directory with unicode filename */
2542 ret = pSHCreateDirectoryExW(NULL, UNICODE_PATH, NULL);
2543 ok(!ret, "SHCreateDirectoryExW returned %d\n", ret);
2544 ok(file_existsW(UNICODE_PATH), "The directory is not created\n");
2545 shfoW.fFlags &= ~FOF_ALLOWUNDO;
2546 ret = pSHFileOperationW(&shfoW);
2547 ok(!ret, "Directory is not removed, ErrorCode: %d\n", ret);
2548 ok(!file_existsW(UNICODE_PATH), "The directory should have been removed\n");
2550 /* Try to trash a directory with unicode filename */
2551 ret = pSHCreateDirectoryExW(NULL, UNICODE_PATH, NULL);
2552 ok(!ret, "SHCreateDirectoryExW returned %d\n", ret);
2553 ok(file_existsW(UNICODE_PATH), "The directory was not created\n");
2554 shfoW.fFlags |= FOF_ALLOWUNDO;
2555 ret = pSHFileOperationW(&shfoW);
2556 ok(!ret, "Directory is not removed, ErrorCode: %d\n", ret);
2557 ok(!file_existsW(UNICODE_PATH), "The directory should have been removed\n");
2559 shfoW.hwnd = NULL;
2560 shfoW.wFunc = FO_COPY;
2561 shfoW.pFrom = UNICODE_PATH;
2562 shfoW.pTo = UNICODE_PATH_TO;
2563 shfoW.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
2564 shfoW.hNameMappings = NULL;
2565 shfoW.lpszProgressTitle = NULL;
2567 /* Check last error after a successful file operation. */
2568 createTestFileW(UNICODE_PATH);
2569 ok(file_existsW(UNICODE_PATH), "The file does not exist\n");
2570 SetLastError(0xdeadbeef);
2571 ret = SHFileOperationW(&shfoW);
2572 ok(ret == ERROR_SUCCESS, "File copy failed with %d\n", ret);
2573 ok(!shfoW.fAnyOperationsAborted, "Didn't expect aborted operations\n");
2574 ok(GetLastError() == ERROR_SUCCESS ||
2575 broken(GetLastError() == ERROR_INVALID_HANDLE), /* WinXp, win2k3 */
2576 "Expected ERROR_SUCCESS, got %d\n", GetLastError());
2578 /* Check last error after a failed file operation. */
2579 DeleteFileW(UNICODE_PATH);
2580 ok(!file_existsW(UNICODE_PATH), "The file should have been removed\n");
2581 SetLastError(0xdeadbeef);
2582 ret = SHFileOperationW(&shfoW);
2583 ok(ret != ERROR_SUCCESS, "Unexpected ERROR_SUCCESS\n");
2584 ok(!shfoW.fAnyOperationsAborted, "Didn't expect aborted operations\n");
2585 ok(GetLastError() == ERROR_SUCCESS ||
2586 broken(GetLastError() == ERROR_INVALID_HANDLE), /* WinXp, win2k3 */
2587 "Expected ERROR_SUCCESS, got %d\n", GetLastError());
2590 static void
2591 test_shlmenu(void) {
2592 HRESULT hres;
2593 hres = Shell_MergeMenus (0, 0, 0x42, 0x4242, 0x424242, 0);
2594 ok (hres == 0x4242, "expected 0x4242 but got %x\n", hres);
2595 hres = Shell_MergeMenus ((HMENU)42, 0, 0x42, 0x4242, 0x424242, 0);
2596 ok (hres == 0x4242, "expected 0x4242 but got %x\n", hres);
2599 /* Check for old shell32 (4.0.x) */
2600 static BOOL is_old_shell32(void)
2602 SHFILEOPSTRUCTA shfo;
2603 CHAR from[5*MAX_PATH];
2604 CHAR to[5*MAX_PATH];
2605 DWORD retval;
2607 shfo.hwnd = NULL;
2608 shfo.wFunc = FO_COPY;
2609 shfo.pFrom = from;
2610 shfo.pTo = to;
2611 /* FOF_NOCONFIRMMKDIR is needed for old shell32 */
2612 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI | FOF_MULTIDESTFILES | FOF_NOCONFIRMMKDIR;
2613 shfo.hNameMappings = NULL;
2614 shfo.lpszProgressTitle = NULL;
2616 set_curr_dir_path(from, "test1.txt\0test2.txt\0test3.txt\0");
2617 set_curr_dir_path(to, "test6.txt\0test7.txt\0");
2618 retval = SHFileOperationA(&shfo);
2620 /* Delete extra files on old shell32 and Vista+*/
2621 DeleteFileA("test6.txt\\test1.txt");
2622 /* Delete extra files on old shell32 */
2623 DeleteFileA("test6.txt\\test2.txt");
2624 DeleteFileA("test6.txt\\test3.txt");
2625 /* Delete extra directory on old shell32 and Vista+ */
2626 RemoveDirectoryA("test6.txt");
2627 /* Delete extra files/directories on Vista+*/
2628 DeleteFileA("test7.txt\\test2.txt");
2629 RemoveDirectoryA("test7.txt");
2631 if (retval == ERROR_SUCCESS)
2632 return TRUE;
2634 return FALSE;
2637 START_TEST(shlfileop)
2639 InitFunctionPointers();
2641 clean_after_shfo_tests();
2643 init_shfo_tests();
2644 old_shell32 = is_old_shell32();
2645 if (old_shell32)
2646 win_skip("Need to cater for old shell32 (4.0.x) on Win95\n");
2647 clean_after_shfo_tests();
2649 init_shfo_tests();
2650 test_get_file_info();
2651 test_get_file_info_iconlist();
2652 clean_after_shfo_tests();
2654 init_shfo_tests();
2655 test_delete();
2656 clean_after_shfo_tests();
2658 init_shfo_tests();
2659 test_rename();
2660 clean_after_shfo_tests();
2662 init_shfo_tests();
2663 test_copy();
2664 clean_after_shfo_tests();
2666 init_shfo_tests();
2667 test_move();
2668 clean_after_shfo_tests();
2670 test_sh_create_dir();
2671 clean_after_shfo_tests();
2673 init_shfo_tests();
2674 test_sh_path_prepare();
2675 clean_after_shfo_tests();
2677 init_shfo_tests();
2678 test_sh_new_link_info();
2679 clean_after_shfo_tests();
2681 test_unicode();
2683 test_shlmenu();