push 9eb9af089d68d39110a91889d3a673043db63c4b
[wine/hacks.git] / dlls / shell32 / tests / shlfileop.c
blob81f893cf5eb67c927a68dd2565ada17ac54ee253
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 static CHAR CURR_DIR[MAX_PATH];
36 static const WCHAR UNICODE_PATH[] = {'c',':','\\',0x00c4,'\0','\0'};
37 /* "c:\Ä", or "c:\A" with diaeresis */
38 /* Double-null termination needed for pFrom field of SHFILEOPSTRUCT */
40 static HMODULE hshell32;
41 static int (WINAPI *pSHCreateDirectoryExA)(HWND, LPCSTR, LPSECURITY_ATTRIBUTES);
42 static int (WINAPI *pSHCreateDirectoryExW)(HWND, LPCWSTR, LPSECURITY_ATTRIBUTES);
43 static int (WINAPI *pSHFileOperationW)(LPSHFILEOPSTRUCTW);
44 static DWORD_PTR (WINAPI *pSHGetFileInfoW)(LPCWSTR, DWORD , SHFILEINFOW*, UINT, UINT);
45 static int (WINAPI *pSHPathPrepareForWriteA)(HWND, IUnknown*, LPCSTR, DWORD);
46 static int (WINAPI *pSHPathPrepareForWriteW)(HWND, IUnknown*, LPCWSTR, DWORD);
48 static void InitFunctionPointers(void)
50 hshell32 = GetModuleHandleA("shell32.dll");
51 pSHCreateDirectoryExA = (void*)GetProcAddress(hshell32, "SHCreateDirectoryExA");
52 pSHCreateDirectoryExW = (void*)GetProcAddress(hshell32, "SHCreateDirectoryExW");
53 pSHFileOperationW = (void*)GetProcAddress(hshell32, "SHFileOperationW");
54 pSHGetFileInfoW = (void*)GetProcAddress(hshell32, "SHGetFileInfoW");
55 pSHPathPrepareForWriteA = (void*)GetProcAddress(hshell32, "SHPathPrepareForWriteA");
56 pSHPathPrepareForWriteW = (void*)GetProcAddress(hshell32, "SHPathPrepareForWriteW");
59 /* creates a file with the specified name for tests */
60 static void createTestFile(const CHAR *name)
62 HANDLE file;
63 DWORD written;
65 file = CreateFileA(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
66 ok(file != INVALID_HANDLE_VALUE, "Failure to open file %s\n", name);
67 WriteFile(file, name, strlen(name), &written, NULL);
68 WriteFile(file, "\n", strlen("\n"), &written, NULL);
69 CloseHandle(file);
72 static void createTestFileW(const WCHAR *name)
74 HANDLE file;
76 file = CreateFileW(name, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
77 ok(file != INVALID_HANDLE_VALUE, "Failure to open file\n");
78 CloseHandle(file);
81 static BOOL file_exists(const CHAR *name)
83 return GetFileAttributesA(name) != INVALID_FILE_ATTRIBUTES;
86 static BOOL file_existsW(LPCWSTR name)
88 return GetFileAttributesW(name) != INVALID_FILE_ATTRIBUTES;
91 static BOOL file_has_content(const CHAR *name, const CHAR *content)
93 CHAR buf[MAX_PATH];
94 HANDLE file;
95 DWORD read;
97 file = CreateFileA(name, GENERIC_READ, 0, NULL, OPEN_EXISTING, 0, NULL);
98 if (file == INVALID_HANDLE_VALUE)
99 return FALSE;
100 ReadFile(file, buf, MAX_PATH - 1, &read, NULL);
101 buf[read] = 0;
102 CloseHandle(file);
103 return strcmp(buf, content)==0;
106 /* initializes the tests */
107 static void init_shfo_tests(void)
109 int len;
111 GetCurrentDirectoryA(MAX_PATH, CURR_DIR);
112 len = lstrlenA(CURR_DIR);
114 if(len && (CURR_DIR[len-1] == '\\'))
115 CURR_DIR[len-1] = 0;
117 createTestFile("test1.txt");
118 createTestFile("test2.txt");
119 createTestFile("test3.txt");
120 createTestFile("test_5.txt");
121 CreateDirectoryA("test4.txt", NULL);
122 CreateDirectoryA("testdir2", NULL);
123 CreateDirectoryA("testdir2\\nested", NULL);
124 createTestFile("testdir2\\one.txt");
125 createTestFile("testdir2\\nested\\two.txt");
128 /* cleans after tests */
129 static void clean_after_shfo_tests(void)
131 DeleteFileA("test1.txt");
132 DeleteFileA("test2.txt");
133 DeleteFileA("test3.txt");
134 DeleteFileA("test_5.txt");
135 DeleteFileA("one.txt");
136 DeleteFileA("test4.txt\\test1.txt");
137 DeleteFileA("test4.txt\\test2.txt");
138 DeleteFileA("test4.txt\\test3.txt");
139 RemoveDirectoryA("test4.txt");
140 DeleteFileA("testdir2\\one.txt");
141 DeleteFileA("testdir2\\test1.txt");
142 DeleteFileA("testdir2\\test2.txt");
143 DeleteFileA("testdir2\\test3.txt");
144 DeleteFileA("testdir2\\test4.txt\\test1.txt");
145 DeleteFileA("testdir2\\nested\\two.txt");
146 RemoveDirectoryA("testdir2\\test4.txt");
147 RemoveDirectoryA("testdir2\\nested");
148 RemoveDirectoryA("testdir2");
149 RemoveDirectoryA("c:\\testdir3");
150 DeleteFileA("nonexistent\\notreal\\test2.txt");
151 RemoveDirectoryA("nonexistent\\notreal");
152 RemoveDirectoryA("nonexistent");
156 static void test_get_file_info(void)
158 DWORD rc, rc2;
159 SHFILEINFOA shfi, shfi2;
160 SHFILEINFOW shfiw;
161 char notepad[MAX_PATH];
163 /* Test whether fields of SHFILEINFOA are always cleared */
164 memset(&shfi, 0xcf, sizeof(shfi));
165 rc=SHGetFileInfoA("", 0, &shfi, sizeof(shfi), 0);
166 ok(rc, "SHGetFileInfoA('' | 0) should not fail\n");
167 todo_wine ok(shfi.hIcon == 0, "SHGetFileInfoA('' | 0) did not clear hIcon\n");
168 todo_wine ok(shfi.szDisplayName[0] == 0, "SHGetFileInfoA('' | 0) did not clear szDisplayName[0]\n");
169 todo_wine ok(shfi.szTypeName[0] == 0, "SHGetFileInfoA('' | 0) did not clear szTypeName[0]\n");
170 ok(shfi.iIcon == 0xcfcfcfcf, "SHGetFileInfoA('' | 0) should not clear iIcon\n");
171 ok(shfi.dwAttributes == 0xcfcfcfcf, "SHGetFileInfoA('' | 0) should not clear dwAttributes\n");
173 if (pSHGetFileInfoW)
175 /* Test whether fields of SHFILEINFOW are always cleared */
176 memset(&shfiw, 0xcf, sizeof(shfiw));
177 rc=pSHGetFileInfoW(NULL, 0, &shfiw, sizeof(shfiw), 0);
178 todo_wine ok(!rc, "SHGetFileInfoW(NULL | 0) should fail\n");
179 ok(shfiw.hIcon == (HANDLE) 0xcfcfcfcf, "SHGetFileInfoW(NULL | 0) should not clear hIcon\n");
180 todo_wine ok(shfiw.szDisplayName[0] == 0xcfcf, "SHGetFileInfoW(NULL | 0) should not clear szDisplayName[0]\n");
181 todo_wine ok(shfiw.szTypeName[0] == 0xcfcf, "SHGetFileInfoW(NULL | 0) should not clear szTypeName[0]\n");
182 todo_wine ok(shfiw.iIcon == 0xcfcfcfcf, "SHGetFileInfoW(NULL | 0) should not clear iIcon\n");
183 ok(shfiw.dwAttributes == 0xcfcfcfcf, "SHGetFileInfoW(NULL | 0) should not clear dwAttributes\n");
185 else
186 win_skip("SHGetFileInfoW is not available\n");
189 /* Test some flag combinations that MSDN claims are not allowed,
190 * but which work anyway
192 memset(&shfi, 0xcf, sizeof(shfi));
193 rc=SHGetFileInfoA("c:\\nonexistent", FILE_ATTRIBUTE_DIRECTORY,
194 &shfi, sizeof(shfi),
195 SHGFI_ATTRIBUTES | SHGFI_USEFILEATTRIBUTES);
196 ok(rc, "SHGetFileInfoA(c:\\nonexistent | SHGFI_ATTRIBUTES) failed\n");
197 if (rc)
198 ok(shfi.dwAttributes != 0xcfcfcfcf, "dwFileAttributes is not set\n");
199 todo_wine ok(shfi.hIcon == 0, "SHGetFileInfoA(c:\\nonexistent | SHGFI_ATTRIBUTES) did not clear hIcon\n");
200 todo_wine ok(shfi.szDisplayName[0] == 0, "SHGetFileInfoA(c:\\nonexistent | SHGFI_ATTRIBUTES) did not clear szDisplayName[0]\n");
201 todo_wine ok(shfi.szTypeName[0] == 0, "SHGetFileInfoA(c:\\nonexistent | SHGFI_ATTRIBUTES) did not clear szTypeName[0]\n");
202 ok(shfi.iIcon == 0xcfcfcfcf, "SHGetFileInfoA(c:\\nonexistent | SHGFI_ATTRIBUTES) should not clear iIcon\n");
204 rc=SHGetFileInfoA("c:\\nonexistent", FILE_ATTRIBUTE_DIRECTORY,
205 &shfi, sizeof(shfi),
206 SHGFI_EXETYPE | SHGFI_USEFILEATTRIBUTES);
207 todo_wine ok(rc == 1, "SHGetFileInfoA(c:\\nonexistent | SHGFI_EXETYPE) returned %d\n", rc);
209 /* Test SHGFI_USEFILEATTRIBUTES support */
210 strcpy(shfi.szDisplayName, "dummy");
211 shfi.iIcon=0xdeadbeef;
212 rc=SHGetFileInfoA("c:\\nonexistent", FILE_ATTRIBUTE_DIRECTORY,
213 &shfi, sizeof(shfi),
214 SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
215 ok(rc, "SHGetFileInfoA(c:\\nonexistent) failed\n");
216 if (rc)
218 ok(strcpy(shfi.szDisplayName, "dummy") != 0, "SHGetFileInfoA(c:\\nonexistent) displayname is not set\n");
219 ok(shfi.iIcon != 0xdeadbeef, "SHGetFileInfoA(c:\\nonexistent) iIcon is not set\n");
222 /* Wine does not have a default icon for text files, and Windows 98 fails
223 * if we give it an empty executable. So use notepad.exe as the test
225 if (SearchPath(NULL, "notepad.exe", NULL, sizeof(notepad), notepad, NULL))
227 strcpy(shfi.szDisplayName, "dummy");
228 shfi.iIcon=0xdeadbeef;
229 rc=SHGetFileInfoA(notepad, GetFileAttributes(notepad),
230 &shfi, sizeof(shfi),
231 SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
232 ok(rc, "SHGetFileInfoA(%s, SHGFI_USEFILEATTRIBUTES) failed\n", notepad);
233 strcpy(shfi2.szDisplayName, "dummy");
234 shfi2.iIcon=0xdeadbeef;
235 rc2=SHGetFileInfoA(notepad, 0,
236 &shfi2, sizeof(shfi2),
237 SHGFI_ICONLOCATION);
238 ok(rc2, "SHGetFileInfoA(%s) failed\n", notepad);
239 if (rc && rc2)
241 ok(lstrcmpi(shfi2.szDisplayName, shfi.szDisplayName) == 0, "wrong display name %s != %s\n", shfi.szDisplayName, shfi2.szDisplayName);
242 ok(shfi2.iIcon == shfi.iIcon, "wrong icon index %d != %d\n", shfi.iIcon, shfi2.iIcon);
246 /* with a directory now */
247 strcpy(shfi.szDisplayName, "dummy");
248 shfi.iIcon=0xdeadbeef;
249 rc=SHGetFileInfoA("test4.txt", GetFileAttributes("test4.txt"),
250 &shfi, sizeof(shfi),
251 SHGFI_ICONLOCATION | SHGFI_USEFILEATTRIBUTES);
252 ok(rc, "SHGetFileInfoA(test4.txt/, SHGFI_USEFILEATTRIBUTES) failed\n");
253 strcpy(shfi2.szDisplayName, "dummy");
254 shfi2.iIcon=0xdeadbeef;
255 rc2=SHGetFileInfoA("test4.txt", 0,
256 &shfi2, sizeof(shfi2),
257 SHGFI_ICONLOCATION);
258 ok(rc2, "SHGetFileInfoA(test4.txt/) failed\n");
259 if (rc && rc2)
261 ok(lstrcmpi(shfi2.szDisplayName, shfi.szDisplayName) == 0, "wrong display name %s != %s\n", shfi.szDisplayName, shfi2.szDisplayName);
262 ok(shfi2.iIcon == shfi.iIcon, "wrong icon index %d != %d\n", shfi.iIcon, shfi2.iIcon);
266 static void test_get_file_info_iconlist(void)
268 /* Test retrieving a handle to the system image list, and
269 * what that returns for hIcon
271 HRESULT hr;
272 HIMAGELIST hSysImageList;
273 LPITEMIDLIST pidList;
274 SHFILEINFOA shInfoa;
275 SHFILEINFOW shInfow;
277 hr = SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &pidList);
278 if (FAILED(hr)) {
279 skip("can't get desktop pidl\n");
280 return;
283 memset(&shInfoa, 0xcf, sizeof(shInfoa));
284 hSysImageList = (HIMAGELIST) SHGetFileInfoA((const char *)pidList, 0,
285 &shInfoa, sizeof(shInfoa),
286 SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_PIDL);
287 ok(hSysImageList != INVALID_HANDLE_VALUE, "Can't get handle for CSIDL_DESKTOP imagelist\n");
288 todo_wine ok(shInfoa.hIcon == 0, "SHGetFileInfoA(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) did not clear hIcon\n");
289 todo_wine ok(shInfoa.szTypeName[0] == 0, "SHGetFileInfoA(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) did not clear szTypeName[0]\n");
290 ok(shInfoa.iIcon != 0xcfcfcfcf, "SHGetFileInfoA(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) should set iIcon\n");
291 ok(shInfoa.dwAttributes == 0xcfcfcfcf, "SHGetFileInfoA(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) should not change dwAttributes\n");
292 CloseHandle(hSysImageList);
294 if (!pSHGetFileInfoW)
296 win_skip("SHGetFileInfoW is not available\n");
297 ILFree(pidList);
298 return;
301 memset(&shInfow, 0xcf, sizeof(shInfow));
302 hSysImageList = (HIMAGELIST) pSHGetFileInfoW((const WCHAR *)pidList, 0,
303 &shInfow, sizeof(shInfow),
304 SHGFI_SYSICONINDEX | SHGFI_SMALLICON | SHGFI_PIDL);
305 ok(hSysImageList != INVALID_HANDLE_VALUE, "Can't get handle for CSIDL_DESKTOP imagelist\n");
306 todo_wine ok(shInfow.hIcon == 0, "SHGetFileInfoW(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) did not clear hIcon\n");
307 ok(shInfow.szTypeName[0] == 0, "SHGetFileInfoW(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) did not clear szTypeName[0]\n");
308 ok(shInfow.iIcon != 0xcfcfcfcf, "SHGetFileInfoW(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) should set iIcon\n");
309 ok(shInfow.dwAttributes == 0xcfcfcfcf, "SHGetFileInfoW(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) should not change dwAttributes\n");
310 CloseHandle(hSysImageList);
312 /* Various suposidly invalid flag testing */
313 memset(&shInfow, 0xcf, sizeof(shInfow));
314 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
315 SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON);
316 ok(hr != 0, "SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON Failed\n");
317 ok(shInfow.iIcon!=0xcfcfcfcf, "Icon Index Missing\n");
318 ok(shInfow.dwAttributes==0xcfcfcfcf,"dwAttributes modified\n");
320 memset(&shInfow, 0xcf, sizeof(shInfow));
321 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
322 SHGFI_ICON|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON);
323 ok(hr != 0, " SHGFI_ICON|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON Failed\n");
324 ok(shInfow.iIcon!=0xcfcfcfcf, "Icon Index Missing\n");
325 ok(shInfow.hIcon!=(HICON)0xcfcfcfcf && shInfow.hIcon!=0,"hIcon invalid\n");
326 if (shInfow.hIcon!=(HICON)0xcfcfcfcf) DestroyIcon(shInfow.hIcon);
327 todo_wine ok(shInfow.dwAttributes==0,"dwAttributes not set\n");
329 memset(&shInfow, 0xcf, sizeof(shInfow));
330 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
331 SHGFI_ICON|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_LARGEICON);
332 ok(hr != 0, "SHGFI_ICON|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_LARGEICON Failed\n");
333 ok(shInfow.iIcon!=0xcfcfcfcf, "Icon Index Missing\n");
334 ok(shInfow.hIcon!=(HICON)0xcfcfcfcf && shInfow.hIcon!=0,"hIcon invalid\n");
335 if (shInfow.hIcon != (HICON)0xcfcfcfcf) DestroyIcon(shInfow.hIcon);
336 todo_wine ok(shInfow.dwAttributes==0,"dwAttributes not set\n");
338 memset(&shInfow, 0xcf, sizeof(shInfow));
339 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
340 SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_LARGEICON);
341 ok(hr != 0, "SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_LARGEICON Failed\n");
342 ok(shInfow.iIcon!=0xcfcfcfcf, "Icon Index Missing\n");
343 ok(shInfow.dwAttributes==0xcfcfcfcf,"dwAttributes modified\n");
345 memset(&shInfow, 0xcf, sizeof(shInfow));
346 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
347 SHGFI_OPENICON|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON);
348 ok(hr != 0, "SHGFI_OPENICON|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON Failed\n");
349 todo_wine ok(shInfow.iIcon==0xcfcfcfcf, "Icon Index Modified\n");
350 ok(shInfow.dwAttributes==0xcfcfcfcf,"dwAttributes modified\n");
352 memset(&shInfow, 0xcf, sizeof(shInfow));
353 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
354 SHGFI_SHELLICONSIZE|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON);
355 ok(hr != 0, "SHGFI_SHELLICONSIZE|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON Failed\n");
356 todo_wine ok(shInfow.iIcon==0xcfcfcfcf, "Icon Index Modified\n");
357 ok(shInfow.dwAttributes==0xcfcfcfcf,"dwAttributes modified\n");
359 memset(&shInfow, 0xcf, sizeof(shInfow));
360 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
361 SHGFI_SHELLICONSIZE|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON);
362 ok(hr != 0, "SHGFI_SHELLICONSIZE|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON Failed\n");
363 todo_wine ok(shInfow.iIcon==0xcfcfcfcf, "Icon Index Modified\n");
364 ok(shInfow.dwAttributes==0xcfcfcfcf,"dwAttributes modified\n");
366 memset(&shInfow, 0xcf, sizeof(shInfow));
367 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
368 SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|
369 SHGFI_ATTRIBUTES);
370 ok(hr != 0, "SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|SHGFI_ATTRIBUTES Failed\n");
371 ok(shInfow.iIcon!=0xcfcfcfcf, "Icon Index Missing\n");
372 ok(shInfow.dwAttributes!=0xcfcfcfcf,"dwAttributes not set\n");
374 memset(&shInfow, 0xcf, sizeof(shInfow));
375 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
376 SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|
377 SHGFI_EXETYPE);
378 todo_wine ok(hr != 0, "SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|SHGFI_EXETYPE Failed\n");
379 ok(shInfow.iIcon!=0xcfcfcfcf, "Icon Index Missing\n");
380 ok(shInfow.dwAttributes==0xcfcfcfcf,"dwAttributes modified\n");
382 memset(&shInfow, 0xcf, sizeof(shInfow));
383 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
384 SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|SHGFI_EXETYPE);
385 todo_wine ok(hr != 0, "SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|SHGFI_EXETYPE Failed\n");
386 todo_wine ok(shInfow.iIcon==0xcfcfcfcf, "Icon Index Modified\n");
387 ok(shInfow.dwAttributes==0xcfcfcfcf,"dwAttributes modified\n");
389 memset(&shInfow, 0xcf, sizeof(shInfow));
390 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
391 SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|SHGFI_ATTRIBUTES);
392 ok(hr != 0, "SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|SHGFI_ATTRIBUTES Failed\n");
393 todo_wine ok(shInfow.iIcon==0xcfcfcfcf, "Icon Index Modified\n");
394 ok(shInfow.dwAttributes!=0xcfcfcfcf,"dwAttributes not set\n");
396 memset(&shInfow, 0xcf, sizeof(shInfow));
397 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
398 SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|
399 SHGFI_ATTRIBUTES);
400 ok(hr != 0, "SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_ATTRIBUTES Failed\n");
401 ok(shInfow.iIcon!=0xcfcfcfcf, "Icon Index Missing\n");
402 ok(shInfow.dwAttributes!=0xcfcfcfcf,"dwAttributes not set\n");
404 memset(&shInfow, 0xcf, sizeof(shInfow));
405 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
406 SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_EXETYPE);
407 todo_wine ok(hr != 0, "SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_EXETYPE Failed\n");
408 ok(shInfow.iIcon!=0xcfcfcfcf, "Icon Index Missing\n");
409 ok(shInfow.dwAttributes==0xcfcfcfcf,"dwAttributes modified\n");
411 memset(&shInfow, 0xcf, sizeof(shInfow));
412 hr = pSHGetFileInfoW((const WCHAR *)pidList, 0, &shInfow, sizeof(shInfow),
413 SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_EXETYPE);
414 todo_wine ok(hr != 0, "SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_EXETYPE 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_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_ATTRIBUTES);
421 ok(hr != 0, "SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_ATTRIBUTES Failed\n");
422 todo_wine ok(shInfow.iIcon==0xcfcfcfcf, "Icon Index Modified\n");
423 ok(shInfow.dwAttributes!=0xcfcfcfcf,"dwAttributes not set\n");
425 ILFree(pidList);
430 puts into the specified buffer file names with current directory.
431 files - string with file names, separated by null characters. Ends on a double
432 null characters
434 static void set_curr_dir_path(CHAR *buf, const CHAR* files)
436 buf[0] = 0;
437 while (files[0])
439 strcpy(buf, CURR_DIR);
440 buf += strlen(buf);
441 buf[0] = '\\';
442 buf++;
443 strcpy(buf, files);
444 buf += strlen(buf) + 1;
445 files += strlen(files) + 1;
447 buf[0] = 0;
451 /* tests the FO_DELETE action */
452 static void test_delete(void)
454 SHFILEOPSTRUCTA shfo;
455 DWORD ret;
456 CHAR buf[sizeof(CURR_DIR)+sizeof("/test?.txt")+1];
458 sprintf(buf, "%s\\%s", CURR_DIR, "test?.txt");
459 buf[strlen(buf) + 1] = '\0';
461 shfo.hwnd = NULL;
462 shfo.wFunc = FO_DELETE;
463 shfo.pFrom = buf;
464 shfo.pTo = "\0";
465 shfo.fFlags = FOF_FILESONLY | FOF_NOCONFIRMATION | FOF_SILENT;
466 shfo.hNameMappings = NULL;
467 shfo.lpszProgressTitle = NULL;
469 ok(!SHFileOperationA(&shfo), "Deletion was not successful\n");
470 ok(file_exists("test4.txt"), "Directory should not have been removed\n");
471 ok(!file_exists("test1.txt"), "File should have been removed\n");
473 ret = SHFileOperationA(&shfo);
474 ok(!ret, "Directory exists, but is not removed, ret=%d\n", ret);
475 ok(file_exists("test4.txt"), "Directory should not have been removed\n");
477 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
479 ok(!SHFileOperationA(&shfo), "Directory is not removed\n");
480 ok(!file_exists("test4.txt"), "Directory should have been removed\n");
482 ret = SHFileOperationA(&shfo);
483 ok(!ret, "The requested file does not exist, ret=%d\n", ret);
485 init_shfo_tests();
486 sprintf(buf, "%s\\%s", CURR_DIR, "test4.txt");
487 buf[strlen(buf) + 1] = '\0';
488 ok(MoveFileA("test1.txt", "test4.txt\\test1.txt"), "Filling the subdirectory failed\n");
489 ok(!SHFileOperationA(&shfo), "Directory is not removed\n");
490 ok(!file_exists("test4.txt"), "Directory is not removed\n");
492 init_shfo_tests();
493 shfo.pFrom = "test1.txt\0test4.txt\0";
494 ok(!SHFileOperationA(&shfo), "Directory and a file are not removed\n");
495 ok(!file_exists("test1.txt"), "The file should have been removed\n");
496 ok(!file_exists("test4.txt"), "Directory should have been removed\n");
497 ok(file_exists("test2.txt"), "This file should not have been removed\n");
499 /* FOF_FILESONLY does not delete a dir matching a wildcard */
500 init_shfo_tests();
501 shfo.fFlags |= FOF_FILESONLY;
502 shfo.pFrom = "*.txt\0";
503 ok(!SHFileOperation(&shfo), "Failed to delete files\n");
504 ok(!file_exists("test1.txt"), "test1.txt should have been removed\n");
505 ok(!file_exists("test_5.txt"), "test_5.txt should have been removed\n");
506 ok(file_exists("test4.txt"), "test4.txt should not have been removed\n");
508 /* FOF_FILESONLY only deletes a dir if explicitly specified */
509 init_shfo_tests();
510 shfo.pFrom = "test_?.txt\0test4.txt\0";
511 ok(!SHFileOperation(&shfo), "Failed to delete files and directory\n");
512 ok(!file_exists("test4.txt"), "test4.txt should have been removed\n");
513 ok(!file_exists("test_5.txt"), "test_5.txt should have been removed\n");
514 ok(file_exists("test1.txt"), "test1.txt should not have been removed\n");
516 /* try to delete an invalid filename */
517 if (0) {
518 /* this crashes on win9x */
519 init_shfo_tests();
520 shfo.pFrom = "\0";
521 shfo.fFlags &= ~FOF_FILESONLY;
522 shfo.fAnyOperationsAborted = FALSE;
523 ret = SHFileOperation(&shfo);
524 ok(ret == ERROR_ACCESS_DENIED, "Expected ERROR_ACCESS_DENIED, got %d\n", ret);
525 ok(!shfo.fAnyOperationsAborted, "Expected no aborted operations\n");
526 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
529 /* try an invalid function */
530 init_shfo_tests();
531 shfo.pFrom = "test1.txt\0";
532 shfo.wFunc = 0;
533 ret = SHFileOperation(&shfo);
534 ok(ret == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", ret);
535 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
537 /* try an invalid list, only one null terminator */
538 if (0) {
539 /* this crashes on win9x */
540 init_shfo_tests();
541 shfo.pFrom = "";
542 shfo.wFunc = FO_DELETE;
543 ret = SHFileOperation(&shfo);
544 ok(ret == ERROR_ACCESS_DENIED, "Expected ERROR_ACCESS_DENIED, got %d\n", ret);
545 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
548 /* delete a dir, and then a file inside the dir, same as
549 * deleting a nonexistent file
551 init_shfo_tests();
552 shfo.pFrom = "testdir2\0testdir2\\one.txt\0";
553 shfo.wFunc = FO_DELETE;
554 ret = SHFileOperation(&shfo);
555 ok(ret == ERROR_PATH_NOT_FOUND, "Expected ERROR_PATH_NOT_FOUND, got %d\n", ret);
556 ok(!file_exists("testdir2"), "Expected testdir2 to not exist\n");
557 ok(!file_exists("testdir2\\one.txt"), "Expected testdir2\\one.txt to not exist\n");
559 /* try the FOF_NORECURSION flag, continues deleting subdirs */
560 init_shfo_tests();
561 shfo.pFrom = "testdir2\0";
562 shfo.fFlags |= FOF_NORECURSION;
563 ret = SHFileOperation(&shfo);
564 ok(ret == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", ret);
565 ok(!file_exists("testdir2\\one.txt"), "Expected testdir2\\one.txt to not exist\n");
566 ok(!file_exists("testdir2\\nested"), "Expected testdir2\\nested to exist\n");
569 /* tests the FO_RENAME action */
570 static void test_rename(void)
572 SHFILEOPSTRUCTA shfo, shfo2;
573 CHAR from[5*MAX_PATH];
574 CHAR to[5*MAX_PATH];
575 DWORD retval;
577 shfo.hwnd = NULL;
578 shfo.wFunc = FO_RENAME;
579 shfo.pFrom = from;
580 shfo.pTo = to;
581 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
582 shfo.hNameMappings = NULL;
583 shfo.lpszProgressTitle = NULL;
585 set_curr_dir_path(from, "test1.txt\0");
586 set_curr_dir_path(to, "test4.txt\0");
587 ok(SHFileOperationA(&shfo), "File is not renamed moving to other directory "
588 "when specifying directory name only\n");
589 ok(file_exists("test1.txt"), "The file is removed\n");
591 set_curr_dir_path(from, "test3.txt\0");
592 set_curr_dir_path(to, "test4.txt\\test1.txt\0");
593 ok(!SHFileOperationA(&shfo), "File is renamed moving to other directory\n");
594 ok(file_exists("test4.txt\\test1.txt"), "The file is not renamed\n");
596 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
597 set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
598 retval = SHFileOperationA(&shfo); /* W98 returns 0, W2K and newer returns ERROR_GEN_FAILURE, both do nothing */
599 ok(!retval || retval == ERROR_GEN_FAILURE || retval == ERROR_INVALID_TARGET_HANDLE,
600 "Can't rename many files, retval = %d\n", retval);
601 ok(file_exists("test1.txt"), "The file is renamed - many files are specified\n");
603 memcpy(&shfo2, &shfo, sizeof(SHFILEOPSTRUCTA));
604 shfo2.fFlags |= FOF_MULTIDESTFILES;
606 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
607 set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
608 retval = SHFileOperationA(&shfo2); /* W98 returns 0, W2K and newer returns ERROR_GEN_FAILURE, both do nothing */
609 ok(!retval || retval == ERROR_GEN_FAILURE || retval == ERROR_INVALID_TARGET_HANDLE,
610 "Can't rename many files, retval = %d\n", retval);
611 ok(file_exists("test1.txt"), "The file is not renamed - many files are specified\n");
613 set_curr_dir_path(from, "test1.txt\0");
614 set_curr_dir_path(to, "test6.txt\0");
615 retval = SHFileOperationA(&shfo);
616 ok(!retval, "Rename file failed, retval = %d\n", retval);
617 ok(!file_exists("test1.txt"), "The file is not renamed\n");
618 ok(file_exists("test6.txt"), "The file is not renamed\n");
620 set_curr_dir_path(from, "test6.txt\0");
621 set_curr_dir_path(to, "test1.txt\0");
622 retval = SHFileOperationA(&shfo);
623 ok(!retval, "Rename file back failed, retval = %d\n", retval);
625 set_curr_dir_path(from, "test4.txt\0");
626 set_curr_dir_path(to, "test6.txt\0");
627 retval = SHFileOperationA(&shfo);
628 ok(!retval, "Rename dir failed, retval = %d\n", retval);
629 ok(!file_exists("test4.txt"), "The dir is not renamed\n");
630 ok(file_exists("test6.txt"), "The dir is not renamed\n");
632 set_curr_dir_path(from, "test6.txt\0");
633 set_curr_dir_path(to, "test4.txt\0");
634 retval = SHFileOperationA(&shfo);
635 ok(!retval, "Rename dir back failed, retval = %d\n", retval);
637 /* try to rename more than one file to a single file */
638 shfo.pFrom = "test1.txt\0test2.txt\0";
639 shfo.pTo = "a.txt\0";
640 retval = SHFileOperationA(&shfo);
641 ok(retval == ERROR_GEN_FAILURE, "Expected ERROR_GEN_FAILURE, got %d\n", retval);
642 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
643 ok(file_exists("test2.txt"), "Expected test2.txt to exist\n");
645 /* pFrom doesn't exist */
646 shfo.pFrom = "idontexist\0";
647 shfo.pTo = "newfile\0";
648 retval = SHFileOperationA(&shfo);
649 ok(retval == 1026, "Expected 1026, got %d\n", retval);
650 ok(!file_exists("newfile"), "Expected newfile to not exist\n");
652 /* pTo already exist */
653 shfo.pFrom = "test1.txt\0";
654 shfo.pTo = "test2.txt\0";
655 retval = SHFileOperationA(&shfo);
656 ok(retval == ERROR_ALREADY_EXISTS, "Expected ERROR_ALREADY_EXISTS, got %d\n", retval);
658 /* pFrom is valid, but pTo is empty */
659 shfo.pFrom = "test1.txt\0";
660 shfo.pTo = "\0";
661 retval = SHFileOperationA(&shfo);
662 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
663 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
665 /* pFrom is empty */
666 shfo.pFrom = "\0";
667 retval = SHFileOperationA(&shfo);
668 ok(retval == ERROR_ACCESS_DENIED, "Expected ERROR_ACCESS_DENIED, got %d\n", retval);
670 /* pFrom is NULL, commented out because it crashes on nt 4.0 */
671 #if 0
672 shfo.pFrom = NULL;
673 retval = SHFileOperationA(&shfo);
674 ok(retval == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", retval);
675 #endif
678 /* tests the FO_COPY action */
679 static void test_copy(void)
681 SHFILEOPSTRUCTA shfo, shfo2;
682 CHAR from[5*MAX_PATH];
683 CHAR to[5*MAX_PATH];
684 FILEOP_FLAGS tmp_flags;
685 DWORD retval;
686 LPSTR ptr;
688 shfo.hwnd = NULL;
689 shfo.wFunc = FO_COPY;
690 shfo.pFrom = from;
691 shfo.pTo = to;
692 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
693 shfo.hNameMappings = NULL;
694 shfo.lpszProgressTitle = NULL;
696 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
697 set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
698 ok(SHFileOperationA(&shfo), "Can't copy many files\n");
699 ok(!file_exists("test6.txt"), "The file is not copied - many files are "
700 "specified as a target\n");
702 memcpy(&shfo2, &shfo, sizeof(SHFILEOPSTRUCTA));
703 shfo2.fFlags |= FOF_MULTIDESTFILES;
705 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
706 set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
707 ok(!SHFileOperationA(&shfo2), "Can't copy many files\n");
708 ok(file_exists("test6.txt"), "The file is copied - many files are "
709 "specified as a target\n");
710 DeleteFileA("test6.txt");
711 DeleteFileA("test7.txt");
712 RemoveDirectoryA("test8.txt");
714 /* number of sources do not correspond to number of targets */
715 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
716 set_curr_dir_path(to, "test6.txt\0test7.txt\0");
717 ok(SHFileOperationA(&shfo2), "Can't copy many files\n");
718 ok(!file_exists("test6.txt"), "The file is not copied - many files are "
719 "specified as a target\n");
721 set_curr_dir_path(from, "test1.txt\0");
722 set_curr_dir_path(to, "test4.txt\0");
723 ok(!SHFileOperationA(&shfo), "Prepare test to check how directories are copied recursively\n");
724 ok(file_exists("test4.txt\\test1.txt"), "The file is copied\n");
726 set_curr_dir_path(from, "test?.txt\0");
727 set_curr_dir_path(to, "testdir2\0");
728 ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n");
729 ok(!file_exists("testdir2\\test4.txt"), "The directory is not copied yet\n");
730 ok(!SHFileOperationA(&shfo), "Files and directories are copied to directory\n");
731 ok(file_exists("testdir2\\test1.txt"), "The file is copied\n");
732 ok(file_exists("testdir2\\test4.txt"), "The directory is copied\n");
733 ok(file_exists("testdir2\\test4.txt\\test1.txt"), "The file in subdirectory is copied\n");
734 clean_after_shfo_tests();
736 init_shfo_tests();
737 shfo.fFlags |= FOF_FILESONLY;
738 ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n");
739 ok(!file_exists("testdir2\\test4.txt"), "The directory is not copied yet\n");
740 ok(!SHFileOperationA(&shfo), "Files are copied to other directory\n");
741 ok(file_exists("testdir2\\test1.txt"), "The file is copied\n");
742 ok(!file_exists("testdir2\\test4.txt"), "The directory is copied\n");
743 clean_after_shfo_tests();
745 init_shfo_tests();
746 set_curr_dir_path(from, "test1.txt\0test2.txt\0");
747 ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n");
748 ok(!file_exists("testdir2\\test2.txt"), "The file is not copied yet\n");
749 ok(!SHFileOperationA(&shfo), "Files are copied to other directory\n");
750 ok(file_exists("testdir2\\test1.txt"), "The file is copied\n");
751 ok(file_exists("testdir2\\test2.txt"), "The file is copied\n");
752 clean_after_shfo_tests();
754 /* Copying multiple files with one not existing as source, fails the
755 entire operation in Win98/ME/2K/XP, but not in 95/NT */
756 init_shfo_tests();
757 tmp_flags = shfo.fFlags;
758 set_curr_dir_path(from, "test1.txt\0test10.txt\0test2.txt\0");
759 ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n");
760 ok(!file_exists("testdir2\\test2.txt"), "The file is not copied yet\n");
761 retval = SHFileOperationA(&shfo);
762 if (!retval)
763 /* Win 95/NT returns success but copies only the files up to the nonexistent source */
764 ok(file_exists("testdir2\\test1.txt"), "The file is not copied\n");
765 else
767 /* Win 98/ME/2K/XP fail the entire operation with return code 1026 if one source file does not exist */
768 ok(retval == 1026, "Files are copied to other directory\n");
769 ok(!file_exists("testdir2\\test1.txt"), "The file is copied\n");
771 ok(!file_exists("testdir2\\test2.txt"), "The file is copied\n");
772 shfo.fFlags = tmp_flags;
774 /* copy into a nonexistent directory */
775 init_shfo_tests();
776 shfo.fFlags = FOF_NOCONFIRMMKDIR;
777 set_curr_dir_path(from, "test1.txt\0");
778 set_curr_dir_path(to, "nonexistent\\notreal\\test2.txt\0");
779 retval= SHFileOperation(&shfo);
780 ok(!retval, "Error copying into nonexistent directory\n");
781 ok(file_exists("nonexistent"), "nonexistent not created\n");
782 ok(file_exists("nonexistent\\notreal"), "nonexistent\\notreal not created\n");
783 ok(file_exists("nonexistent\\notreal\\test2.txt"), "Directory not created\n");
784 ok(!file_exists("nonexistent\\notreal\\test1.txt"), "test1.txt should not exist\n");
786 /* a relative dest directory is OK */
787 clean_after_shfo_tests();
788 init_shfo_tests();
789 shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0";
790 shfo.pTo = "testdir2\0";
791 retval = SHFileOperation(&shfo);
792 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
793 ok(file_exists("testdir2\\test1.txt"), "Expected testdir2\\test1 to exist\n");
795 /* try to copy files to a file */
796 clean_after_shfo_tests();
797 init_shfo_tests();
798 shfo.pFrom = from;
799 shfo.pTo = to;
800 /* suppress the error-dialog in win9x here */
801 shfo.fFlags |= FOF_NOERRORUI;
802 set_curr_dir_path(from, "test1.txt\0test2.txt\0");
803 set_curr_dir_path(to, "test3.txt\0");
804 retval = SHFileOperation(&shfo);
805 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
806 ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n");
807 ok(!file_exists("test3.txt\\test2.txt"), "Expected test3.txt\\test2.txt to not exist\n");
809 /* try to copy many files to nonexistent directory */
810 DeleteFile(to);
811 shfo.fFlags &= ~FOF_NOERRORUI;
812 shfo.fAnyOperationsAborted = FALSE;
813 retval = SHFileOperation(&shfo);
814 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
815 ok(DeleteFile("test3.txt\\test1.txt"), "Expected test3.txt\\test1.txt to exist\n");
816 ok(DeleteFile("test3.txt\\test2.txt"), "Expected test3.txt\\test1.txt to exist\n");
817 ok(RemoveDirectory(to), "Expected test3.txt to exist\n");
819 /* send in FOF_MULTIDESTFILES with too many destination files */
820 init_shfo_tests();
821 shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0";
822 shfo.pTo = "testdir2\\a.txt\0testdir2\\b.txt\0testdir2\\c.txt\0testdir2\\d.txt\0";
823 shfo.fFlags |= FOF_NOERRORUI | FOF_MULTIDESTFILES;
824 retval = SHFileOperation(&shfo);
825 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
826 ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n");
827 ok(!file_exists("testdir2\\a.txt"), "Expected testdir2\\a.txt to not exist\n");
829 /* send in FOF_MULTIDESTFILES with too many destination files */
830 shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0";
831 shfo.pTo = "e.txt\0f.txt\0";
832 shfo.fAnyOperationsAborted = FALSE;
833 retval = SHFileOperation(&shfo);
834 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
835 ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n");
836 ok(!file_exists("e.txt"), "Expected e.txt to not exist\n");
838 /* use FOF_MULTIDESTFILES with files and a source directory */
839 shfo.pFrom = "test1.txt\0test2.txt\0test4.txt\0";
840 shfo.pTo = "testdir2\\a.txt\0testdir2\\b.txt\0testdir2\\c.txt\0";
841 shfo.fAnyOperationsAborted = FALSE;
842 retval = SHFileOperation(&shfo);
843 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
844 ok(DeleteFile("testdir2\\a.txt"), "Expected testdir2\\a.txt to exist\n");
845 ok(DeleteFile("testdir2\\b.txt"), "Expected testdir2\\b.txt to exist\n");
846 ok(RemoveDirectory("testdir2\\c.txt"), "Expected testdir2\\c.txt to exist\n");
848 /* try many dest files without FOF_MULTIDESTFILES flag */
849 shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0";
850 shfo.pTo = "a.txt\0b.txt\0c.txt\0";
851 shfo.fAnyOperationsAborted = FALSE;
852 shfo.fFlags &= ~FOF_MULTIDESTFILES;
853 retval = SHFileOperation(&shfo);
854 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
855 ok(!file_exists("a.txt"), "Expected a.txt to not exist\n");
857 /* try a glob */
858 shfo.pFrom = "test?.txt\0";
859 shfo.pTo = "testdir2\0";
860 shfo.fFlags &= ~FOF_MULTIDESTFILES;
861 retval = SHFileOperation(&shfo);
862 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
863 ok(file_exists("testdir2\\test1.txt"), "Expected testdir2\\test1.txt to exist\n");
865 /* try a glob with FOF_FILESONLY */
866 clean_after_shfo_tests();
867 init_shfo_tests();
868 shfo.pFrom = "test?.txt\0";
869 shfo.fFlags |= FOF_FILESONLY;
870 retval = SHFileOperation(&shfo);
871 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
872 ok(file_exists("testdir2\\test1.txt"), "Expected testdir2\\test1.txt to exist\n");
873 ok(!file_exists("testdir2\\test4.txt"), "Expected testdir2\\test4.txt to not exist\n");
875 /* try a glob with FOF_MULTIDESTFILES and the same number
876 * of dest files that we would expect
878 clean_after_shfo_tests();
879 init_shfo_tests();
880 shfo.pTo = "testdir2\\a.txt\0testdir2\\b.txt\0testdir2\\c.txt\0testdir2\\d.txt\0";
881 shfo.fFlags &= ~FOF_FILESONLY;
882 shfo.fFlags |= FOF_MULTIDESTFILES;
883 retval = SHFileOperation(&shfo);
884 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
885 ok(shfo.fAnyOperationsAborted, "Expected aborted operations\n");
886 ok(!file_exists("testdir2\\a.txt"), "Expected testdir2\\test1.txt to not exist\n");
887 ok(!RemoveDirectory("b.txt"), "b.txt should not exist\n");
889 /* copy one file to two others, second is ignored */
890 clean_after_shfo_tests();
891 init_shfo_tests();
892 shfo.pFrom = "test1.txt\0";
893 shfo.pTo = "b.txt\0c.txt\0";
894 shfo.fAnyOperationsAborted = FALSE;
895 retval = SHFileOperation(&shfo);
896 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
897 ok(DeleteFile("b.txt"), "Expected b.txt to exist\n");
898 ok(!DeleteFile("c.txt"), "Expected c.txt to not exist\n");
900 /* copy two file to three others, all fail */
901 shfo.pFrom = "test1.txt\0test2.txt\0";
902 shfo.pTo = "b.txt\0c.txt\0d.txt\0";
903 retval = SHFileOperation(&shfo);
904 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
905 ok(shfo.fAnyOperationsAborted, "Expected operations to be aborted\n");
906 ok(!DeleteFile("b.txt"), "Expected b.txt to not exist\n");
908 /* copy one file and one directory to three others */
909 shfo.pFrom = "test1.txt\0test4.txt\0";
910 shfo.pTo = "b.txt\0c.txt\0d.txt\0";
911 shfo.fAnyOperationsAborted = FALSE;
912 retval = SHFileOperation(&shfo);
913 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
914 ok(shfo.fAnyOperationsAborted, "Expected operations to be aborted\n");
915 ok(!DeleteFile("b.txt"), "Expected b.txt to not exist\n");
916 ok(!DeleteFile("c.txt"), "Expected c.txt to not exist\n");
918 /* copy a directory with a file beneath it, plus some files */
919 createTestFile("test4.txt\\a.txt");
920 shfo.pFrom = "test4.txt\0test1.txt\0";
921 shfo.pTo = "testdir2\0";
922 shfo.fFlags &= ~FOF_MULTIDESTFILES;
923 shfo.fAnyOperationsAborted = FALSE;
924 retval = SHFileOperation(&shfo);
925 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
926 ok(DeleteFile("testdir2\\test1.txt"), "Expected newdir\\test1.txt to exist\n");
927 ok(DeleteFile("testdir2\\test4.txt\\a.txt"), "Expected a.txt to exist\n");
928 ok(RemoveDirectory("testdir2\\test4.txt"), "Expected testdir2\\test4.txt to exist\n");
930 /* copy one directory and a file in that dir to another dir */
931 shfo.pFrom = "test4.txt\0test4.txt\\a.txt\0";
932 shfo.pTo = "testdir2\0";
933 retval = SHFileOperation(&shfo);
934 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
935 ok(DeleteFile("testdir2\\test4.txt\\a.txt"), "Expected a.txt to exist\n");
936 ok(DeleteFile("testdir2\\a.txt"), "Expected testdir2\\a.txt to exist\n");
938 /* copy a file in a directory first, and then the directory to a nonexistent dir */
939 shfo.pFrom = "test4.txt\\a.txt\0test4.txt\0";
940 shfo.pTo = "nonexistent\0";
941 retval = SHFileOperation(&shfo);
942 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
943 ok(shfo.fAnyOperationsAborted, "Expected operations to be aborted\n");
944 ok(!file_exists("nonexistent\\test4.txt"), "Expected nonexistent\\test4.txt to not exist\n");
945 DeleteFile("test4.txt\\a.txt");
947 /* destination is same as source file */
948 shfo.pFrom = "test1.txt\0test2.txt\0test3.txt\0";
949 shfo.pTo = "b.txt\0test2.txt\0c.txt\0";
950 shfo.fAnyOperationsAborted = FALSE;
951 shfo.fFlags = FOF_NOERRORUI | FOF_MULTIDESTFILES;
952 retval = SHFileOperation(&shfo);
953 ok(retval == ERROR_NO_MORE_SEARCH_HANDLES,
954 "Expected ERROR_NO_MORE_SEARCH_HANDLES, got %d\n", retval);
955 ok(!shfo.fAnyOperationsAborted, "Expected no operations to be aborted\n");
956 ok(DeleteFile("b.txt"), "Expected b.txt to exist\n");
957 ok(!file_exists("c.txt"), "Expected c.txt to not exist\n");
959 /* destination is same as source directory */
960 shfo.pFrom = "test1.txt\0test4.txt\0test3.txt\0";
961 shfo.pTo = "b.txt\0test4.txt\0c.txt\0";
962 shfo.fAnyOperationsAborted = FALSE;
963 retval = SHFileOperation(&shfo);
964 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
965 ok(DeleteFile("b.txt"), "Expected b.txt to exist\n");
966 ok(!file_exists("c.txt"), "Expected c.txt to not exist\n");
968 /* copy a directory into itself, error displayed in UI */
969 shfo.pFrom = "test4.txt\0";
970 shfo.pTo = "test4.txt\\newdir\0";
971 shfo.fFlags &= ~FOF_MULTIDESTFILES;
972 shfo.fAnyOperationsAborted = FALSE;
973 retval = SHFileOperation(&shfo);
974 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
975 ok(!RemoveDirectory("test4.txt\\newdir"), "Expected test4.txt\\newdir to not exist\n");
977 /* copy a directory to itself, error displayed in UI */
978 shfo.pFrom = "test4.txt\0";
979 shfo.pTo = "test4.txt\0";
980 shfo.fAnyOperationsAborted = FALSE;
981 retval = SHFileOperation(&shfo);
982 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
984 /* copy a file into a directory, and the directory into itself */
985 shfo.pFrom = "test1.txt\0test4.txt\0";
986 shfo.pTo = "test4.txt\0";
987 shfo.fAnyOperationsAborted = FALSE;
988 shfo.fFlags |= FOF_NOCONFIRMATION;
989 retval = SHFileOperation(&shfo);
990 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
991 ok(DeleteFile("test4.txt\\test1.txt"), "Expected test4.txt\\test1.txt to exist\n");
993 /* copy a file to a file, and the directory into itself */
994 shfo.pFrom = "test1.txt\0test4.txt\0";
995 shfo.pTo = "test4.txt\\a.txt\0";
996 shfo.fAnyOperationsAborted = FALSE;
997 retval = SHFileOperation(&shfo);
998 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
999 ok(!file_exists("test4.txt\\a.txt"), "Expected test4.txt\\a.txt to not exist\n");
1001 /* copy a nonexistent file to a nonexistent directory */
1002 shfo.pFrom = "e.txt\0";
1003 shfo.pTo = "nonexistent\0";
1004 shfo.fAnyOperationsAborted = FALSE;
1005 retval = SHFileOperation(&shfo);
1006 ok(retval == 1026, "Expected 1026, got %d\n", retval);
1007 ok(!file_exists("nonexistent\\e.txt"), "Expected nonexistent\\e.txt to not exist\n");
1008 ok(!file_exists("nonexistent"), "Expected nonexistent to not exist\n");
1010 /* Overwrite tests */
1011 clean_after_shfo_tests();
1012 init_shfo_tests();
1013 shfo.fFlags = FOF_NOCONFIRMATION;
1014 shfo.pFrom = "test1.txt\0";
1015 shfo.pTo = "test2.txt\0";
1016 shfo.fAnyOperationsAborted = FALSE;
1017 /* without FOF_NOCONFIRMATION the confirmation is Yes/No */
1018 retval = SHFileOperation(&shfo);
1019 ok(retval == 0, "Expected 0, got %d\n", retval);
1020 ok(file_has_content("test2.txt", "test1.txt\n"), "The file was not copied\n");
1022 shfo.pFrom = "test3.txt\0test1.txt\0";
1023 shfo.pTo = "test2.txt\0one.txt\0";
1024 shfo.fFlags = FOF_NOCONFIRMATION | FOF_MULTIDESTFILES;
1025 /* without FOF_NOCONFIRMATION the confirmation is Yes/Yes to All/No/Cancel */
1026 retval = SHFileOperation(&shfo);
1027 ok(retval == 0, "Expected 0, got %d\n", retval);
1028 ok(file_has_content("test2.txt", "test3.txt\n"), "The file was not copied\n");
1030 shfo.pFrom = "one.txt\0";
1031 shfo.pTo = "testdir2\0";
1032 shfo.fFlags = FOF_NOCONFIRMATION;
1033 /* without FOF_NOCONFIRMATION the confirmation is Yes/No */
1034 retval = SHFileOperation(&shfo);
1035 ok(retval == 0, "Expected 0, got %d\n", retval);
1036 ok(file_has_content("testdir2\\one.txt", "test1.txt\n"), "The file was not copied\n");
1038 createTestFile("test4.txt\\test1.txt");
1039 shfo.pFrom = "test4.txt\0";
1040 shfo.pTo = "testdir2\0";
1041 shfo.fFlags = FOF_NOCONFIRMATION;
1042 ok(!SHFileOperation(&shfo), "First SHFileOperation failed\n");
1043 createTestFile("test4.txt\\.\\test1.txt"); /* modify the content of the file */
1044 /* without FOF_NOCONFIRMATION the confirmation is "This folder already contains a folder named ..." */
1045 retval = SHFileOperation(&shfo);
1046 ok(retval == 0, "Expected 0, got %d\n", retval);
1047 ok(file_has_content("testdir2\\test4.txt\\test1.txt", "test4.txt\\.\\test1.txt\n"), "The file was not copied\n");
1049 createTestFile("one.txt");
1051 /* pFrom contains bogus 2nd name longer than MAX_PATH */
1052 memset(from, 'a', MAX_PATH*2);
1053 memset(from+MAX_PATH*2, 0, 2);
1054 lstrcpyA(from, "one.txt");
1055 shfo.pFrom = from;
1056 shfo.pTo = "two.txt\0";
1057 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1058 retval = SHFileOperation(&shfo);
1059 ok(retval == 1148 || retval == 1026 ||
1060 retval == ERROR_ACCESS_DENIED, /* win2k */
1061 "Expected 1148, 1026 or ERROR_ACCESS_DENIED, got %d\n", retval);
1062 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1063 ok(!DeleteFileA("two.txt"), "Expected file to not exist\n");
1065 createTestFile("one.txt");
1067 /* pTo contains bogus 2nd name longer than MAX_PATH */
1068 memset(to, 'a', MAX_PATH*2);
1069 memset(to+MAX_PATH*2, 0, 2);
1070 lstrcpyA(to, "two.txt");
1071 shfo.pFrom = "one.txt\0";
1072 shfo.pTo = to;
1073 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1074 retval = SHFileOperation(&shfo);
1075 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1076 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1077 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1079 createTestFile("one.txt");
1081 /* no FOF_MULTIDESTFILES, two files in pTo */
1082 shfo.pFrom = "one.txt\0";
1083 shfo.pTo = "two.txt\0three.txt\0";
1084 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1085 retval = SHFileOperation(&shfo);
1086 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1087 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1088 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1090 createTestFile("one.txt");
1092 /* both pFrom and pTo contain bogus 2nd names longer than MAX_PATH */
1093 memset(from, 'a', MAX_PATH*2);
1094 memset(from+MAX_PATH*2, 0, 2);
1095 memset(to, 'a', MAX_PATH*2);
1096 memset(to+MAX_PATH*2, 0, 2);
1097 lstrcpyA(from, "one.txt");
1098 lstrcpyA(to, "two.txt");
1099 shfo.pFrom = from;
1100 shfo.pTo = to;
1101 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1102 retval = SHFileOperation(&shfo);
1103 ok(retval == 1148 || retval == 1026 ||
1104 retval == ERROR_ACCESS_DENIED, /* win2k */
1105 "Expected 1148, 1026 or ERROR_ACCESS_DENIED, got %d\n", retval);
1106 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1107 ok(!DeleteFileA("two.txt"), "Expected file to not exist\n");
1109 createTestFile("one.txt");
1111 /* pTo contains bogus 2nd name longer than MAX_PATH, FOF_MULTIDESTFILES */
1112 memset(to, 'a', MAX_PATH*2);
1113 memset(to+MAX_PATH*2, 0, 2);
1114 lstrcpyA(to, "two.txt");
1115 shfo.pFrom = "one.txt\0";
1116 shfo.pTo = to;
1117 shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION |
1118 FOF_SILENT | FOF_NOERRORUI;
1119 retval = SHFileOperation(&shfo);
1120 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1121 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1122 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1124 createTestFile("one.txt");
1125 createTestFile("two.txt");
1127 /* pTo contains bogus 2nd name longer than MAX_PATH,
1128 * multiple source files,
1129 * dest directory does not exist
1131 memset(to, 'a', 2 * MAX_PATH);
1132 memset(to+MAX_PATH*2, 0, 2);
1133 lstrcpyA(to, "threedir");
1134 shfo.pFrom = "one.txt\0two.txt\0";
1135 shfo.pTo = to;
1136 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1137 retval = SHFileOperation(&shfo);
1138 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
1139 ok(!DeleteFileA("threedir\\one.txt"), "Expected file to not exist\n");
1140 ok(!DeleteFileA("threedir\\two.txt"), "Expected file to not exist\n");
1141 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1142 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1143 ok(!DeleteFileA("threedir"), "Expected file to not exist\n");
1144 ok(!RemoveDirectoryA("threedir"), "Expected dir to not exist\n");
1146 createTestFile("one.txt");
1147 createTestFile("two.txt");
1148 CreateDirectoryA("threedir", NULL);
1150 /* pTo contains bogus 2nd name longer than MAX_PATH,
1151 * multiple source files,
1152 * dest directory does exist
1154 memset(to, 'a', 2 * MAX_PATH);
1155 memset(to+MAX_PATH*2, 0, 2);
1156 lstrcpyA(to, "threedir");
1157 shfo.pFrom = "one.txt\0two.txt\0";
1158 shfo.pTo = to;
1159 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1160 retval = SHFileOperation(&shfo);
1161 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1162 ok(DeleteFileA("threedir\\one.txt"), "Expected file to exist\n");
1163 ok(DeleteFileA("threedir\\two.txt"), "Expected file to exist\n");
1164 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1165 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1166 ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
1168 if (0) {
1169 /* this crashes on win9x */
1170 createTestFile("one.txt");
1171 createTestFile("two.txt");
1173 /* pTo contains bogus 2nd name longer than MAX_PATH,
1174 * multiple source files, FOF_MULTIDESTFILES
1175 * dest dir does not exist
1178 memset(to, 'a', 2 * MAX_PATH);
1179 memset(to+MAX_PATH*2, 0, 2);
1180 lstrcpyA(to, "threedir");
1181 shfo.pFrom = "one.txt\0two.txt\0";
1182 shfo.pTo = to;
1183 shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION |
1184 FOF_SILENT | FOF_NOERRORUI;
1185 retval = SHFileOperation(&shfo);
1186 ok(retval == ERROR_CANCELLED ||
1187 retval == ERROR_SUCCESS, /* win2k3 */
1188 "Expected ERROR_CANCELLED or ERROR_SUCCESS, got %d\n", retval);
1189 ok(!DeleteFileA("threedir\\one.txt"), "Expected file to not exist\n");
1190 ok(!DeleteFileA("threedir\\two.txt"), "Expected file to not exist\n");
1191 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1192 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1193 ok(!RemoveDirectoryA("threedir"), "Expected dir to not exist\n");
1195 /* file exists in win2k */
1196 DeleteFileA("threedir");
1200 createTestFile("one.txt");
1201 createTestFile("two.txt");
1202 CreateDirectoryA("threedir", NULL);
1204 /* pTo contains bogus 2nd name longer than MAX_PATH,
1205 * multiple source files, FOF_MULTIDESTFILES
1206 * dest dir does exist
1208 memset(to, 'a', 2 * MAX_PATH);
1209 memset(to+MAX_PATH*2, 0, 2);
1210 lstrcpyA(to, "threedir");
1211 ptr = to + lstrlenA(to) + 1;
1212 lstrcpyA(ptr, "fourdir");
1213 shfo.pFrom = "one.txt\0two.txt\0";
1214 shfo.pTo = to;
1215 shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION |
1216 FOF_SILENT | FOF_NOERRORUI;
1217 retval = SHFileOperation(&shfo);
1218 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1219 ok(DeleteFileA("threedir\\one.txt"), "Expected file to exist\n");
1220 ok(DeleteFileA("threedir\\two.txt"), "Expected file to exist\n");
1221 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1222 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1223 ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
1224 ok(!DeleteFileA("fourdir"), "Expected file to not exist\n");
1225 ok(!RemoveDirectoryA("fourdir"), "Expected dir to not exist\n");
1227 createTestFile("one.txt");
1228 createTestFile("two.txt");
1229 CreateDirectoryA("threedir", NULL);
1231 /* multiple source files, FOF_MULTIDESTFILES
1232 * multiple dest files, but first dest dir exists
1233 * num files in lists is equal
1235 shfo.pFrom = "one.txt\0two.txt\0";
1236 shfo.pTo = "threedir\0fourdir\0";
1237 shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION |
1238 FOF_SILENT | FOF_NOERRORUI;
1239 retval = SHFileOperation(&shfo);
1240 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
1241 ok(!DeleteFileA("threedir\\one.txt"), "Expected file to not exist\n");
1242 ok(!DeleteFileA("threedir\\two.txt"), "Expected file to not exist\n");
1243 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1244 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1245 ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
1246 ok(!DeleteFileA("fourdir"), "Expected file to not exist\n");
1247 ok(!RemoveDirectoryA("fourdir"), "Expected dit to not exist\n");
1249 createTestFile("one.txt");
1250 createTestFile("two.txt");
1251 CreateDirectoryA("threedir", NULL);
1253 /* multiple source files, FOF_MULTIDESTFILES
1254 * multiple dest files, but first dest dir exists
1255 * num files in lists is not equal
1257 shfo.pFrom = "one.txt\0two.txt\0";
1258 shfo.pTo = "threedir\0fourdir\0five\0";
1259 shfo.fFlags = FOF_MULTIDESTFILES | FOF_NOCONFIRMATION |
1260 FOF_SILENT | FOF_NOERRORUI;
1261 retval = SHFileOperation(&shfo);
1262 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1263 ok(DeleteFileA("threedir\\one.txt"), "Expected file to exist\n");
1264 ok(DeleteFileA("threedir\\two.txt"), "Expected file to exist\n");
1265 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1266 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1267 ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
1268 ok(!DeleteFileA("fourdir"), "Expected file to not exist\n");
1269 ok(!RemoveDirectoryA("fourdir"), "Expected dit to not exist\n");
1270 ok(!DeleteFileA("five"), "Expected file to not exist\n");
1271 ok(!RemoveDirectoryA("five"), "Expected dit to not exist\n");
1273 createTestFile("aa.txt");
1274 createTestFile("ab.txt");
1275 CreateDirectoryA("one", NULL);
1276 CreateDirectoryA("two", NULL);
1278 /* pFrom has a glob, pTo has more than one dest */
1279 shfo.pFrom = "a*.txt\0";
1280 shfo.pTo = "one\0two\0";
1281 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1282 retval = SHFileOperation(&shfo);
1283 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1284 ok(DeleteFileA("one\\aa.txt"), "Expected file to exist\n");
1285 ok(DeleteFileA("one\\ab.txt"), "Expected file to exist\n");
1286 ok(!DeleteFileA("two\\aa.txt"), "Expected file to not exist\n");
1287 ok(!DeleteFileA("two\\ab.txt"), "Expected file to not exist\n");
1288 ok(DeleteFileA("aa.txt"), "Expected file to exist\n");
1289 ok(DeleteFileA("ab.txt"), "Expected file to exist\n");
1290 ok(RemoveDirectoryA("one"), "Expected dir to exist\n");
1291 ok(RemoveDirectoryA("two"), "Expected dir to exist\n");
1294 /* tests the FO_MOVE action */
1295 static void test_move(void)
1297 SHFILEOPSTRUCTA shfo, shfo2;
1298 CHAR from[5*MAX_PATH];
1299 CHAR to[5*MAX_PATH];
1300 DWORD retval;
1302 shfo.hwnd = NULL;
1303 shfo.wFunc = FO_MOVE;
1304 shfo.pFrom = from;
1305 shfo.pTo = to;
1306 shfo.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1307 shfo.hNameMappings = NULL;
1308 shfo.lpszProgressTitle = NULL;
1310 set_curr_dir_path(from, "test1.txt\0");
1311 set_curr_dir_path(to, "test4.txt\0");
1312 ok(!SHFileOperationA(&shfo), "Prepare test to check how directories are moved recursively\n");
1313 ok(!file_exists("test1.txt"), "test1.txt should not exist\n");
1314 ok(file_exists("test4.txt\\test1.txt"), "The file is not moved\n");
1316 set_curr_dir_path(from, "test?.txt\0");
1317 set_curr_dir_path(to, "testdir2\0");
1318 ok(!file_exists("testdir2\\test2.txt"), "The file is not moved yet\n");
1319 ok(!file_exists("testdir2\\test4.txt"), "The directory is not moved yet\n");
1320 ok(!SHFileOperationA(&shfo), "Files and directories are moved to directory\n");
1321 ok(file_exists("testdir2\\test2.txt"), "The file is moved\n");
1322 ok(file_exists("testdir2\\test4.txt"), "The directory is moved\n");
1323 ok(file_exists("testdir2\\test4.txt\\test1.txt"), "The file in subdirectory is moved\n");
1325 clean_after_shfo_tests();
1326 init_shfo_tests();
1328 memcpy(&shfo2, &shfo, sizeof(SHFILEOPSTRUCTA));
1329 shfo2.fFlags |= FOF_MULTIDESTFILES;
1331 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
1332 set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
1333 ok(!SHFileOperationA(&shfo2), "Move many files\n");
1334 ok(file_exists("test6.txt"), "The file is moved - many files are "
1335 "specified as a target\n");
1336 DeleteFileA("test6.txt");
1337 DeleteFileA("test7.txt");
1338 RemoveDirectoryA("test8.txt");
1340 init_shfo_tests();
1342 /* number of sources do not correspond to number of targets */
1343 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
1344 set_curr_dir_path(to, "test6.txt\0test7.txt\0");
1345 ok(SHFileOperationA(&shfo2), "Can't move many files\n");
1346 ok(!file_exists("test6.txt"), "The file is not moved - many files are "
1347 "specified as a target\n");
1349 init_shfo_tests();
1351 set_curr_dir_path(from, "test3.txt\0");
1352 set_curr_dir_path(to, "test4.txt\\test1.txt\0");
1353 ok(!SHFileOperationA(&shfo), "File is moved moving to other directory\n");
1354 ok(file_exists("test4.txt\\test1.txt"), "The file is moved\n");
1356 set_curr_dir_path(from, "test1.txt\0test2.txt\0test4.txt\0");
1357 set_curr_dir_path(to, "test6.txt\0test7.txt\0test8.txt\0");
1358 ok(SHFileOperationA(&shfo), "Cannot move many files\n");
1359 ok(file_exists("test1.txt"), "The file is not moved. Many files are specified\n");
1360 ok(file_exists("test4.txt"), "The directory is not moved. Many files are specified\n");
1362 set_curr_dir_path(from, "test1.txt\0");
1363 set_curr_dir_path(to, "test6.txt\0");
1364 ok(!SHFileOperationA(&shfo), "Move file\n");
1365 ok(!file_exists("test1.txt"), "The file is moved\n");
1366 ok(file_exists("test6.txt"), "The file is moved\n");
1367 set_curr_dir_path(from, "test6.txt\0");
1368 set_curr_dir_path(to, "test1.txt\0");
1369 ok(!SHFileOperationA(&shfo), "Move file back\n");
1371 set_curr_dir_path(from, "test4.txt\0");
1372 set_curr_dir_path(to, "test6.txt\0");
1373 ok(!SHFileOperationA(&shfo), "Move dir\n");
1374 ok(!file_exists("test4.txt"), "The dir is moved\n");
1375 ok(file_exists("test6.txt"), "The dir is moved\n");
1376 set_curr_dir_path(from, "test6.txt\0");
1377 set_curr_dir_path(to, "test4.txt\0");
1378 ok(!SHFileOperationA(&shfo), "Move dir back\n");
1380 /* move one file to two others */
1381 init_shfo_tests();
1382 shfo.pFrom = "test1.txt\0";
1383 shfo.pTo = "a.txt\0b.txt\0";
1384 retval = SHFileOperationA(&shfo);
1385 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1386 ok(!file_exists("test1.txt"), "Expected test1.txt to not exist\n");
1387 ok(DeleteFile("a.txt"), "Expected a.txt to exist\n");
1388 ok(!file_exists("b.txt"), "Expected b.txt to not exist\n");
1390 /* move two files to one other */
1391 shfo.pFrom = "test2.txt\0test3.txt\0";
1392 shfo.pTo = "test1.txt\0";
1393 retval = SHFileOperationA(&shfo);
1394 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
1395 ok(!file_exists("test1.txt"), "Expected test1.txt to not exist\n");
1396 ok(file_exists("test2.txt"), "Expected test2.txt to exist\n");
1397 ok(file_exists("test3.txt"), "Expected test3.txt to exist\n");
1399 /* move a directory into itself */
1400 shfo.pFrom = "test4.txt\0";
1401 shfo.pTo = "test4.txt\\b.txt\0";
1402 retval = SHFileOperationA(&shfo);
1403 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1404 ok(!RemoveDirectory("test4.txt\\b.txt"), "Expected test4.txt\\b.txt to not exist\n");
1405 ok(file_exists("test4.txt"), "Expected test4.txt to exist\n");
1407 /* move many files without FOF_MULTIDESTFILES */
1408 shfo.pFrom = "test2.txt\0test3.txt\0";
1409 shfo.pTo = "d.txt\0e.txt\0";
1410 retval = SHFileOperationA(&shfo);
1411 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
1412 ok(!DeleteFile("d.txt"), "Expected d.txt to not exist\n");
1413 ok(!DeleteFile("e.txt"), "Expected e.txt to not exist\n");
1415 /* number of sources != number of targets */
1416 shfo.pTo = "d.txt\0";
1417 shfo.fFlags |= FOF_MULTIDESTFILES;
1418 retval = SHFileOperationA(&shfo);
1419 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
1420 ok(!DeleteFile("d.txt"), "Expected d.txt to not exist\n");
1422 /* FO_MOVE does not create dest directories */
1423 shfo.pFrom = "test2.txt\0";
1424 shfo.pTo = "dir1\\dir2\\test2.txt\0";
1425 retval = SHFileOperationA(&shfo);
1426 ok(retval == ERROR_CANCELLED, "Expected ERROR_CANCELLED, got %d\n", retval);
1427 ok(!file_exists("dir1"), "Expected dir1 to not exist\n");
1429 /* try to overwrite an existing file */
1430 shfo.pTo = "test3.txt\0";
1431 retval = SHFileOperationA(&shfo);
1432 ok(retval == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", retval);
1433 ok(!file_exists("test2.txt"), "Expected test2.txt to not exist\n");
1434 ok(file_exists("test3.txt"), "Expected test3.txt to exist\n");
1437 static void test_sh_create_dir(void)
1439 CHAR path[MAX_PATH];
1440 int ret;
1442 if(!pSHCreateDirectoryExA)
1444 win_skip("skipping SHCreateDirectoryExA tests\n");
1445 return;
1448 set_curr_dir_path(path, "testdir2\\test4.txt\0");
1449 ret = pSHCreateDirectoryExA(NULL, path, NULL);
1450 ok(ERROR_SUCCESS == ret, "SHCreateDirectoryEx failed to create directory recursively, ret = %d\n", ret);
1451 ok(file_exists("testdir2"), "The first directory is not created\n");
1452 ok(file_exists("testdir2\\test4.txt"), "The second directory is not created\n");
1454 ret = pSHCreateDirectoryExA(NULL, path, NULL);
1455 ok(ERROR_ALREADY_EXISTS == ret, "SHCreateDirectoryEx should fail to create existing directory, ret = %d\n", ret);
1457 ret = pSHCreateDirectoryExA(NULL, "c:\\testdir3", NULL);
1458 ok(file_exists("c:\\testdir3"), "The directory is not created\n");
1461 static void test_sh_path_prepare(void)
1463 HRESULT res;
1464 CHAR path[MAX_PATH];
1466 if(!pSHPathPrepareForWriteA)
1468 win_skip("skipping SHPathPrepareForWriteA tests\n");
1469 return;
1472 /* directory exists, SHPPFW_NONE */
1473 set_curr_dir_path(path, "testdir2\0");
1474 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_NONE);
1475 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
1477 /* directory exists, SHPPFW_IGNOREFILENAME */
1478 set_curr_dir_path(path, "testdir2\\test4.txt\0");
1479 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_IGNOREFILENAME);
1480 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
1482 /* directory exists, SHPPFW_DIRCREATE */
1483 set_curr_dir_path(path, "testdir2\0");
1484 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_DIRCREATE);
1485 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
1487 /* directory exists, SHPPFW_IGNOREFILENAME|SHPPFW_DIRCREATE */
1488 set_curr_dir_path(path, "testdir2\\test4.txt\0");
1489 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_IGNOREFILENAME|SHPPFW_DIRCREATE);
1490 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
1491 ok(!file_exists("nonexistent\\"), "nonexistent\\ exists but shouldn't\n");
1493 /* file exists, SHPPFW_NONE */
1494 set_curr_dir_path(path, "test1.txt\0");
1495 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_NONE);
1496 ok(res == HRESULT_FROM_WIN32(ERROR_DIRECTORY), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_DIRECTORY)\n", res);
1498 /* file exists, SHPPFW_DIRCREATE */
1499 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_DIRCREATE);
1500 ok(res == HRESULT_FROM_WIN32(ERROR_DIRECTORY), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_DIRECTORY)\n", res);
1502 /* file exists, SHPPFW_NONE, trailing \ */
1503 set_curr_dir_path(path, "test1.txt\\\0");
1504 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_NONE);
1505 ok(res == HRESULT_FROM_WIN32(ERROR_DIRECTORY), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_DIRECTORY)\n", res);
1507 /* relative path exists, SHPPFW_DIRCREATE */
1508 res = pSHPathPrepareForWriteA(0, 0, ".\\testdir2", SHPPFW_DIRCREATE);
1509 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
1511 /* relative path doesn't exist, SHPPFW_DIRCREATE -- Windows does not create the directory in this case */
1512 res = pSHPathPrepareForWriteA(0, 0, ".\\testdir2\\test4.txt", SHPPFW_DIRCREATE);
1513 ok(res == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)\n", res);
1514 ok(!file_exists(".\\testdir2\\test4.txt\\"), ".\\testdir2\\test4.txt\\ exists but shouldn't\n");
1516 /* directory doesn't exist, SHPPFW_NONE */
1517 set_curr_dir_path(path, "nonexistent\0");
1518 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_NONE);
1519 ok(res == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)\n", res);
1521 /* directory doesn't exist, SHPPFW_IGNOREFILENAME */
1522 set_curr_dir_path(path, "nonexistent\\notreal\0");
1523 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_IGNOREFILENAME);
1524 ok(res == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)\n", res);
1525 ok(!file_exists("nonexistent\\notreal"), "nonexistent\\notreal exists but shouldn't\n");
1526 ok(!file_exists("nonexistent\\"), "nonexistent\\ exists but shouldn't\n");
1528 /* directory doesn't exist, SHPPFW_IGNOREFILENAME|SHPPFW_DIRCREATE */
1529 set_curr_dir_path(path, "testdir2\\test4.txt\\\0");
1530 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_IGNOREFILENAME|SHPPFW_DIRCREATE);
1531 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
1532 ok(file_exists("testdir2\\test4.txt\\"), "testdir2\\test4.txt doesn't exist but should\n");
1534 /* nested directory doesn't exist, SHPPFW_DIRCREATE */
1535 set_curr_dir_path(path, "nonexistent\\notreal\0");
1536 res = pSHPathPrepareForWriteA(0, 0, path, SHPPFW_DIRCREATE);
1537 ok(res == S_OK, "res == 0x%08x, expected S_OK\n", res);
1538 ok(file_exists("nonexistent\\notreal"), "nonexistent\\notreal doesn't exist but should\n");
1540 /* SHPPFW_ASKDIRCREATE, SHPPFW_NOWRITECHECK, and SHPPFW_MEDIACHECKONLY are untested */
1542 if(!pSHPathPrepareForWriteW)
1544 skip("Skipping SHPathPrepareForWriteW tests\n");
1545 return;
1547 /* unicode directory doesn't exist, SHPPFW_NONE */
1548 res = pSHPathPrepareForWriteW(0, 0, UNICODE_PATH, SHPPFW_NONE);
1549 ok(res == HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND), "res == %08x, expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)\n", res);
1550 ok(!file_existsW(UNICODE_PATH), "unicode path was created but shouldn't be\n");
1551 RemoveDirectoryW(UNICODE_PATH);
1553 /* unicode directory doesn't exist, SHPPFW_DIRCREATE */
1554 res = pSHPathPrepareForWriteW(0, 0, UNICODE_PATH, SHPPFW_DIRCREATE);
1555 ok(res == S_OK, "res == %08x, expected S_OK\n", res);
1556 ok(file_existsW(UNICODE_PATH), "unicode path should've been created\n");
1558 /* unicode directory exists, SHPPFW_NONE */
1559 res = pSHPathPrepareForWriteW(0, 0, UNICODE_PATH, SHPPFW_NONE);
1560 ok(res == S_OK, "ret == %08x, expected S_OK\n", res);
1562 /* unicode directory exists, SHPPFW_DIRCREATE */
1563 res = pSHPathPrepareForWriteW(0, 0, UNICODE_PATH, SHPPFW_DIRCREATE);
1564 ok(res == S_OK, "ret == %08x, expected S_OK\n", res);
1565 RemoveDirectoryW(UNICODE_PATH);
1568 static void test_unicode(void)
1570 SHFILEOPSTRUCTW shfoW;
1571 int ret;
1572 HANDLE file;
1574 if (!pSHFileOperationW)
1576 skip("SHFileOperationW() is missing\n");
1577 return;
1580 shfoW.hwnd = NULL;
1581 shfoW.wFunc = FO_DELETE;
1582 shfoW.pFrom = UNICODE_PATH;
1583 shfoW.pTo = '\0';
1584 shfoW.fFlags = FOF_NOCONFIRMATION | FOF_SILENT | FOF_NOERRORUI;
1585 shfoW.hNameMappings = NULL;
1586 shfoW.lpszProgressTitle = NULL;
1588 /* Clean up before start test */
1589 DeleteFileW(UNICODE_PATH);
1590 RemoveDirectoryW(UNICODE_PATH);
1592 /* Make sure we are on a system that supports unicode */
1593 SetLastError(0xdeadbeef);
1594 file = CreateFileW(UNICODE_PATH, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);
1595 if (GetLastError()==ERROR_CALL_NOT_IMPLEMENTED)
1597 skip("Unicode tests skipped on non-unicode system\n");
1598 return;
1600 CloseHandle(file);
1602 /* Try to delete a file with unicode filename */
1603 ok(file_existsW(UNICODE_PATH), "The file does not exist\n");
1604 ret = pSHFileOperationW(&shfoW);
1605 ok(!ret, "File is not removed, ErrorCode: %d\n", ret);
1606 ok(!file_existsW(UNICODE_PATH), "The file should have been removed\n");
1608 /* Try to trash a file with unicode filename */
1609 createTestFileW(UNICODE_PATH);
1610 shfoW.fFlags |= FOF_ALLOWUNDO;
1611 ok(file_existsW(UNICODE_PATH), "The file does not exist\n");
1612 ret = pSHFileOperationW(&shfoW);
1613 ok(!ret, "File is not removed, ErrorCode: %d\n", ret);
1614 ok(!file_existsW(UNICODE_PATH), "The file should have been removed\n");
1616 if(!pSHCreateDirectoryExW)
1618 skip("Skipping SHCreateDirectoryExW tests\n");
1619 return;
1622 /* Try to delete a directory with unicode filename */
1623 ret = pSHCreateDirectoryExW(NULL, UNICODE_PATH, NULL);
1624 ok(!ret, "SHCreateDirectoryExW returned %d\n", ret);
1625 ok(file_existsW(UNICODE_PATH), "The directory is not created\n");
1626 shfoW.fFlags &= ~FOF_ALLOWUNDO;
1627 ret = pSHFileOperationW(&shfoW);
1628 ok(!ret, "Directory is not removed, ErrorCode: %d\n", ret);
1629 ok(!file_existsW(UNICODE_PATH), "The directory should have been removed\n");
1631 /* Try to trash a directory with unicode filename */
1632 ret = pSHCreateDirectoryExW(NULL, UNICODE_PATH, NULL);
1633 ok(!ret, "SHCreateDirectoryExW returned %d\n", ret);
1634 ok(file_existsW(UNICODE_PATH), "The directory was not created\n");
1635 shfoW.fFlags |= FOF_ALLOWUNDO;
1636 ret = pSHFileOperationW(&shfoW);
1637 ok(!ret, "Directory is not removed, ErrorCode: %d\n", ret);
1638 ok(!file_existsW(UNICODE_PATH), "The directory should have been removed\n");
1641 START_TEST(shlfileop)
1643 InitFunctionPointers();
1645 clean_after_shfo_tests();
1647 init_shfo_tests();
1648 test_get_file_info();
1649 test_get_file_info_iconlist();
1650 clean_after_shfo_tests();
1652 init_shfo_tests();
1653 test_delete();
1654 clean_after_shfo_tests();
1656 init_shfo_tests();
1657 test_rename();
1658 clean_after_shfo_tests();
1660 init_shfo_tests();
1661 test_copy();
1662 clean_after_shfo_tests();
1664 init_shfo_tests();
1665 test_move();
1666 clean_after_shfo_tests();
1668 test_sh_create_dir();
1669 clean_after_shfo_tests();
1671 init_shfo_tests();
1672 test_sh_path_prepare();
1673 clean_after_shfo_tests();
1675 test_unicode();