2 * Unit test of the SHFileOperation function.
4 * Copyright 2002 Andriy Palamarchuk
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
24 #define WINE_NOWINSOCK
29 #include "wine/test.h"
31 #ifndef FOF_NORECURSION
32 #define FOF_NORECURSION 0x1000
35 /* 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)\
47 broken(retval == ret_prewin32),\
48 "Expected %d, got %d\n", ret, retval)
50 static CHAR CURR_DIR
[MAX_PATH
];
51 static const WCHAR UNICODE_PATH
[] = {'c',':','\\',0x00ae,'\0','\0'};
52 /* "c:\®" can be used in all codepages */
53 /* Double-null termination needed for pFrom field of SHFILEOPSTRUCT */
55 static HMODULE hshell32
;
56 static int (WINAPI
*pSHCreateDirectoryExA
)(HWND
, LPCSTR
, LPSECURITY_ATTRIBUTES
);
57 static int (WINAPI
*pSHCreateDirectoryExW
)(HWND
, LPCWSTR
, LPSECURITY_ATTRIBUTES
);
58 static int (WINAPI
*pSHFileOperationW
)(LPSHFILEOPSTRUCTW
);
59 static DWORD_PTR (WINAPI
*pSHGetFileInfoW
)(LPCWSTR
, DWORD
, SHFILEINFOW
*, UINT
, UINT
);
60 static int (WINAPI
*pSHPathPrepareForWriteA
)(HWND
, IUnknown
*, LPCSTR
, DWORD
);
61 static int (WINAPI
*pSHPathPrepareForWriteW
)(HWND
, IUnknown
*, LPCWSTR
, DWORD
);
63 static void InitFunctionPointers(void)
65 hshell32
= GetModuleHandleA("shell32.dll");
66 pSHCreateDirectoryExA
= (void*)GetProcAddress(hshell32
, "SHCreateDirectoryExA");
67 pSHCreateDirectoryExW
= (void*)GetProcAddress(hshell32
, "SHCreateDirectoryExW");
68 pSHFileOperationW
= (void*)GetProcAddress(hshell32
, "SHFileOperationW");
69 pSHGetFileInfoW
= (void*)GetProcAddress(hshell32
, "SHGetFileInfoW");
70 pSHPathPrepareForWriteA
= (void*)GetProcAddress(hshell32
, "SHPathPrepareForWriteA");
71 pSHPathPrepareForWriteW
= (void*)GetProcAddress(hshell32
, "SHPathPrepareForWriteW");
74 /* creates a file with the specified name for tests */
75 static void createTestFile(const CHAR
*name
)
80 file
= CreateFileA(name
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
81 ok(file
!= INVALID_HANDLE_VALUE
, "Failure to open file %s\n", name
);
82 WriteFile(file
, name
, strlen(name
), &written
, NULL
);
83 WriteFile(file
, "\n", strlen("\n"), &written
, NULL
);
87 static void createTestFileW(const WCHAR
*name
)
91 file
= CreateFileW(name
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
92 ok(file
!= INVALID_HANDLE_VALUE
, "Failure to open file\n");
96 static BOOL
file_exists(const CHAR
*name
)
98 return GetFileAttributesA(name
) != INVALID_FILE_ATTRIBUTES
;
101 static BOOL
dir_exists(const CHAR
*name
)
106 attr
= GetFileAttributesA(name
);
107 dir
= ((attr
& FILE_ATTRIBUTE_DIRECTORY
) == FILE_ATTRIBUTE_DIRECTORY
);
109 return ((attr
!= INVALID_FILE_ATTRIBUTES
) && dir
);
112 static BOOL
file_existsW(LPCWSTR name
)
114 return GetFileAttributesW(name
) != INVALID_FILE_ATTRIBUTES
;
117 static BOOL
file_has_content(const CHAR
*name
, const CHAR
*content
)
123 file
= CreateFileA(name
, GENERIC_READ
, 0, NULL
, OPEN_EXISTING
, 0, NULL
);
124 if (file
== INVALID_HANDLE_VALUE
)
126 ReadFile(file
, buf
, MAX_PATH
- 1, &read
, NULL
);
129 return strcmp(buf
, content
)==0;
132 /* initializes the tests */
133 static void init_shfo_tests(void)
137 GetCurrentDirectoryA(MAX_PATH
, CURR_DIR
);
138 len
= lstrlenA(CURR_DIR
);
140 if(len
&& (CURR_DIR
[len
-1] == '\\'))
143 createTestFile("test1.txt");
144 createTestFile("test2.txt");
145 createTestFile("test3.txt");
146 createTestFile("test_5.txt");
147 CreateDirectoryA("test4.txt", NULL
);
148 CreateDirectoryA("testdir2", NULL
);
149 CreateDirectoryA("testdir2\\nested", NULL
);
150 createTestFile("testdir2\\one.txt");
151 createTestFile("testdir2\\nested\\two.txt");
154 /* cleans after tests */
155 static void clean_after_shfo_tests(void)
157 DeleteFileA("test1.txt");
158 DeleteFileA("test2.txt");
159 DeleteFileA("test3.txt");
160 DeleteFileA("test_5.txt");
161 DeleteFileA("one.txt");
162 DeleteFileA("test4.txt\\test1.txt");
163 DeleteFileA("test4.txt\\test2.txt");
164 DeleteFileA("test4.txt\\test3.txt");
165 RemoveDirectoryA("test4.txt");
166 DeleteFileA("testdir2\\one.txt");
167 DeleteFileA("testdir2\\test1.txt");
168 DeleteFileA("testdir2\\test2.txt");
169 DeleteFileA("testdir2\\test3.txt");
170 DeleteFileA("testdir2\\test4.txt\\test1.txt");
171 DeleteFileA("testdir2\\nested\\two.txt");
172 RemoveDirectoryA("testdir2\\test4.txt");
173 RemoveDirectoryA("testdir2\\nested");
174 RemoveDirectoryA("testdir2");
175 RemoveDirectoryA("c:\\testdir3");
176 DeleteFileA("nonexistent\\notreal\\test2.txt");
177 RemoveDirectoryA("nonexistent\\notreal");
178 RemoveDirectoryA("nonexistent");
182 static void test_get_file_info(void)
185 SHFILEINFOA shfi
, shfi2
;
187 char notepad
[MAX_PATH
];
189 /* Test whether fields of SHFILEINFOA are always cleared */
190 memset(&shfi
, 0xcf, sizeof(shfi
));
191 rc
=SHGetFileInfoA("", 0, &shfi
, sizeof(shfi
), 0);
192 ok(rc
== 1, "SHGetFileInfoA('' | 0) should return 1, got 0x%x\n", rc
);
193 todo_wine
ok(shfi
.hIcon
== 0, "SHGetFileInfoA('' | 0) did not clear hIcon\n");
194 todo_wine
ok(shfi
.szDisplayName
[0] == 0, "SHGetFileInfoA('' | 0) did not clear szDisplayName[0]\n");
195 todo_wine
ok(shfi
.szTypeName
[0] == 0, "SHGetFileInfoA('' | 0) did not clear szTypeName[0]\n");
196 ok(shfi
.iIcon
== 0xcfcfcfcf ||
197 broken(shfi
.iIcon
!= 0xcfcfcfcf), /* NT4 doesn't clear but sets this field */
198 "SHGetFileInfoA('' | 0) should not clear iIcon\n");
199 ok(shfi
.dwAttributes
== 0xcfcfcfcf ||
200 broken(shfi
.dwAttributes
!= 0xcfcfcfcf), /* NT4 doesn't clear but sets this field */
201 "SHGetFileInfoA('' | 0) should not clear dwAttributes\n");
206 /* Test whether fields of SHFILEINFOW are always cleared */
207 memset(&shfiw
, 0xcf, sizeof(shfiw
));
208 memset(&unset_icon
, 0xcf, sizeof(unset_icon
));
209 rc
=pSHGetFileInfoW(NULL
, 0, &shfiw
, sizeof(shfiw
), 0);
210 ok(!rc
, "SHGetFileInfoW(NULL | 0) should fail\n");
211 ok(shfiw
.hIcon
== unset_icon
, "SHGetFileInfoW(NULL | 0) should not clear hIcon\n");
212 ok(shfiw
.szDisplayName
[0] == 0xcfcf, "SHGetFileInfoW(NULL | 0) should not clear szDisplayName[0]\n");
213 ok(shfiw
.szTypeName
[0] == 0xcfcf, "SHGetFileInfoW(NULL | 0) should not clear szTypeName[0]\n");
214 ok(shfiw
.iIcon
== 0xcfcfcfcf, "SHGetFileInfoW(NULL | 0) should not clear iIcon\n");
215 ok(shfiw
.dwAttributes
== 0xcfcfcfcf, "SHGetFileInfoW(NULL | 0) should not clear dwAttributes\n");
218 win_skip("SHGetFileInfoW is not available\n");
221 /* Test some flag combinations that MSDN claims are not allowed,
222 * but which work anyway
224 memset(&shfi
, 0xcf, sizeof(shfi
));
225 rc
=SHGetFileInfoA("c:\\nonexistent", FILE_ATTRIBUTE_DIRECTORY
,
227 SHGFI_ATTRIBUTES
| SHGFI_USEFILEATTRIBUTES
);
228 ok(rc
== 1, "SHGetFileInfoA(c:\\nonexistent | SHGFI_ATTRIBUTES) should return 1, got 0x%x\n", rc
);
230 ok(shfi
.dwAttributes
!= 0xcfcfcfcf, "dwFileAttributes is not set\n");
231 todo_wine
ok(shfi
.hIcon
== 0, "SHGetFileInfoA(c:\\nonexistent | SHGFI_ATTRIBUTES) did not clear hIcon\n");
232 todo_wine
ok(shfi
.szDisplayName
[0] == 0, "SHGetFileInfoA(c:\\nonexistent | SHGFI_ATTRIBUTES) did not clear szDisplayName[0]\n");
233 todo_wine
ok(shfi
.szTypeName
[0] == 0, "SHGetFileInfoA(c:\\nonexistent | SHGFI_ATTRIBUTES) did not clear szTypeName[0]\n");
234 ok(shfi
.iIcon
== 0xcfcfcfcf ||
235 broken(shfi
.iIcon
!= 0xcfcfcfcf), /* NT4 doesn't clear but sets this field */
236 "SHGetFileInfoA(c:\\nonexistent | SHGFI_ATTRIBUTES) should not clear iIcon\n");
238 rc
=SHGetFileInfoA("c:\\nonexistent", FILE_ATTRIBUTE_DIRECTORY
,
240 SHGFI_EXETYPE
| SHGFI_USEFILEATTRIBUTES
);
241 todo_wine
ok(rc
== 1, "SHGetFileInfoA(c:\\nonexistent | SHGFI_EXETYPE) should return 1, got 0x%x\n", rc
);
243 /* Test SHGFI_USEFILEATTRIBUTES support */
244 strcpy(shfi
.szDisplayName
, "dummy");
245 shfi
.iIcon
=0xdeadbeef;
246 rc
=SHGetFileInfoA("c:\\nonexistent", FILE_ATTRIBUTE_DIRECTORY
,
248 SHGFI_ICONLOCATION
| SHGFI_USEFILEATTRIBUTES
);
249 ok(rc
== 1, "SHGetFileInfoA(c:\\nonexistent) should return 1, got 0x%x\n", rc
);
252 ok(strcpy(shfi
.szDisplayName
, "dummy") != 0, "SHGetFileInfoA(c:\\nonexistent) displayname is not set\n");
253 ok(shfi
.iIcon
!= 0xdeadbeef, "SHGetFileInfoA(c:\\nonexistent) iIcon is not set\n");
256 /* Wine does not have a default icon for text files, and Windows 98 fails
257 * if we give it an empty executable. So use notepad.exe as the test
259 if (SearchPath(NULL
, "notepad.exe", NULL
, sizeof(notepad
), notepad
, NULL
))
261 strcpy(shfi
.szDisplayName
, "dummy");
262 shfi
.iIcon
=0xdeadbeef;
263 rc
=SHGetFileInfoA(notepad
, GetFileAttributes(notepad
),
265 SHGFI_ICONLOCATION
| SHGFI_USEFILEATTRIBUTES
);
266 ok(rc
== 1, "SHGetFileInfoA(%s, SHGFI_USEFILEATTRIBUTES) should return 1, got 0x%x\n", notepad
, rc
);
267 strcpy(shfi2
.szDisplayName
, "dummy");
268 shfi2
.iIcon
=0xdeadbeef;
269 rc2
=SHGetFileInfoA(notepad
, 0,
270 &shfi2
, sizeof(shfi2
),
272 ok(rc2
== 1, "SHGetFileInfoA(%s) failed %x\n", notepad
, rc2
);
275 ok(lstrcmpi(shfi2
.szDisplayName
, shfi
.szDisplayName
) == 0, "wrong display name %s != %s\n", shfi
.szDisplayName
, shfi2
.szDisplayName
);
276 ok(shfi2
.iIcon
== shfi
.iIcon
, "wrong icon index %d != %d\n", shfi
.iIcon
, shfi2
.iIcon
);
280 /* with a directory now */
281 strcpy(shfi
.szDisplayName
, "dummy");
282 shfi
.iIcon
=0xdeadbeef;
283 rc
=SHGetFileInfoA("test4.txt", GetFileAttributes("test4.txt"),
285 SHGFI_ICONLOCATION
| SHGFI_USEFILEATTRIBUTES
);
286 ok(rc
== 1, "SHGetFileInfoA(test4.txt/, SHGFI_USEFILEATTRIBUTES) should return 1, got 0x%x\n", rc
);
287 strcpy(shfi2
.szDisplayName
, "dummy");
288 shfi2
.iIcon
=0xdeadbeef;
289 rc2
=SHGetFileInfoA("test4.txt", 0,
290 &shfi2
, sizeof(shfi2
),
292 ok(rc2
== 1, "SHGetFileInfoA(test4.txt/) should return 1, got 0x%x\n", rc2
);
295 ok(lstrcmpi(shfi2
.szDisplayName
, shfi
.szDisplayName
) == 0, "wrong display name %s != %s\n", shfi
.szDisplayName
, shfi2
.szDisplayName
);
296 ok(shfi2
.iIcon
== shfi
.iIcon
, "wrong icon index %d != %d\n", shfi
.iIcon
, shfi2
.iIcon
);
298 /* with drive root directory */
299 strcpy(shfi
.szDisplayName
, "dummy");
300 strcpy(shfi
.szTypeName
, "dummy");
301 shfi
.hIcon
=(HICON
) 0xdeadbeef;
302 shfi
.iIcon
=0xdeadbeef;
303 shfi
.dwAttributes
=0xdeadbeef;
304 rc
=SHGetFileInfoA("c:\\", 0, &shfi
, sizeof(shfi
),
305 SHGFI_TYPENAME
| SHGFI_DISPLAYNAME
| SHGFI_ICON
| SHGFI_SMALLICON
);
306 ok(rc
== 1, "SHGetFileInfoA(c:\\) should return 1, got 0x%x\n", rc
);
307 ok(lstrcmp(shfi
.szDisplayName
, "dummy") != 0, "display name was expected to change\n");
308 ok(lstrcmp(shfi
.szTypeName
, "dummy") != 0, "type name was expected to change\n");
309 ok(shfi
.hIcon
!= (HICON
) 0xdeadbeef, "hIcon was expected to change\n");
310 ok(shfi
.iIcon
!= 0xdeadbeef, "iIcon was expected to change\n");
313 static void test_get_file_info_iconlist(void)
315 /* Test retrieving a handle to the system image list, and
316 * what that returns for hIcon
319 HIMAGELIST hSysImageList
;
320 LPITEMIDLIST pidList
;
324 hr
= SHGetSpecialFolderLocation(NULL
, CSIDL_DESKTOP
, &pidList
);
326 skip("can't get desktop pidl\n");
330 memset(&shInfoa
, 0xcf, sizeof(shInfoa
));
331 hSysImageList
= (HIMAGELIST
) SHGetFileInfoA((const char *)pidList
, 0,
332 &shInfoa
, sizeof(shInfoa
),
333 SHGFI_SYSICONINDEX
| SHGFI_SMALLICON
| SHGFI_PIDL
);
334 ok((hSysImageList
!= INVALID_HANDLE_VALUE
) && (hSysImageList
> (HIMAGELIST
) 0xffff), "Can't get handle for CSIDL_DESKTOP imagelist\n");
335 todo_wine
ok(shInfoa
.hIcon
== 0, "SHGetFileInfoA(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) did not clear hIcon\n");
336 todo_wine
ok(shInfoa
.szTypeName
[0] == 0, "SHGetFileInfoA(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) did not clear szTypeName[0]\n");
337 ok(shInfoa
.iIcon
!= 0xcfcfcfcf, "SHGetFileInfoA(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) should set iIcon\n");
338 ok(shInfoa
.dwAttributes
== 0xcfcfcfcf ||
339 shInfoa
.dwAttributes
== 0 || /* Vista */
340 broken(shInfoa
.dwAttributes
!= 0xcfcfcfcf), /* NT4 doesn't clear but sets this field */
341 "SHGetFileInfoA(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL), unexpected dwAttributes\n");
342 CloseHandle(hSysImageList
);
344 if (!pSHGetFileInfoW
)
346 win_skip("SHGetFileInfoW is not available\n");
351 memset(&shInfow
, 0xcf, sizeof(shInfow
));
352 hSysImageList
= (HIMAGELIST
) pSHGetFileInfoW((const WCHAR
*)pidList
, 0,
353 &shInfow
, sizeof(shInfow
),
354 SHGFI_SYSICONINDEX
| SHGFI_SMALLICON
| SHGFI_PIDL
);
357 win_skip("SHGetFileInfoW is not implemented\n");
360 ok((hSysImageList
!= INVALID_HANDLE_VALUE
) && (hSysImageList
> (HIMAGELIST
) 0xffff), "Can't get handle for CSIDL_DESKTOP imagelist\n");
361 todo_wine
ok(shInfow
.hIcon
== 0, "SHGetFileInfoW(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) did not clear hIcon\n");
362 ok(shInfow
.szTypeName
[0] == 0, "SHGetFileInfoW(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) did not clear szTypeName[0]\n");
363 ok(shInfow
.iIcon
!= 0xcfcfcfcf, "SHGetFileInfoW(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) should set iIcon\n");
364 ok(shInfow
.dwAttributes
== 0xcfcfcfcf ||
365 shInfoa
.dwAttributes
== 0, /* Vista */
366 "SHGetFileInfoW(CSIDL_DESKTOP, SHGFI_SYSICONINDEX|SHGFI_SMALLICON|SHGFI_PIDL) unexpected dwAttributes\n");
367 CloseHandle(hSysImageList
);
369 /* Various suposidly invalid flag testing */
370 memset(&shInfow
, 0xcf, sizeof(shInfow
));
371 hr
= pSHGetFileInfoW((const WCHAR
*)pidList
, 0, &shInfow
, sizeof(shInfow
),
372 SHGFI_SYSICONINDEX
|SHGFI_USEFILEATTRIBUTES
|SHGFI_PIDL
|SHGFI_SMALLICON
);
373 ok(hr
!= 0, "SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON Failed\n");
374 ok(shInfow
.iIcon
!=0xcfcfcfcf, "Icon Index Missing\n");
375 ok(shInfow
.dwAttributes
==0xcfcfcfcf ||
376 shInfoa
.dwAttributes
==0, /* Vista */
377 "unexpected dwAttributes\n");
379 memset(&shInfow
, 0xcf, sizeof(shInfow
));
380 hr
= pSHGetFileInfoW((const WCHAR
*)pidList
, 0, &shInfow
, sizeof(shInfow
),
381 SHGFI_ICON
|SHGFI_USEFILEATTRIBUTES
|SHGFI_PIDL
|SHGFI_SMALLICON
);
382 ok(hr
!= 0, " SHGFI_ICON|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON Failed\n");
383 ok(shInfow
.iIcon
!=0xcfcfcfcf, "Icon Index Missing\n");
384 ok(shInfow
.hIcon
!=(HICON
)0xcfcfcfcf && shInfow
.hIcon
!=0,"hIcon invalid\n");
385 if (shInfow
.hIcon
!=(HICON
)0xcfcfcfcf) DestroyIcon(shInfow
.hIcon
);
386 todo_wine
ok(shInfow
.dwAttributes
==0,"dwAttributes not set\n");
388 memset(&shInfow
, 0xcf, sizeof(shInfow
));
389 hr
= pSHGetFileInfoW((const WCHAR
*)pidList
, 0, &shInfow
, sizeof(shInfow
),
390 SHGFI_ICON
|SHGFI_USEFILEATTRIBUTES
|SHGFI_PIDL
|SHGFI_LARGEICON
);
391 ok(hr
!= 0, "SHGFI_ICON|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_LARGEICON Failed\n");
392 ok(shInfow
.iIcon
!=0xcfcfcfcf, "Icon Index Missing\n");
393 ok(shInfow
.hIcon
!=(HICON
)0xcfcfcfcf && shInfow
.hIcon
!=0,"hIcon invalid\n");
394 if (shInfow
.hIcon
!= (HICON
)0xcfcfcfcf) DestroyIcon(shInfow
.hIcon
);
395 todo_wine
ok(shInfow
.dwAttributes
==0,"dwAttributes not set\n");
397 memset(&shInfow
, 0xcf, sizeof(shInfow
));
398 hr
= pSHGetFileInfoW((const WCHAR
*)pidList
, 0, &shInfow
, sizeof(shInfow
),
399 SHGFI_SYSICONINDEX
|SHGFI_USEFILEATTRIBUTES
|SHGFI_PIDL
|SHGFI_LARGEICON
);
400 ok(hr
!= 0, "SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_LARGEICON Failed\n");
401 ok(shInfow
.iIcon
!=0xcfcfcfcf, "Icon Index Missing\n");
402 ok(shInfow
.dwAttributes
==0xcfcfcfcf ||
403 shInfoa
.dwAttributes
==0, /* Vista */
404 "unexpected dwAttributes\n");
406 memset(&shInfow
, 0xcf, sizeof(shInfow
));
407 hr
= pSHGetFileInfoW((const WCHAR
*)pidList
, 0, &shInfow
, sizeof(shInfow
),
408 SHGFI_OPENICON
|SHGFI_USEFILEATTRIBUTES
|SHGFI_PIDL
|SHGFI_SMALLICON
);
409 ok(hr
!= 0, "SHGFI_OPENICON|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON Failed\n");
410 todo_wine
ok(shInfow
.iIcon
==0xcfcfcfcf, "Icon Index Modified\n");
411 ok(shInfow
.dwAttributes
==0xcfcfcfcf,"dwAttributes modified\n");
413 memset(&shInfow
, 0xcf, sizeof(shInfow
));
414 hr
= pSHGetFileInfoW((const WCHAR
*)pidList
, 0, &shInfow
, sizeof(shInfow
),
415 SHGFI_SHELLICONSIZE
|SHGFI_USEFILEATTRIBUTES
|SHGFI_PIDL
|SHGFI_SMALLICON
);
416 ok(hr
!= 0, "SHGFI_SHELLICONSIZE|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON Failed\n");
417 todo_wine
ok(shInfow
.iIcon
==0xcfcfcfcf, "Icon Index Modified\n");
418 ok(shInfow
.dwAttributes
==0xcfcfcfcf,"dwAttributes modified\n");
420 memset(&shInfow
, 0xcf, sizeof(shInfow
));
421 hr
= pSHGetFileInfoW((const WCHAR
*)pidList
, 0, &shInfow
, sizeof(shInfow
),
422 SHGFI_SHELLICONSIZE
|SHGFI_USEFILEATTRIBUTES
|SHGFI_PIDL
|SHGFI_SMALLICON
);
423 ok(hr
!= 0, "SHGFI_SHELLICONSIZE|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON Failed\n");
424 todo_wine
ok(shInfow
.iIcon
==0xcfcfcfcf, "Icon Index Modified\n");
425 ok(shInfow
.dwAttributes
==0xcfcfcfcf,"dwAttributes modified\n");
427 memset(&shInfow
, 0xcf, sizeof(shInfow
));
428 hr
= pSHGetFileInfoW((const WCHAR
*)pidList
, 0, &shInfow
, sizeof(shInfow
),
429 SHGFI_SYSICONINDEX
|SHGFI_USEFILEATTRIBUTES
|SHGFI_PIDL
|SHGFI_SMALLICON
|
431 ok(hr
!= 0, "SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|SHGFI_ATTRIBUTES Failed\n");
432 ok(shInfow
.iIcon
!=0xcfcfcfcf, "Icon Index Missing\n");
433 ok(shInfow
.dwAttributes
!=0xcfcfcfcf,"dwAttributes not set\n");
435 memset(&shInfow
, 0xcf, sizeof(shInfow
));
436 hr
= pSHGetFileInfoW((const WCHAR
*)pidList
, 0, &shInfow
, sizeof(shInfow
),
437 SHGFI_SYSICONINDEX
|SHGFI_USEFILEATTRIBUTES
|SHGFI_PIDL
|SHGFI_SMALLICON
|
439 todo_wine
ok(hr
!= 0, "SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|SHGFI_EXETYPE Failed\n");
440 ok(shInfow
.iIcon
!=0xcfcfcfcf, "Icon Index Missing\n");
441 ok(shInfow
.dwAttributes
==0xcfcfcfcf ||
442 shInfoa
.dwAttributes
==0, /* Vista */
443 "unexpected dwAttributes\n");
445 memset(&shInfow
, 0xcf, sizeof(shInfow
));
446 hr
= pSHGetFileInfoW((const WCHAR
*)pidList
, 0, &shInfow
, sizeof(shInfow
),
447 SHGFI_USEFILEATTRIBUTES
|SHGFI_PIDL
|SHGFI_SMALLICON
|SHGFI_EXETYPE
);
448 todo_wine
ok(hr
!= 0, "SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|SHGFI_EXETYPE Failed\n");
449 todo_wine
ok(shInfow
.iIcon
==0xcfcfcfcf, "Icon Index Modified\n");
450 ok(shInfow
.dwAttributes
==0xcfcfcfcf,"dwAttributes modified\n");
452 memset(&shInfow
, 0xcf, sizeof(shInfow
));
453 hr
= pSHGetFileInfoW((const WCHAR
*)pidList
, 0, &shInfow
, sizeof(shInfow
),
454 SHGFI_USEFILEATTRIBUTES
|SHGFI_PIDL
|SHGFI_SMALLICON
|SHGFI_ATTRIBUTES
);
455 ok(hr
!= 0, "SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_SMALLICON|SHGFI_ATTRIBUTES Failed\n");
456 todo_wine
ok(shInfow
.iIcon
==0xcfcfcfcf, "Icon Index Modified\n");
457 ok(shInfow
.dwAttributes
!=0xcfcfcfcf,"dwAttributes not set\n");
459 memset(&shInfow
, 0xcf, sizeof(shInfow
));
460 hr
= pSHGetFileInfoW((const WCHAR
*)pidList
, 0, &shInfow
, sizeof(shInfow
),
461 SHGFI_SYSICONINDEX
|SHGFI_USEFILEATTRIBUTES
|SHGFI_PIDL
|
463 ok(hr
!= 0, "SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_ATTRIBUTES Failed\n");
464 ok(shInfow
.iIcon
!=0xcfcfcfcf, "Icon Index Missing\n");
465 ok(shInfow
.dwAttributes
!=0xcfcfcfcf,"dwAttributes not set\n");
467 memset(&shInfow
, 0xcf, sizeof(shInfow
));
468 hr
= pSHGetFileInfoW((const WCHAR
*)pidList
, 0, &shInfow
, sizeof(shInfow
),
469 SHGFI_SYSICONINDEX
|SHGFI_USEFILEATTRIBUTES
|SHGFI_PIDL
|SHGFI_EXETYPE
);
470 todo_wine
ok(hr
!= 0, "SHGFI_SYSICONINDEX|SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_EXETYPE Failed\n");
471 ok(shInfow
.iIcon
!=0xcfcfcfcf, "Icon Index Missing\n");
472 ok(shInfow
.dwAttributes
==0xcfcfcfcf ||
473 shInfoa
.dwAttributes
==0, /* Vista */
474 "unexpected dwAttributes\n");
476 memset(&shInfow
, 0xcf, sizeof(shInfow
));
477 hr
= pSHGetFileInfoW((const WCHAR
*)pidList
, 0, &shInfow
, sizeof(shInfow
),
478 SHGFI_USEFILEATTRIBUTES
|SHGFI_PIDL
|SHGFI_EXETYPE
);
479 todo_wine
ok(hr
!= 0, "SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_EXETYPE Failed\n");
480 todo_wine
ok(shInfow
.iIcon
==0xcfcfcfcf, "Icon Index Modified\n");
481 ok(shInfow
.dwAttributes
==0xcfcfcfcf,"dwAttributes modified\n");
483 memset(&shInfow
, 0xcf, sizeof(shInfow
));
484 hr
= pSHGetFileInfoW((const WCHAR
*)pidList
, 0, &shInfow
, sizeof(shInfow
),
485 SHGFI_USEFILEATTRIBUTES
|SHGFI_PIDL
|SHGFI_ATTRIBUTES
);
486 ok(hr
!= 0, "SHGFI_USEFILEATTRIBUTES|SHGFI_PIDL|SHGFI_ATTRIBUTES Failed\n");
487 todo_wine
ok(shInfow
.iIcon
==0xcfcfcfcf, "Icon Index Modified\n");
488 ok(shInfow
.dwAttributes
!=0xcfcfcfcf,"dwAttributes not set\n");
495 puts into the specified buffer file names with current directory.
496 files - string with file names, separated by null characters. Ends on a double
499 static void set_curr_dir_path(CHAR
*buf
, const CHAR
* files
)
504 strcpy(buf
, CURR_DIR
);
509 buf
+= strlen(buf
) + 1;
510 files
+= strlen(files
) + 1;
516 /* tests the FO_DELETE action */
517 static void test_delete(void)
519 SHFILEOPSTRUCTA shfo
;
521 CHAR buf
[sizeof(CURR_DIR
)+sizeof("/test?.txt")+1];
523 sprintf(buf
, "%s\\%s", CURR_DIR
, "test?.txt");
524 buf
[strlen(buf
) + 1] = '\0';
527 shfo
.wFunc
= FO_DELETE
;
530 shfo
.fFlags
= FOF_FILESONLY
| FOF_NOCONFIRMATION
| FOF_SILENT
;
531 shfo
.hNameMappings
= NULL
;
532 shfo
.lpszProgressTitle
= NULL
;
534 ok(!SHFileOperationA(&shfo
), "Deletion was not successful\n");
535 ok(dir_exists("test4.txt"), "Directory should not have been removed\n");
536 ok(!file_exists("test1.txt"), "File should have been removed\n");
537 ok(!file_exists("test2.txt"), "File should have been removed\n");
538 ok(!file_exists("test3.txt"), "File should have been removed\n");
540 ret
= SHFileOperationA(&shfo
);
541 ok(ret
== ERROR_SUCCESS
, "Directory exists, but is not removed, ret=%d\n", ret
);
542 ok(dir_exists("test4.txt"), "Directory should not have been removed\n");
544 shfo
.fFlags
= FOF_NOCONFIRMATION
| FOF_SILENT
| FOF_NOERRORUI
;
546 ok(!SHFileOperationA(&shfo
), "Directory is not removed\n");
547 ok(!dir_exists("test4.txt"), "Directory should have been removed\n");
549 ret
= SHFileOperationA(&shfo
);
550 ok(!ret
, "The requested file does not exist, ret=%d\n", ret
);
553 sprintf(buf
, "%s\\%s", CURR_DIR
, "test4.txt");
554 buf
[strlen(buf
) + 1] = '\0';
555 ok(MoveFileA("test1.txt", "test4.txt\\test1.txt"), "Filling the subdirectory failed\n");
556 ok(!SHFileOperationA(&shfo
), "Directory is not removed\n");
557 ok(!dir_exists("test4.txt"), "Directory is not removed\n");
560 shfo
.pFrom
= "test1.txt\0test4.txt\0";
561 ok(!SHFileOperationA(&shfo
), "Directory and a file are not removed\n");
562 ok(!file_exists("test1.txt"), "The file should have been removed\n");
563 ok(!dir_exists("test4.txt"), "Directory should have been removed\n");
564 ok(file_exists("test2.txt"), "This file should not have been removed\n");
566 /* FOF_FILESONLY does not delete a dir matching a wildcard */
568 shfo
.fFlags
|= FOF_FILESONLY
;
569 shfo
.pFrom
= "*.txt\0";
570 ok(!SHFileOperation(&shfo
), "Failed to delete files\n");
571 ok(!file_exists("test1.txt"), "test1.txt should have been removed\n");
572 ok(!file_exists("test_5.txt"), "test_5.txt should have been removed\n");
573 ok(dir_exists("test4.txt"), "test4.txt should not have been removed\n");
575 /* FOF_FILESONLY only deletes a dir if explicitly specified */
577 shfo
.pFrom
= "test_?.txt\0test4.txt\0";
578 ok(!SHFileOperation(&shfo
), "Failed to delete files and directory\n");
579 ok(!dir_exists("test4.txt") ||
580 broken(dir_exists("test4.txt")), /* NT4 */
581 "test4.txt should have been removed\n");
582 ok(!file_exists("test_5.txt"), "test_5.txt should have been removed\n");
583 ok(file_exists("test1.txt"), "test1.txt should not have been removed\n");
585 /* try to delete an invalid filename */
587 /* this crashes on win9x */
590 shfo
.fFlags
&= ~FOF_FILESONLY
;
591 shfo
.fAnyOperationsAborted
= FALSE
;
592 ret
= SHFileOperation(&shfo
);
593 ok(ret
== ERROR_ACCESS_DENIED
, "Expected ERROR_ACCESS_DENIED, got %d\n", ret
);
594 ok(!shfo
.fAnyOperationsAborted
, "Expected no aborted operations\n");
595 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
598 /* try an invalid function */
600 shfo
.pFrom
= "test1.txt\0";
602 ret
= SHFileOperation(&shfo
);
603 ok(ret
== ERROR_INVALID_PARAMETER
||
604 broken(ret
== ERROR_SUCCESS
), /* Win9x, NT4 */
605 "Expected ERROR_INVALID_PARAMETER, got %d\n", ret
);
606 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
608 /* try an invalid list, only one null terminator */
610 /* this crashes on win9x */
613 shfo
.wFunc
= FO_DELETE
;
614 ret
= SHFileOperation(&shfo
);
615 ok(ret
== ERROR_ACCESS_DENIED
, "Expected ERROR_ACCESS_DENIED, got %d\n", ret
);
616 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
619 /* delete a nonexistent file */
620 shfo
.pFrom
= "nonexistent.txt\0";
621 shfo
.wFunc
= FO_DELETE
;
622 ret
= SHFileOperation(&shfo
);
625 ret
== ERROR_FILE_NOT_FOUND
|| /* Vista */
626 broken(ret
== ERROR_SUCCESS
), /* NT4 */
627 "Expected 1026 or ERROR_FILE_NOT_FOUND, got %d\n", ret
);
629 /* delete a dir, and then a file inside the dir, same as
630 * deleting a nonexistent file
632 if (ret
!= ERROR_FILE_NOT_FOUND
)
634 /* Vista would throw up a dialog box that we can't suppress */
636 shfo
.pFrom
= "testdir2\0testdir2\\one.txt\0";
637 ret
= SHFileOperation(&shfo
);
638 ok(ret
== ERROR_PATH_NOT_FOUND
||
639 broken(ret
== ERROR_SUCCESS
), /* NT4 */
640 "Expected ERROR_PATH_NOT_FOUND, got %d\n", ret
);
641 ok(!dir_exists("testdir2"), "Expected testdir2 to not exist\n");
642 ok(!file_exists("testdir2\\one.txt"), "Expected testdir2\\one.txt to not exist\n");
645 skip("Test would show a dialog box\n");
647 /* try the FOF_NORECURSION flag, continues deleting subdirs */
649 shfo
.pFrom
= "testdir2\0";
650 shfo
.fFlags
|= FOF_NORECURSION
;
651 ret
= SHFileOperation(&shfo
);
652 ok(ret
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", ret
);
653 ok(!file_exists("testdir2\\one.txt"), "Expected testdir2\\one.txt to not exist\n");
654 ok(!dir_exists("testdir2\\nested"), "Expected testdir2\\nested to not exist\n");
657 /* tests the FO_RENAME action */
658 static void test_rename(void)
660 SHFILEOPSTRUCTA shfo
, shfo2
;
661 CHAR from
[5*MAX_PATH
];
666 shfo
.wFunc
= FO_RENAME
;
669 shfo
.fFlags
= FOF_NOCONFIRMATION
| FOF_SILENT
| FOF_NOERRORUI
;
670 shfo
.hNameMappings
= NULL
;
671 shfo
.lpszProgressTitle
= NULL
;
673 set_curr_dir_path(from
, "test1.txt\0");
674 set_curr_dir_path(to
, "test4.txt\0");
675 retval
= SHFileOperationA(&shfo
);
676 ok(retval
== ERROR_ALREADY_EXISTS
||
677 retval
== DE_FILEDESTISFLD
|| /* Vista */
678 broken(retval
== ERROR_INVALID_NAME
), /* Win9x, NT4 */
679 "Expected ERROR_ALREADY_EXISTS or DE_FILEDESTISFLD, got %d\n", retval
);
680 ok(file_exists("test1.txt"), "The file is renamed\n");
682 set_curr_dir_path(from
, "test3.txt\0");
683 set_curr_dir_path(to
, "test4.txt\\test1.txt\0");
684 retval
= SHFileOperationA(&shfo
);
685 if (retval
== DE_DIFFDIR
)
687 /* Vista and W2K8 (broken or new behavior ?) */
688 ok(!file_exists("test4.txt\\test1.txt"), "The file is renamed\n");
692 ok(retval
== ERROR_SUCCESS
, "File is renamed moving to other directory\n");
693 ok(file_exists("test4.txt\\test1.txt"), "The file is not renamed\n");
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 retval
= SHFileOperationA(&shfo
);
699 ok(retval
== ERROR_GEN_FAILURE
||
700 retval
== DE_MANYSRC1DEST
|| /* Vista */
701 broken(retval
== ERROR_SUCCESS
), /* Win9x */
702 "Expected ERROR_GEN_FAILURE or DE_MANYSRC1DEST , got %d\n", retval
);
703 ok(file_exists("test1.txt"), "The file is renamed - many files are specified\n");
705 memcpy(&shfo2
, &shfo
, sizeof(SHFILEOPSTRUCTA
));
706 shfo2
.fFlags
|= FOF_MULTIDESTFILES
;
708 set_curr_dir_path(from
, "test1.txt\0test2.txt\0test4.txt\0");
709 set_curr_dir_path(to
, "test6.txt\0test7.txt\0test8.txt\0");
710 retval
= SHFileOperationA(&shfo2
);
711 ok(retval
== ERROR_GEN_FAILURE
||
712 retval
== DE_MANYSRC1DEST
|| /* Vista */
713 broken(retval
== ERROR_SUCCESS
), /* Win9x */
714 "Expected ERROR_GEN_FAILURE or DE_MANYSRC1DEST files, got %d\n", retval
);
715 ok(file_exists("test1.txt"), "The file is not renamed - many files are specified\n");
717 set_curr_dir_path(from
, "test1.txt\0");
718 set_curr_dir_path(to
, "test6.txt\0");
719 retval
= SHFileOperationA(&shfo
);
720 ok(retval
== ERROR_SUCCESS
, "Rename file failed, retval = %d\n", retval
);
721 ok(!file_exists("test1.txt"), "The file is not renamed\n");
722 ok(file_exists("test6.txt"), "The file is not renamed\n");
724 set_curr_dir_path(from
, "test6.txt\0");
725 set_curr_dir_path(to
, "test1.txt\0");
726 retval
= SHFileOperationA(&shfo
);
727 ok(retval
== ERROR_SUCCESS
, "Rename file back failed, retval = %d\n", retval
);
729 set_curr_dir_path(from
, "test4.txt\0");
730 set_curr_dir_path(to
, "test6.txt\0");
731 retval
= SHFileOperationA(&shfo
);
732 ok(retval
== ERROR_SUCCESS
, "Rename dir failed, retval = %d\n", retval
);
733 ok(!dir_exists("test4.txt"), "The dir is not renamed\n");
734 ok(dir_exists("test6.txt"), "The dir is not renamed\n");
736 set_curr_dir_path(from
, "test6.txt\0");
737 set_curr_dir_path(to
, "test4.txt\0");
738 retval
= SHFileOperationA(&shfo
);
739 ok(retval
== ERROR_SUCCESS
, "Rename dir back failed, retval = %d\n", retval
);
740 ok(dir_exists("test4.txt"), "The dir is not renamed\n");
742 /* try to rename more than one file to a single file */
743 shfo
.pFrom
= "test1.txt\0test2.txt\0";
744 shfo
.pTo
= "a.txt\0";
745 retval
= SHFileOperationA(&shfo
);
746 ok(retval
== ERROR_GEN_FAILURE
||
747 retval
== DE_MANYSRC1DEST
|| /* Vista */
748 broken(retval
== ERROR_SUCCESS
), /* Win9x */
749 "Expected ERROR_GEN_FAILURE or DE_MANYSRC1DEST, got %d\n", retval
);
750 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
751 ok(file_exists("test2.txt"), "Expected test2.txt to exist\n");
752 ok(!file_exists("a.txt"), "Expected a.txt to not exist\n");
754 /* pFrom doesn't exist */
755 shfo
.pFrom
= "idontexist\0";
756 shfo
.pTo
= "newfile\0";
757 retval
= SHFileOperationA(&shfo
);
759 retval
== ERROR_FILE_NOT_FOUND
|| /* Vista */
760 broken(retval
== ERROR_SUCCESS
), /* NT4 */
761 "Expected 1026 or ERROR_FILE_NOT_FOUND, got %d\n", retval
);
762 ok(!file_exists("newfile"), "Expected newfile to not exist\n");
764 /* pTo already exist */
765 shfo
.pFrom
= "test1.txt\0";
766 shfo
.pTo
= "test2.txt\0";
767 retval
= SHFileOperationA(&shfo
);
768 if (retval
== ERROR_SUCCESS
)
770 /* Vista and W2K8 (broken or new behavior ?) */
771 createTestFile("test1.txt");
775 ok(retval
== ERROR_ALREADY_EXISTS
||
776 broken(retval
== DE_OPCANCELLED
) || /* NT4 */
777 broken(retval
== ERROR_INVALID_NAME
), /* Win9x */
778 "Expected ERROR_ALREADY_EXISTS, got %d\n", retval
);
781 /* pFrom is valid, but pTo is empty */
782 shfo
.pFrom
= "test1.txt\0";
784 retval
= SHFileOperationA(&shfo
);
785 ok(retval
== ERROR_CANCELLED
||
786 retval
== DE_DIFFDIR
|| /* Vista */
787 broken(retval
== DE_OPCANCELLED
) || /* Win9x */
788 broken(retval
== 65652), /* NT4 */
789 "Expected ERROR_CANCELLED or DE_DIFFDIR\n");
790 ok(file_exists("test1.txt"), "Expected test1.txt to exist\n");
794 retval
= SHFileOperationA(&shfo
);
795 ok(retval
== ERROR_ACCESS_DENIED
||
796 retval
== DE_MANYSRC1DEST
|| /* Vista */
797 broken(retval
== ERROR_SUCCESS
), /* Win9x */
798 "Expected ERROR_ACCESS_DENIED or DE_MANYSRC1DEST, got %d\n", retval
);
800 /* pFrom is NULL, commented out because it crashes on nt 4.0 */
804 retval
= SHFileOperationA(&shfo
);
805 ok(retval
== ERROR_INVALID_PARAMETER
, "Expected ERROR_INVALID_PARAMETER, got %d\n", retval
);
809 /* tests the FO_COPY action */
810 static void test_copy(void)
812 SHFILEOPSTRUCTA shfo
, shfo2
;
813 CHAR from
[5*MAX_PATH
];
815 FILEOP_FLAGS tmp_flags
;
821 shfo
.wFunc
= FO_COPY
;
824 shfo
.fFlags
= FOF_NOCONFIRMATION
| FOF_SILENT
| FOF_NOERRORUI
;
825 shfo
.hNameMappings
= NULL
;
826 shfo
.lpszProgressTitle
= NULL
;
828 set_curr_dir_path(from
, "test1.txt\0test2.txt\0test4.txt\0");
829 set_curr_dir_path(to
, "test6.txt\0test7.txt\0test8.txt\0");
830 retval
= SHFileOperationA(&shfo
);
831 if (dir_exists("test6.txt"))
833 /* Vista and W2K8 (broken or new behavior ?) */
834 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
835 ok(DeleteFileA("test6.txt\\test1.txt"), "The file is not copied - many files "
836 "are specified as a target\n");
837 DeleteFileA("test6.txt\\test2.txt");
838 RemoveDirectoryA("test6.txt\\test4.txt");
839 RemoveDirectoryA("test6.txt");
843 expect_retval(ERROR_CANCELLED
, DE_OPCANCELLED
/* Win9x, NT4 */);
844 ok(!file_exists("test6.txt"), "The file is copied - many files are "
845 "specified as a target\n");
848 memcpy(&shfo2
, &shfo
, sizeof(SHFILEOPSTRUCTA
));
849 shfo2
.fFlags
|= FOF_MULTIDESTFILES
;
851 set_curr_dir_path(from
, "test1.txt\0test2.txt\0test4.txt\0");
852 set_curr_dir_path(to
, "test6.txt\0test7.txt\0test8.txt\0");
853 ok(!SHFileOperationA(&shfo2
), "Can't copy many files\n");
854 ok(file_exists("test6.txt"), "The file is not copied - many files are "
855 "specified as a target\n");
856 DeleteFileA("test6.txt");
857 DeleteFileA("test7.txt");
858 RemoveDirectoryA("test8.txt");
860 /* number of sources do not correspond to number of targets */
861 set_curr_dir_path(from
, "test1.txt\0test2.txt\0test4.txt\0");
862 set_curr_dir_path(to
, "test6.txt\0test7.txt\0");
863 retval
= SHFileOperationA(&shfo2
);
864 if (dir_exists("test6.txt"))
866 /* Vista and W2K8 (broken or new behavior ?) */
867 ok(retval
== DE_DESTSAMETREE
, "Expected DE_DESTSAMETREE, got %d\n", retval
);
868 ok(DeleteFileA("test6.txt\\test1.txt"), "The file is not copied - many files "
869 "are specified as a target\n");
870 RemoveDirectoryA("test6.txt");
871 ok(DeleteFileA("test7.txt\\test2.txt"), "The file is not copied - many files "
872 "are specified as a target\n");
873 RemoveDirectoryA("test7.txt");
877 expect_retval(ERROR_CANCELLED
, DE_OPCANCELLED
/* Win9x, NT4 */);
878 ok(!file_exists("test6.txt"), "The file is copied - many files are "
879 "specified as a target\n");
882 set_curr_dir_path(from
, "test1.txt\0");
883 set_curr_dir_path(to
, "test4.txt\0");
884 ok(!SHFileOperationA(&shfo
), "Prepare test to check how directories are copied recursively\n");
885 ok(file_exists("test4.txt\\test1.txt"), "The file is copied\n");
887 set_curr_dir_path(from
, "test?.txt\0");
888 set_curr_dir_path(to
, "testdir2\0");
889 ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n");
890 ok(!file_exists("testdir2\\test4.txt"), "The directory is not copied yet\n");
891 ok(!SHFileOperationA(&shfo
), "Files and directories are copied to directory\n");
892 ok(file_exists("testdir2\\test1.txt"), "The file is copied\n");
893 ok(file_exists("testdir2\\test4.txt"), "The directory is copied\n");
894 ok(file_exists("testdir2\\test4.txt\\test1.txt"), "The file in subdirectory is copied\n");
895 clean_after_shfo_tests();
898 shfo
.fFlags
|= FOF_FILESONLY
;
899 ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n");
900 ok(!file_exists("testdir2\\test4.txt"), "The directory is not copied yet\n");
901 ok(!SHFileOperationA(&shfo
), "Files are copied to other directory\n");
902 ok(file_exists("testdir2\\test1.txt"), "The file is copied\n");
903 ok(!file_exists("testdir2\\test4.txt"), "The directory is copied\n");
904 clean_after_shfo_tests();
907 set_curr_dir_path(from
, "test1.txt\0test2.txt\0");
908 ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n");
909 ok(!file_exists("testdir2\\test2.txt"), "The file is not copied yet\n");
910 ok(!SHFileOperationA(&shfo
), "Files are copied to other directory\n");
911 ok(file_exists("testdir2\\test1.txt"), "The file is copied\n");
912 ok(file_exists("testdir2\\test2.txt"), "The file is copied\n");
913 clean_after_shfo_tests();
915 /* Copying multiple files with one not existing as source, fails the
916 entire operation in Win98/ME/2K/XP, but not in 95/NT */
918 tmp_flags
= shfo
.fFlags
;
919 set_curr_dir_path(from
, "test1.txt\0test10.txt\0test2.txt\0");
920 ok(!file_exists("testdir2\\test1.txt"), "The file is not copied yet\n");
921 ok(!file_exists("testdir2\\test2.txt"), "The file is not copied yet\n");
922 retval
= SHFileOperationA(&shfo
);
923 if (retval
== ERROR_SUCCESS
)
924 /* Win 95/NT returns success but copies only the files up to the nonexistent source */
925 ok(file_exists("testdir2\\test1.txt"), "The file is not copied\n");
928 /* Failure if one source file does not exist */
929 ok(retval
== 1026 || /* Win 98/ME/2K/XP */
930 retval
== ERROR_FILE_NOT_FOUND
, /* Vista and W2K8 */
931 "Files are copied to other directory\n");
932 ok(!file_exists("testdir2\\test1.txt"), "The file is copied\n");
934 ok(!file_exists("testdir2\\test2.txt"), "The file is copied\n");
935 shfo
.fFlags
= tmp_flags
;
937 /* copy into a nonexistent directory */
939 shfo
.fFlags
= FOF_NOCONFIRMMKDIR
;
940 set_curr_dir_path(from
, "test1.txt\0");
941 set_curr_dir_path(to
, "nonexistent\\notreal\\test2.txt\0");
942 retval
= SHFileOperation(&shfo
);
943 ok(!retval
, "Error copying into nonexistent directory\n");
944 ok(file_exists("nonexistent"), "nonexistent not created\n");
945 ok(file_exists("nonexistent\\notreal"), "nonexistent\\notreal not created\n");
946 ok(file_exists("nonexistent\\notreal\\test2.txt"), "Directory not created\n");
947 ok(!file_exists("nonexistent\\notreal\\test1.txt"), "test1.txt should not exist\n");
949 /* a relative dest directory is OK */
950 clean_after_shfo_tests();
952 shfo
.pFrom
= "test1.txt\0test2.txt\0test3.txt\0";
953 shfo
.pTo
= "testdir2\0";
954 retval
= SHFileOperation(&shfo
);
955 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
956 ok(file_exists("testdir2\\test1.txt"), "Expected testdir2\\test1 to exist\n");
958 /* try to copy files to a file */
959 clean_after_shfo_tests();
963 /* suppress the error-dialog in win9x here */
964 shfo
.fFlags
|= FOF_NOERRORUI
;
965 set_curr_dir_path(from
, "test1.txt\0test2.txt\0");
966 set_curr_dir_path(to
, "test3.txt\0");
967 retval
= SHFileOperation(&shfo
);
968 if (retval
== DE_FLDDESTISFILE
|| /* Vista and W2K8 */
969 retval
== DE_INVALIDFILES
) /* Win7 */
971 /* Most likely new behavior */
972 ok(!shfo
.fAnyOperationsAborted
, "Didn't expect aborted operations\n");
976 expect_retval(ERROR_CANCELLED
, DE_OPCANCELLED
/* Win9x, NT4 */);
977 ok(shfo
.fAnyOperationsAborted
, "Expected aborted operations\n");
979 ok(!file_exists("test3.txt\\test2.txt"), "Expected test3.txt\\test2.txt to not exist\n");
981 /* try to copy many files to nonexistent directory */
983 shfo
.fFlags
&= ~FOF_NOERRORUI
;
984 shfo
.fAnyOperationsAborted
= FALSE
;
985 retval
= SHFileOperation(&shfo
);
986 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
987 ok(DeleteFile("test3.txt\\test1.txt"), "Expected test3.txt\\test1.txt to exist\n");
988 ok(DeleteFile("test3.txt\\test2.txt"), "Expected test3.txt\\test1.txt to exist\n");
989 ok(RemoveDirectory(to
), "Expected test3.txt to exist\n");
991 /* send in FOF_MULTIDESTFILES with too many destination files */
993 shfo
.pFrom
= "test1.txt\0test2.txt\0test3.txt\0";
994 shfo
.pTo
= "testdir2\\a.txt\0testdir2\\b.txt\0testdir2\\c.txt\0testdir2\\d.txt\0";
995 shfo
.fFlags
|= FOF_NOERRORUI
| FOF_MULTIDESTFILES
;
996 retval
= SHFileOperation(&shfo
);
997 if (dir_exists("testdir2\\a.txt"))
999 /* Vista and W2K8 (broken or new behavior ?) */
1000 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1001 ok(DeleteFile("testdir2\\a.txt\\test1.txt"), "Expected testdir2\\a.txt\\test1.txt to exist\n");
1002 RemoveDirectory("testdir2\\a.txt");
1003 ok(DeleteFile("testdir2\\b.txt\\test2.txt"), "Expected testdir2\\b.txt\\test2.txt to exist\n");
1004 RemoveDirectory("testdir2\\b.txt");
1005 ok(DeleteFile("testdir2\\c.txt\\test3.txt"), "Expected testdir2\\c.txt\\test3.txt to exist\n");
1006 RemoveDirectory("testdir2\\c.txt");
1007 ok(!file_exists("testdir2\\d.txt"), "Expected testdir2\\d.txt to not exist\n");
1011 expect_retval(ERROR_CANCELLED
, DE_OPCANCELLED
/* Win9x, NT4 */);
1012 ok(shfo
.fAnyOperationsAborted
||
1013 broken(!shfo
.fAnyOperationsAborted
), /* NT4 */
1014 "Expected aborted operations\n");
1015 ok(!file_exists("testdir2\\a.txt"), "Expected testdir2\\a.txt to not exist\n");
1018 /* send in FOF_MULTIDESTFILES with too many destination files */
1019 shfo
.pFrom
= "test1.txt\0test2.txt\0test3.txt\0";
1020 shfo
.pTo
= "e.txt\0f.txt\0";
1021 shfo
.fAnyOperationsAborted
= FALSE
;
1022 retval
= SHFileOperation(&shfo
);
1023 if (dir_exists("e.txt"))
1025 /* Vista and W2K8 (broken or new behavior ?) */
1026 ok(retval
== DE_SAMEFILE
, "Expected DE_SAMEFILE, got %d\n", retval
);
1027 ok(DeleteFile("e.txt\\test1.txt"), "Expected e.txt\\test1.txt to exist\n");
1028 RemoveDirectory("e.txt");
1029 ok(DeleteFile("f.txt\\test2.txt"), "Expected f.txt\\test2.txt to exist\n");
1030 RemoveDirectory("f.txt");
1034 expect_retval(ERROR_CANCELLED
, DE_OPCANCELLED
/* Win9x, NT4 */);
1035 ok(shfo
.fAnyOperationsAborted
||
1036 broken(!shfo
.fAnyOperationsAborted
), /* NT4 */
1037 "Expected aborted operations\n");
1038 ok(!file_exists("e.txt"), "Expected e.txt to not exist\n");
1041 /* use FOF_MULTIDESTFILES with files and a source directory */
1042 shfo
.pFrom
= "test1.txt\0test2.txt\0test4.txt\0";
1043 shfo
.pTo
= "testdir2\\a.txt\0testdir2\\b.txt\0testdir2\\c.txt\0";
1044 shfo
.fAnyOperationsAborted
= FALSE
;
1045 retval
= SHFileOperation(&shfo
);
1046 ok(retval
== ERROR_SUCCESS
||
1047 broken(retval
== 0x100a1), /* WinMe */
1048 "Expected ERROR_SUCCESS, got %d\n", retval
);
1049 ok(DeleteFile("testdir2\\a.txt"), "Expected testdir2\\a.txt to exist\n");
1050 ok(DeleteFile("testdir2\\b.txt"), "Expected testdir2\\b.txt to exist\n");
1051 if (retval
== ERROR_SUCCESS
)
1052 ok(RemoveDirectory("testdir2\\c.txt"), "Expected testdir2\\c.txt to exist\n");
1054 /* try many dest files without FOF_MULTIDESTFILES flag */
1055 shfo
.pFrom
= "test1.txt\0test2.txt\0test3.txt\0";
1056 shfo
.pTo
= "a.txt\0b.txt\0c.txt\0";
1057 shfo
.fAnyOperationsAborted
= FALSE
;
1058 shfo
.fFlags
&= ~FOF_MULTIDESTFILES
;
1059 retval
= SHFileOperation(&shfo
);
1060 if (dir_exists("a.txt"))
1062 /* Vista and W2K8 (broken or new behavior ?) */
1063 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1064 ok(DeleteFile("a.txt\\test1.txt"), "Expected a.txt\\test1.txt to exist\n");
1065 ok(DeleteFile("a.txt\\test2.txt"), "Expected a.txt\\test2.txt to exist\n");
1066 ok(DeleteFile("a.txt\\test3.txt"), "Expected a.txt\\test3.txt to exist\n");
1067 RemoveDirectory("a.txt");
1071 expect_retval(ERROR_CANCELLED
, DE_OPCANCELLED
/* Win9x, NT4 */);
1072 ok(!file_exists("a.txt"), "Expected a.txt to not exist\n");
1076 shfo
.pFrom
= "test?.txt\0";
1077 shfo
.pTo
= "testdir2\0";
1078 shfo
.fFlags
&= ~FOF_MULTIDESTFILES
;
1079 retval
= SHFileOperation(&shfo
);
1080 ok(retval
== ERROR_SUCCESS
||
1081 broken(retval
== 0x100a1), /* WinMe */
1082 "Expected ERROR_SUCCESS, got %d\n", retval
);
1083 ok(file_exists("testdir2\\test1.txt"), "Expected testdir2\\test1.txt to exist\n");
1085 /* try a glob with FOF_FILESONLY */
1086 clean_after_shfo_tests();
1088 shfo
.pFrom
= "test?.txt\0";
1089 shfo
.fFlags
|= FOF_FILESONLY
;
1090 retval
= SHFileOperation(&shfo
);
1091 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1092 ok(file_exists("testdir2\\test1.txt"), "Expected testdir2\\test1.txt to exist\n");
1093 ok(!dir_exists("testdir2\\test4.txt"), "Expected testdir2\\test4.txt to not exist\n");
1095 /* try a glob with FOF_MULTIDESTFILES and the same number
1096 * of dest files that we would expect
1098 clean_after_shfo_tests();
1100 shfo
.pTo
= "testdir2\\a.txt\0testdir2\\b.txt\0testdir2\\c.txt\0testdir2\\d.txt\0";
1101 shfo
.fFlags
&= ~FOF_FILESONLY
;
1102 shfo
.fFlags
|= FOF_MULTIDESTFILES
;
1103 retval
= SHFileOperation(&shfo
);
1104 if (dir_exists("testdir2\\a.txt"))
1106 /* Vista and W2K8 (broken or new behavior ?) */
1107 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1108 ok(DeleteFile("testdir2\\a.txt\\test1.txt"), "Expected testdir2\\a.txt\\test1.txt to exist\n");
1109 ok(DeleteFile("testdir2\\a.txt\\test2.txt"), "Expected testdir2\\a.txt\\test2.txt to exist\n");
1110 ok(DeleteFile("testdir2\\a.txt\\test3.txt"), "Expected testdir2\\a.txt\\test3.txt to exist\n");
1111 ok(RemoveDirectory("testdir2\\a.txt\\test4.txt"), "Expected testdir2\\a.txt\\test4.txt to exist\n");
1112 RemoveDirectory("testdir2\\a.txt");
1116 expect_retval(ERROR_CANCELLED
, DE_OPCANCELLED
/* Win9x, NT4 */);
1117 ok(shfo
.fAnyOperationsAborted
||
1118 broken(!shfo
.fAnyOperationsAborted
), /* NT4 */
1119 "Expected aborted operations\n");
1120 ok(!file_exists("testdir2\\a.txt"), "Expected testdir2\\test1.txt to not exist\n");
1122 ok(!RemoveDirectory("b.txt"), "b.txt should not exist\n");
1124 /* copy one file to two others, second is ignored */
1125 clean_after_shfo_tests();
1127 shfo
.pFrom
= "test1.txt\0";
1128 shfo
.pTo
= "b.txt\0c.txt\0";
1129 shfo
.fAnyOperationsAborted
= FALSE
;
1130 retval
= SHFileOperation(&shfo
);
1131 if (retval
== DE_OPCANCELLED
)
1133 /* NT4 fails and doesn't copy any files */
1134 ok(!file_exists("b.txt"), "Expected b.txt to not exist\n");
1135 /* Needed to skip some tests */
1136 win_skip("Skipping some tests on NT4\n");
1141 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1142 ok(DeleteFile("b.txt"), "Expected b.txt to exist\n");
1144 ok(!DeleteFile("c.txt"), "Expected c.txt to not exist\n");
1146 /* copy two file to three others, all fail */
1147 shfo
.pFrom
= "test1.txt\0test2.txt\0";
1148 shfo
.pTo
= "b.txt\0c.txt\0d.txt\0";
1149 retval
= SHFileOperation(&shfo
);
1150 if (dir_exists("b.txt"))
1152 /* Vista and W2K8 (broken or new behavior ?) */
1153 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1154 ok(DeleteFile("b.txt\\test1.txt"), "Expected b.txt\\test1.txt to exist\n");
1155 RemoveDirectory("b.txt");
1156 ok(DeleteFile("c.txt\\test2.txt"), "Expected c.txt\\test2.txt to exist\n");
1157 RemoveDirectory("c.txt");
1161 expect_retval(ERROR_CANCELLED
, DE_OPCANCELLED
/* Win9x, NT4 */);
1162 ok(shfo
.fAnyOperationsAborted
||
1163 broken(!shfo
.fAnyOperationsAborted
), /* NT4 */
1164 "Expected aborted operations\n");
1165 ok(!DeleteFile("b.txt"), "Expected b.txt to not exist\n");
1168 /* copy one file and one directory to three others */
1169 shfo
.pFrom
= "test1.txt\0test4.txt\0";
1170 shfo
.pTo
= "b.txt\0c.txt\0d.txt\0";
1171 shfo
.fAnyOperationsAborted
= FALSE
;
1172 retval
= SHFileOperation(&shfo
);
1173 if (dir_exists("b.txt"))
1175 /* Vista and W2K8 (broken or new behavior ?) */
1176 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1177 ok(DeleteFile("b.txt\\test1.txt"), "Expected b.txt\\test1.txt to exist\n");
1178 RemoveDirectory("b.txt");
1179 ok(RemoveDirectory("c.txt\\test4.txt"), "Expected c.txt\\test4.txt to exist\n");
1180 RemoveDirectory("c.txt");
1184 expect_retval(ERROR_CANCELLED
, DE_OPCANCELLED
/* Win9x, NT4 */);
1185 ok(shfo
.fAnyOperationsAborted
||
1186 broken(!shfo
.fAnyOperationsAborted
), /* NT4 */
1187 "Expected aborted operations\n");
1188 ok(!DeleteFile("b.txt"), "Expected b.txt to not exist\n");
1189 ok(!DeleteFile("c.txt"), "Expected c.txt to not exist\n");
1192 /* copy a directory with a file beneath it, plus some files */
1193 createTestFile("test4.txt\\a.txt");
1194 shfo
.pFrom
= "test4.txt\0test1.txt\0";
1195 shfo
.pTo
= "testdir2\0";
1196 shfo
.fFlags
&= ~FOF_MULTIDESTFILES
;
1197 shfo
.fAnyOperationsAborted
= FALSE
;
1198 retval
= SHFileOperation(&shfo
);
1199 ok(retval
== ERROR_SUCCESS
||
1200 broken(retval
== 0x100a1), /* WinMe */
1201 "Expected ERROR_SUCCESS, got %d\n", retval
);
1202 if (retval
== ERROR_SUCCESS
)
1204 ok(DeleteFile("testdir2\\test1.txt"), "Expected testdir2\\test1.txt to exist\n");
1205 ok(DeleteFile("testdir2\\test4.txt\\a.txt"), "Expected a.txt to exist\n");
1206 ok(RemoveDirectory("testdir2\\test4.txt"), "Expected testdir2\\test4.txt to exist\n");
1209 /* copy one directory and a file in that dir to another dir */
1210 shfo
.pFrom
= "test4.txt\0test4.txt\\a.txt\0";
1211 shfo
.pTo
= "testdir2\0";
1212 retval
= SHFileOperation(&shfo
);
1213 ok(retval
== ERROR_SUCCESS
||
1214 broken(retval
== 0x100a1), /* WinMe */
1215 "Expected ERROR_SUCCESS, got %d\n", retval
);
1216 if (retval
== ERROR_SUCCESS
)
1218 ok(DeleteFile("testdir2\\test4.txt\\a.txt"), "Expected a.txt to exist\n");
1219 ok(DeleteFile("testdir2\\a.txt"), "Expected testdir2\\a.txt to exist\n");
1222 /* copy a file in a directory first, and then the directory to a nonexistent dir */
1223 shfo
.pFrom
= "test4.txt\\a.txt\0test4.txt\0";
1224 shfo
.pTo
= "nonexistent\0";
1225 retval
= SHFileOperation(&shfo
);
1226 if (dir_exists("nonexistent"))
1228 /* Vista and W2K8 (broken or new behavior ?) */
1229 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1230 ok(DeleteFile("nonexistent\\test4.txt\\a.txt"), "Expected nonexistent\\test4.txt\\a.txt to exist\n");
1231 RemoveDirectory("nonexistent\\test4.txt");
1232 ok(DeleteFile("nonexistent\\a.txt"), "Expected nonexistent\\a.txt to exist\n");
1233 RemoveDirectory("nonexistent");
1237 expect_retval(ERROR_CANCELLED
, DE_OPCANCELLED
/* Win9x, NT4 */);
1238 ok(shfo
.fAnyOperationsAborted
||
1239 broken(!shfo
.fAnyOperationsAborted
), /* NT4 */
1240 "Expected aborted operations\n");
1241 ok(!file_exists("nonexistent\\test4.txt"), "Expected nonexistent\\test4.txt to not exist\n");
1243 DeleteFile("test4.txt\\a.txt");
1245 /* destination is same as source file */
1246 shfo
.pFrom
= "test1.txt\0test2.txt\0test3.txt\0";
1247 shfo
.pTo
= "b.txt\0test2.txt\0c.txt\0";
1248 shfo
.fAnyOperationsAborted
= FALSE
;
1249 shfo
.fFlags
= FOF_NOERRORUI
| FOF_MULTIDESTFILES
;
1250 retval
= SHFileOperation(&shfo
);
1251 if (retval
== DE_OPCANCELLED
)
1253 /* NT4 fails and doesn't copy any files */
1254 ok(!file_exists("b.txt"), "Expected b.txt to not exist\n");
1258 ok(retval
== DE_SAMEFILE
, "Expected DE_SAMEFILE, got %d\n", retval
);
1259 ok(DeleteFile("b.txt"), "Expected b.txt to exist\n");
1261 ok(!shfo
.fAnyOperationsAborted
, "Expected no operations to be aborted\n");
1262 ok(!file_exists("c.txt"), "Expected c.txt to not exist\n");
1264 /* destination is same as source directory */
1265 shfo
.pFrom
= "test1.txt\0test4.txt\0test3.txt\0";
1266 shfo
.pTo
= "b.txt\0test4.txt\0c.txt\0";
1267 shfo
.fAnyOperationsAborted
= FALSE
;
1268 retval
= SHFileOperation(&shfo
);
1269 if (retval
== DE_OPCANCELLED
)
1271 /* NT4 fails and doesn't copy any files */
1272 ok(!file_exists("b.txt"), "Expected b.txt to not exist\n");
1276 ok(retval
== ERROR_SUCCESS
||
1277 retval
== DE_DESTSAMETREE
, /* Vista */
1278 "Expected ERROR_SUCCESS or DE_DESTSAMETREE, got %d\n", retval
);
1279 ok(DeleteFile("b.txt"), "Expected b.txt to exist\n");
1281 ok(!file_exists("c.txt"), "Expected c.txt to not exist\n");
1283 /* copy a directory into itself, error displayed in UI */
1284 shfo
.pFrom
= "test4.txt\0";
1285 shfo
.pTo
= "test4.txt\\newdir\0";
1286 shfo
.fFlags
&= ~FOF_MULTIDESTFILES
;
1287 shfo
.fAnyOperationsAborted
= FALSE
;
1288 retval
= SHFileOperation(&shfo
);
1289 ok(retval
== ERROR_SUCCESS
||
1290 retval
== DE_DESTSUBTREE
, /* Vista */
1291 "Expected ERROR_SUCCESS or DE_DESTSUBTREE, got %d\n", retval
);
1292 ok(!RemoveDirectory("test4.txt\\newdir"), "Expected test4.txt\\newdir to not exist\n");
1294 /* copy a directory to itself, error displayed in UI */
1295 shfo
.pFrom
= "test4.txt\0";
1296 shfo
.pTo
= "test4.txt\0";
1297 shfo
.fAnyOperationsAborted
= FALSE
;
1298 retval
= SHFileOperation(&shfo
);
1299 ok(retval
== ERROR_SUCCESS
||
1300 retval
== DE_DESTSUBTREE
, /* Vista */
1301 "Expected ERROR_SUCCESS or DE_DESTSUBTREE, got %d\n", retval
);
1303 /* copy a file into a directory, and the directory into itself */
1304 shfo
.pFrom
= "test1.txt\0test4.txt\0";
1305 shfo
.pTo
= "test4.txt\0";
1306 shfo
.fAnyOperationsAborted
= FALSE
;
1307 shfo
.fFlags
|= FOF_NOCONFIRMATION
;
1308 retval
= SHFileOperation(&shfo
);
1309 ok(retval
== ERROR_SUCCESS
||
1310 retval
== DE_DESTSUBTREE
, /* Vista */
1311 "Expected ERROR_SUCCESS or DE_DESTSUBTREE, got %d\n", retval
);
1312 ok(DeleteFile("test4.txt\\test1.txt"), "Expected test4.txt\\test1.txt to exist\n");
1314 /* copy a file to a file, and the directory into itself */
1315 shfo
.pFrom
= "test1.txt\0test4.txt\0";
1316 shfo
.pTo
= "test4.txt\\a.txt\0";
1317 shfo
.fAnyOperationsAborted
= FALSE
;
1318 retval
= SHFileOperation(&shfo
);
1319 if (dir_exists("test4.txt\\a.txt"))
1321 /* Vista and W2K8 (broken or new behavior ?) */
1322 ok(retval
== DE_DESTSUBTREE
, "Expected DE_DESTSUBTREE, got %d\n", retval
);
1323 ok(DeleteFile("test4.txt\\a.txt\\test1.txt"), "Expected test4.txt\\a.txt\\test1.txt to exist\n");
1324 RemoveDirectory("test4.txt\\a.txt");
1328 expect_retval(ERROR_CANCELLED
, DE_OPCANCELLED
/* Win9x, NT4 */);
1329 ok(!file_exists("test4.txt\\a.txt"), "Expected test4.txt\\a.txt to not exist\n");
1332 /* copy a nonexistent file to a nonexistent directory */
1333 shfo
.pFrom
= "e.txt\0";
1334 shfo
.pTo
= "nonexistent\0";
1335 shfo
.fAnyOperationsAborted
= FALSE
;
1336 retval
= SHFileOperation(&shfo
);
1337 ok(retval
== 1026 ||
1338 retval
== ERROR_FILE_NOT_FOUND
|| /* Vista */
1339 broken(retval
== ERROR_SUCCESS
), /* NT4 */
1340 "Expected 1026 or ERROR_FILE_NOT_FOUND, got %d\n", retval
);
1341 ok(!file_exists("nonexistent\\e.txt"), "Expected nonexistent\\e.txt to not exist\n");
1342 ok(!file_exists("nonexistent"), "Expected nonexistent to not exist\n");
1344 /* Overwrite tests */
1345 clean_after_shfo_tests();
1349 /* NT4 would throw up some dialog boxes and doesn't copy files that are needed
1350 * in subsequent tests.
1352 shfo
.fFlags
= FOF_NOCONFIRMATION
;
1353 shfo
.pFrom
= "test1.txt\0";
1354 shfo
.pTo
= "test2.txt\0";
1355 shfo
.fAnyOperationsAborted
= FALSE
;
1356 /* without FOF_NOCONFIRMATION the confirmation is Yes/No */
1357 retval
= SHFileOperation(&shfo
);
1358 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1359 ok(file_has_content("test2.txt", "test1.txt\n"), "The file was not copied\n");
1361 shfo
.pFrom
= "test3.txt\0test1.txt\0";
1362 shfo
.pTo
= "test2.txt\0one.txt\0";
1363 shfo
.fFlags
= FOF_NOCONFIRMATION
| FOF_MULTIDESTFILES
;
1364 /* without FOF_NOCONFIRMATION the confirmation is Yes/Yes to All/No/Cancel */
1365 retval
= SHFileOperation(&shfo
);
1366 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1367 ok(file_has_content("test2.txt", "test3.txt\n"), "The file was not copied\n");
1369 shfo
.pFrom
= "one.txt\0";
1370 shfo
.pTo
= "testdir2\0";
1371 shfo
.fFlags
= FOF_NOCONFIRMATION
;
1372 /* without FOF_NOCONFIRMATION the confirmation is Yes/No */
1373 retval
= SHFileOperation(&shfo
);
1374 ok(retval
== 0, "Expected 0, got %d\n", retval
);
1375 ok(file_has_content("testdir2\\one.txt", "test1.txt\n"), "The file was not copied\n");
1378 createTestFile("test4.txt\\test1.txt");
1379 shfo
.pFrom
= "test4.txt\0";
1380 shfo
.pTo
= "testdir2\0";
1381 /* WinMe needs FOF_NOERRORUI */
1382 shfo
.fFlags
= FOF_NOCONFIRMATION
| FOF_NOERRORUI
;
1383 retval
= SHFileOperation(&shfo
);
1384 ok(retval
== ERROR_SUCCESS
||
1385 broken(retval
== 0x100a1), /* WinMe */
1386 "Expected ERROR_SUCCESS, got %d\n", retval
);
1387 shfo
.fFlags
= FOF_NOCONFIRMATION
;
1390 createTestFile("test4.txt\\.\\test1.txt"); /* modify the content of the file */
1391 /* without FOF_NOCONFIRMATION the confirmation is "This folder already contains a folder named ..." */
1392 retval
= SHFileOperation(&shfo
);
1393 ok(retval
== 0, "Expected 0, got %d\n", retval
);
1394 ok(file_has_content("testdir2\\test4.txt\\test1.txt", "test4.txt\\.\\test1.txt\n"), "The file was not copied\n");
1397 createTestFile("one.txt");
1399 /* pFrom contains bogus 2nd name longer than MAX_PATH */
1400 memset(from
, 'a', MAX_PATH
*2);
1401 memset(from
+MAX_PATH
*2, 0, 2);
1402 lstrcpyA(from
, "one.txt");
1404 shfo
.pTo
= "two.txt\0";
1405 shfo
.fFlags
= FOF_NOCONFIRMATION
| FOF_SILENT
| FOF_NOERRORUI
;
1406 retval
= SHFileOperation(&shfo
);
1407 ok(retval
== 1148 || retval
== 1026 ||
1408 retval
== ERROR_ACCESS_DENIED
|| /* win2k */
1409 retval
== DE_INVALIDFILES
, /* Vista */
1410 "Unexpected return value, got %d\n", retval
);
1411 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1412 if (dir_exists("two.txt"))
1413 /* Vista and W2K8 (broken or new behavior ?) */
1414 ok(RemoveDirectory("two.txt"), "Expected two.txt to exist\n");
1416 ok(!DeleteFileA("two.txt"), "Expected file to not exist\n");
1418 createTestFile("one.txt");
1420 /* pTo contains bogus 2nd name longer than MAX_PATH */
1421 memset(to
, 'a', MAX_PATH
*2);
1422 memset(to
+MAX_PATH
*2, 0, 2);
1423 lstrcpyA(to
, "two.txt");
1424 shfo
.pFrom
= "one.txt\0";
1426 shfo
.fFlags
= FOF_NOCONFIRMATION
| FOF_SILENT
| FOF_NOERRORUI
;
1427 retval
= SHFileOperation(&shfo
);
1428 if (retval
== DE_OPCANCELLED
)
1430 /* NT4 fails and doesn't copy any files */
1431 ok(!file_exists("two.txt"), "Expected two.txt to not exist\n");
1435 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1436 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1438 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1440 createTestFile("one.txt");
1442 /* no FOF_MULTIDESTFILES, two files in pTo */
1443 shfo
.pFrom
= "one.txt\0";
1444 shfo
.pTo
= "two.txt\0three.txt\0";
1445 shfo
.fFlags
= FOF_NOCONFIRMATION
| FOF_SILENT
| FOF_NOERRORUI
;
1446 retval
= SHFileOperation(&shfo
);
1447 if (retval
== DE_OPCANCELLED
)
1449 /* NT4 fails and doesn't copy any files */
1450 ok(!file_exists("two.txt"), "Expected two.txt to not exist\n");
1454 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1455 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1457 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1459 createTestFile("one.txt");
1461 /* both pFrom and pTo contain bogus 2nd names longer than MAX_PATH */
1462 memset(from
, 'a', MAX_PATH
*2);
1463 memset(from
+MAX_PATH
*2, 0, 2);
1464 memset(to
, 'a', MAX_PATH
*2);
1465 memset(to
+MAX_PATH
*2, 0, 2);
1466 lstrcpyA(from
, "one.txt");
1467 lstrcpyA(to
, "two.txt");
1470 shfo
.fFlags
= FOF_NOCONFIRMATION
| FOF_SILENT
| FOF_NOERRORUI
;
1471 retval
= SHFileOperation(&shfo
);
1472 ok(retval
== 1148 || retval
== 1026 ||
1473 retval
== ERROR_ACCESS_DENIED
|| /* win2k */
1474 retval
== DE_INVALIDFILES
, /* Vista */
1475 "Unexpected return value, got %d\n", retval
);
1476 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1477 if (dir_exists("two.txt"))
1478 /* Vista and W2K8 (broken or new behavior ?) */
1479 ok(RemoveDirectory("two.txt"), "Expected two.txt to exist\n");
1481 ok(!DeleteFileA("two.txt"), "Expected file to not exist\n");
1483 createTestFile("one.txt");
1485 /* pTo contains bogus 2nd name longer than MAX_PATH, FOF_MULTIDESTFILES */
1486 memset(to
, 'a', MAX_PATH
*2);
1487 memset(to
+MAX_PATH
*2, 0, 2);
1488 lstrcpyA(to
, "two.txt");
1489 shfo
.pFrom
= "one.txt\0";
1491 shfo
.fFlags
= FOF_MULTIDESTFILES
| FOF_NOCONFIRMATION
|
1492 FOF_SILENT
| FOF_NOERRORUI
;
1493 retval
= SHFileOperation(&shfo
);
1494 if (retval
== DE_OPCANCELLED
)
1496 /* NT4 fails and doesn't copy any files */
1497 ok(!file_exists("two.txt"), "Expected two.txt to not exist\n");
1501 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1502 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1504 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1506 createTestFile("one.txt");
1507 createTestFile("two.txt");
1509 /* pTo contains bogus 2nd name longer than MAX_PATH,
1510 * multiple source files,
1511 * dest directory does not exist
1513 memset(to
, 'a', 2 * MAX_PATH
);
1514 memset(to
+MAX_PATH
*2, 0, 2);
1515 lstrcpyA(to
, "threedir");
1516 shfo
.pFrom
= "one.txt\0two.txt\0";
1518 shfo
.fFlags
= FOF_NOCONFIRMATION
| FOF_SILENT
| FOF_NOERRORUI
;
1519 retval
= SHFileOperation(&shfo
);
1520 if (dir_exists("threedir"))
1522 /* Vista and W2K8 (broken or new behavior ?) */
1523 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1524 ok(DeleteFileA("threedir\\one.txt"), "Expected file to exist\n");
1525 ok(DeleteFileA("threedir\\two.txt"), "Expected file to exist\n");
1526 ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
1530 expect_retval(ERROR_CANCELLED
, DE_OPCANCELLED
/* Win9x, NT4 */);
1531 ok(!DeleteFileA("threedir\\one.txt"), "Expected file to not exist\n");
1532 ok(!DeleteFileA("threedir\\two.txt"), "Expected file to not exist\n");
1533 ok(!DeleteFileA("threedir"), "Expected file to not exist\n");
1534 ok(!RemoveDirectoryA("threedir"), "Expected dir to not exist\n");
1536 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1537 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1539 createTestFile("one.txt");
1540 createTestFile("two.txt");
1541 CreateDirectoryA("threedir", NULL
);
1543 /* pTo contains bogus 2nd name longer than MAX_PATH,
1544 * multiple source files,
1545 * dest directory does exist
1547 memset(to
, 'a', 2 * MAX_PATH
);
1548 memset(to
+MAX_PATH
*2, 0, 2);
1549 lstrcpyA(to
, "threedir");
1550 shfo
.pFrom
= "one.txt\0two.txt\0";
1552 shfo
.fFlags
= FOF_NOCONFIRMATION
| FOF_SILENT
| FOF_NOERRORUI
;
1553 retval
= SHFileOperation(&shfo
);
1554 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1555 ok(DeleteFileA("threedir\\one.txt"), "Expected file to exist\n");
1556 ok(DeleteFileA("threedir\\two.txt"), "Expected file to exist\n");
1557 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1558 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1559 ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
1562 /* this crashes on win9x */
1563 createTestFile("one.txt");
1564 createTestFile("two.txt");
1566 /* pTo contains bogus 2nd name longer than MAX_PATH,
1567 * multiple source files, FOF_MULTIDESTFILES
1568 * dest dir does not exist
1571 memset(to
, 'a', 2 * MAX_PATH
);
1572 memset(to
+MAX_PATH
*2, 0, 2);
1573 lstrcpyA(to
, "threedir");
1574 shfo
.pFrom
= "one.txt\0two.txt\0";
1576 shfo
.fFlags
= FOF_MULTIDESTFILES
| FOF_NOCONFIRMATION
|
1577 FOF_SILENT
| FOF_NOERRORUI
;
1578 retval
= SHFileOperation(&shfo
);
1579 ok(retval
== ERROR_CANCELLED
||
1580 retval
== ERROR_SUCCESS
, /* win2k3 */
1581 "Expected ERROR_CANCELLED or ERROR_SUCCESS, got %d\n", retval
);
1582 ok(!DeleteFileA("threedir\\one.txt"), "Expected file to not exist\n");
1583 ok(!DeleteFileA("threedir\\two.txt"), "Expected file to not exist\n");
1584 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1585 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1586 ok(!RemoveDirectoryA("threedir"), "Expected dir to not exist\n");
1588 /* file exists in win2k */
1589 DeleteFileA("threedir");
1593 createTestFile("one.txt");
1594 createTestFile("two.txt");
1595 CreateDirectoryA("threedir", NULL
);
1597 /* pTo contains bogus 2nd name longer than MAX_PATH,
1598 * multiple source files, FOF_MULTIDESTFILES
1599 * dest dir does exist
1601 memset(to
, 'a', 2 * MAX_PATH
);
1602 memset(to
+MAX_PATH
*2, 0, 2);
1603 lstrcpyA(to
, "threedir");
1604 ptr
= to
+ lstrlenA(to
) + 1;
1605 lstrcpyA(ptr
, "fourdir");
1606 shfo
.pFrom
= "one.txt\0two.txt\0";
1608 shfo
.fFlags
= FOF_MULTIDESTFILES
| FOF_NOCONFIRMATION
|
1609 FOF_SILENT
| FOF_NOERRORUI
;
1610 retval
= SHFileOperation(&shfo
);
1611 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1612 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1613 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1614 ok(DeleteFileA("threedir\\one.txt"), "Expected file to exist\n");
1615 if (dir_exists("fourdir"))
1617 /* Vista and W2K8 (broken or new behavior ?) */
1618 ok(!DeleteFileA("threedir\\two.txt"), "Expected file to not exist\n");
1619 ok(DeleteFileA("fourdir\\two.txt"), "Expected file to exist\n");
1620 RemoveDirectoryA("fourdir");
1624 ok(DeleteFileA("threedir\\two.txt"), "Expected file to exist\n");
1625 ok(!DeleteFileA("fourdir"), "Expected file to not exist\n");
1626 ok(!RemoveDirectoryA("fourdir"), "Expected dir to not exist\n");
1628 ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
1630 createTestFile("one.txt");
1631 createTestFile("two.txt");
1632 CreateDirectoryA("threedir", NULL
);
1634 /* multiple source files, FOF_MULTIDESTFILES
1635 * multiple dest files, but first dest dir exists
1636 * num files in lists is equal
1638 shfo
.pFrom
= "one.txt\0two.txt\0";
1639 shfo
.pTo
= "threedir\0fourdir\0";
1640 shfo
.fFlags
= FOF_MULTIDESTFILES
| FOF_NOCONFIRMATION
|
1641 FOF_SILENT
| FOF_NOERRORUI
;
1642 retval
= SHFileOperation(&shfo
);
1643 ok(retval
== ERROR_CANCELLED
||
1644 retval
== DE_FILEDESTISFLD
|| /* Vista */
1645 broken(retval
== DE_OPCANCELLED
), /* Win9x, NT4 */
1646 "Expected ERROR_CANCELLED or DE_FILEDESTISFLD. got %d\n", retval
);
1647 if (file_exists("threedir\\threedir"))
1650 ok(DeleteFileA("threedir\\threedir"), "Expected file to exist\n");
1652 ok(!DeleteFileA("threedir\\one.txt"), "Expected file to not exist\n");
1653 ok(!DeleteFileA("threedir\\two.txt"), "Expected file to not exist\n");
1654 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1655 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1656 ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
1657 ok(!DeleteFileA("fourdir"), "Expected file to not exist\n");
1658 ok(!RemoveDirectoryA("fourdir"), "Expected dir to not exist\n");
1660 createTestFile("one.txt");
1661 createTestFile("two.txt");
1662 CreateDirectoryA("threedir", NULL
);
1664 /* multiple source files, FOF_MULTIDESTFILES
1665 * multiple dest files, but first dest dir exists
1666 * num files in lists is not equal
1668 shfo
.pFrom
= "one.txt\0two.txt\0";
1669 shfo
.pTo
= "threedir\0fourdir\0five\0";
1670 shfo
.fFlags
= FOF_MULTIDESTFILES
| FOF_NOCONFIRMATION
|
1671 FOF_SILENT
| FOF_NOERRORUI
;
1672 retval
= SHFileOperation(&shfo
);
1673 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1674 ok(DeleteFileA("one.txt"), "Expected file to exist\n");
1675 ok(DeleteFileA("two.txt"), "Expected file to exist\n");
1676 ok(DeleteFileA("threedir\\one.txt"), "Expected file to exist\n");
1677 if (dir_exists("fourdir"))
1679 /* Vista and W2K8 (broken or new behavior ?) */
1680 ok(!DeleteFileA("threedir\\two.txt"), "Expected file to not exist\n");
1681 ok(DeleteFileA("fourdir\\two.txt"), "Expected file to exist\n");
1682 RemoveDirectoryA("fourdir");
1686 ok(DeleteFileA("threedir\\two.txt"), "Expected file to exist\n");
1687 ok(!DeleteFileA("fourdir"), "Expected file to not exist\n");
1688 ok(!RemoveDirectoryA("fourdir"), "Expected dit to not exist\n");
1690 ok(RemoveDirectoryA("threedir"), "Expected dir to exist\n");
1691 ok(!DeleteFileA("five"), "Expected file to not exist\n");
1692 ok(!RemoveDirectoryA("five"), "Expected dit to not exist\n");
1694 createTestFile("aa.txt");
1695 createTestFile("ab.txt");
1696 CreateDirectoryA("one", NULL
);
1697 CreateDirectoryA("two", NULL
);
1699 /* pFrom has a glob, pTo has more than one dest */
1700 shfo
.pFrom
= "a*.txt\0";
1701 shfo
.pTo
= "one\0two\0";
1702 shfo
.fFlags
= FOF_NOCONFIRMATION
| FOF_SILENT
| FOF_NOERRORUI
;
1703 retval
= SHFileOperation(&shfo
);
1704 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1705 ok(DeleteFileA("one\\aa.txt"), "Expected file to exist\n");
1706 ok(DeleteFileA("one\\ab.txt"), "Expected file to exist\n");
1707 ok(!DeleteFileA("two\\aa.txt"), "Expected file to not exist\n");
1708 ok(!DeleteFileA("two\\ab.txt"), "Expected file to not exist\n");
1709 ok(DeleteFileA("aa.txt"), "Expected file to exist\n");
1710 ok(DeleteFileA("ab.txt"), "Expected file to exist\n");
1711 ok(RemoveDirectoryA("one"), "Expected dir to exist\n");
1712 ok(RemoveDirectoryA("two"), "Expected dir to exist\n");
1715 /* tests the FO_MOVE action */
1716 static void test_move(void)
1718 SHFILEOPSTRUCTA shfo
, shfo2
;
1719 CHAR from
[5*MAX_PATH
];
1720 CHAR to
[5*MAX_PATH
];
1724 shfo
.wFunc
= FO_MOVE
;
1727 shfo
.fFlags
= FOF_NOCONFIRMATION
| FOF_SILENT
| FOF_NOERRORUI
;
1728 shfo
.hNameMappings
= NULL
;
1729 shfo
.lpszProgressTitle
= NULL
;
1731 set_curr_dir_path(from
, "test1.txt\0");
1732 set_curr_dir_path(to
, "test4.txt\0");
1733 ok(!SHFileOperationA(&shfo
), "Prepare test to check how directories are moved recursively\n");
1734 ok(!file_exists("test1.txt"), "test1.txt should not exist\n");
1735 ok(file_exists("test4.txt\\test1.txt"), "The file is not moved\n");
1737 set_curr_dir_path(from
, "test?.txt\0");
1738 set_curr_dir_path(to
, "testdir2\0");
1739 ok(!file_exists("testdir2\\test2.txt"), "The file is not moved yet\n");
1740 ok(!file_exists("testdir2\\test4.txt"), "The directory is not moved yet\n");
1741 ok(!SHFileOperationA(&shfo
), "Files and directories are moved to directory\n");
1742 ok(file_exists("testdir2\\test2.txt"), "The file is moved\n");
1743 ok(file_exists("testdir2\\test4.txt"), "The directory is moved\n");
1744 ok(file_exists("testdir2\\test4.txt\\test1.txt"), "The file in subdirectory is moved\n");
1746 clean_after_shfo_tests();
1749 memcpy(&shfo2
, &shfo
, sizeof(SHFILEOPSTRUCTA
));
1750 shfo2
.fFlags
|= FOF_MULTIDESTFILES
;
1752 set_curr_dir_path(from
, "test1.txt\0test2.txt\0test4.txt\0");
1753 set_curr_dir_path(to
, "test6.txt\0test7.txt\0test8.txt\0");
1754 ok(!SHFileOperationA(&shfo2
), "Move many files\n");
1755 ok(DeleteFileA("test6.txt"), "The file is not moved - many files are "
1756 "specified as a target\n");
1757 ok(DeleteFileA("test7.txt"), "The file is not moved\n");
1758 ok(RemoveDirectoryA("test8.txt"), "The directory is not moved\n");
1762 /* number of sources do not correspond to number of targets */
1763 set_curr_dir_path(from
, "test1.txt\0test2.txt\0test4.txt\0");
1764 set_curr_dir_path(to
, "test6.txt\0test7.txt\0");
1765 retval
= SHFileOperationA(&shfo2
);
1766 if (dir_exists("test6.txt"))
1768 /* Vista and W2K8 (broken or new behavior ?) */
1769 ok(retval
== DE_DESTSAMETREE
, "Expected DE_DESTSAMETREE, got %d\n", retval
);
1770 ok(DeleteFileA("test6.txt\\test1.txt"), "The file is not moved\n");
1771 RemoveDirectoryA("test6.txt");
1772 ok(DeleteFileA("test7.txt\\test2.txt"), "The file is not moved\n");
1773 RemoveDirectoryA("test7.txt");
1777 expect_retval(ERROR_CANCELLED
, DE_OPCANCELLED
/* Win9x, NT4 */);
1778 ok(!file_exists("test6.txt"), "The file is not moved - many files are "
1779 "specified as a target\n");
1784 set_curr_dir_path(from
, "test3.txt\0");
1785 set_curr_dir_path(to
, "test4.txt\\test1.txt\0");
1786 ok(!SHFileOperationA(&shfo
), "Can't move file to other directory\n");
1787 ok(file_exists("test4.txt\\test1.txt"), "The file is not moved\n");
1789 set_curr_dir_path(from
, "test1.txt\0test2.txt\0test4.txt\0");
1790 set_curr_dir_path(to
, "test6.txt\0test7.txt\0test8.txt\0");
1791 retval
= SHFileOperationA(&shfo
);
1792 if (dir_exists("test6.txt"))
1794 /* Vista and W2K8 (broken or new behavior ?) */
1795 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1796 ok(DeleteFileA("test6.txt\\test1.txt"), "The file is not moved. Many files are specified\n");
1797 ok(DeleteFileA("test6.txt\\test2.txt"), "The file is not moved. Many files are specified\n");
1798 ok(DeleteFileA("test6.txt\\test4.txt\\test1.txt"), "The file is not moved. Many files are specified\n");
1799 ok(RemoveDirectoryA("test6.txt\\test4.txt"), "The directory is not moved. Many files are specified\n");
1800 RemoveDirectoryA("test6.txt");
1805 expect_retval(ERROR_CANCELLED
, DE_OPCANCELLED
/* Win9x, NT4 */);
1806 ok(file_exists("test1.txt"), "The file is moved. Many files are specified\n");
1807 ok(dir_exists("test4.txt"), "The directory is moved. Many files are specified\n");
1810 set_curr_dir_path(from
, "test1.txt\0");
1811 set_curr_dir_path(to
, "test6.txt\0");
1812 ok(!SHFileOperationA(&shfo
), "Move file failed\n");
1813 ok(!file_exists("test1.txt"), "The file is not moved\n");
1814 ok(file_exists("test6.txt"), "The file is not moved\n");
1815 set_curr_dir_path(from
, "test6.txt\0");
1816 set_curr_dir_path(to
, "test1.txt\0");
1817 ok(!SHFileOperationA(&shfo
), "Move file back failed\n");
1819 set_curr_dir_path(from
, "test4.txt\0");
1820 set_curr_dir_path(to
, "test6.txt\0");
1821 ok(!SHFileOperationA(&shfo
), "Move dir failed\n");
1822 ok(!dir_exists("test4.txt"), "The dir is not moved\n");
1823 ok(dir_exists("test6.txt"), "The dir is moved\n");
1824 set_curr_dir_path(from
, "test6.txt\0");
1825 set_curr_dir_path(to
, "test4.txt\0");
1826 ok(!SHFileOperationA(&shfo
), "Move dir back failed\n");
1828 /* move one file to two others */
1830 shfo
.pFrom
= "test1.txt\0";
1831 shfo
.pTo
= "a.txt\0b.txt\0";
1832 retval
= SHFileOperationA(&shfo
);
1833 if (retval
== DE_OPCANCELLED
)
1835 /* NT4 fails and doesn't move any files */
1836 ok(!file_exists("a.txt"), "Expected a.txt to not exist\n");
1837 DeleteFileA("test1.txt");
1841 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1842 ok(!file_exists("test1.txt"), "Expected test1.txt to not exist\n");
1843 ok(DeleteFile("a.txt"), "Expected a.txt to exist\n");
1845 ok(!file_exists("b.txt"), "Expected b.txt to not exist\n");
1847 /* move two files to one other */
1848 shfo
.pFrom
= "test2.txt\0test3.txt\0";
1849 shfo
.pTo
= "test1.txt\0";
1850 retval
= SHFileOperationA(&shfo
);
1851 if (dir_exists("test1.txt"))
1853 /* Vista and W2K8 (broken or new behavior ?) */
1854 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1855 ok(DeleteFileA("test1.txt\\test2.txt"), "Expected test1.txt\\test2.txt to exist\n");
1856 ok(DeleteFileA("test1.txt\\test3.txt"), "Expected test1.txt\\test3.txt to exist\n");
1857 RemoveDirectoryA("test1.txt");
1858 createTestFile("test2.txt");
1859 createTestFile("test3.txt");
1863 expect_retval(ERROR_CANCELLED
, DE_OPCANCELLED
/* Win9x, NT4 */);
1864 ok(!file_exists("test1.txt"), "Expected test1.txt to not exist\n");
1865 ok(file_exists("test2.txt"), "Expected test2.txt to exist\n");
1866 ok(file_exists("test3.txt"), "Expected test3.txt to exist\n");
1869 /* move a directory into itself */
1870 shfo
.pFrom
= "test4.txt\0";
1871 shfo
.pTo
= "test4.txt\\b.txt\0";
1872 retval
= SHFileOperationA(&shfo
);
1873 ok(retval
== ERROR_SUCCESS
||
1874 retval
== DE_DESTSUBTREE
, /* Vista */
1875 "Expected ERROR_SUCCESS or DE_DESTSUBTREE, got %d\n", retval
);
1876 ok(!RemoveDirectory("test4.txt\\b.txt"), "Expected test4.txt\\b.txt to not exist\n");
1877 ok(dir_exists("test4.txt"), "Expected test4.txt to exist\n");
1879 /* move many files without FOF_MULTIDESTFILES */
1880 shfo
.pFrom
= "test2.txt\0test3.txt\0";
1881 shfo
.pTo
= "d.txt\0e.txt\0";
1882 retval
= SHFileOperationA(&shfo
);
1883 if (dir_exists("d.txt"))
1885 /* Vista and W2K8 (broken or new behavior ?) */
1886 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1887 ok(DeleteFileA("d.txt\\test2.txt"), "Expected d.txt\\test2.txt to exist\n");
1888 ok(DeleteFileA("d.txt\\test3.txt"), "Expected d.txt\\test3.txt to exist\n");
1889 RemoveDirectoryA("d.txt");
1890 createTestFile("test2.txt");
1891 createTestFile("test3.txt");
1895 expect_retval(ERROR_CANCELLED
, DE_OPCANCELLED
/* Win9x, NT4 */);
1896 ok(!DeleteFile("d.txt"), "Expected d.txt to not exist\n");
1897 ok(!DeleteFile("e.txt"), "Expected e.txt to not exist\n");
1900 /* number of sources != number of targets */
1901 shfo
.pTo
= "d.txt\0";
1902 shfo
.fFlags
|= FOF_MULTIDESTFILES
;
1903 retval
= SHFileOperationA(&shfo
);
1904 if (dir_exists("d.txt"))
1906 /* Vista and W2K8 (broken or new behavior ?) */
1907 ok(retval
== DE_SAMEFILE
,
1908 "Expected DE_SAMEFILE, got %d\n", retval
);
1909 ok(DeleteFileA("d.txt\\test2.txt"), "Expected d.txt\\test2.txt to exist\n");
1910 ok(!file_exists("d.txt\\test3.txt"), "Expected d.txt\\test3.txt to not exist\n");
1911 RemoveDirectoryA("d.txt");
1912 createTestFile("test2.txt");
1916 expect_retval(ERROR_CANCELLED
, DE_OPCANCELLED
/* Win9x, NT4 */);
1917 ok(!DeleteFile("d.txt"), "Expected d.txt to not exist\n");
1920 /* FO_MOVE does not create dest directories */
1921 shfo
.pFrom
= "test2.txt\0";
1922 shfo
.pTo
= "dir1\\dir2\\test2.txt\0";
1923 retval
= SHFileOperationA(&shfo
);
1924 if (dir_exists("dir1"))
1926 /* Vista and W2K8 (broken or new behavior ?) */
1927 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1928 ok(DeleteFileA("dir1\\dir2\\test2.txt"), "Expected dir1\\dir2\\test2.txt to exist\n");
1929 RemoveDirectoryA("dir1\\dir2");
1930 RemoveDirectoryA("dir1");
1931 createTestFile("test2.txt");
1935 expect_retval(ERROR_CANCELLED
, DE_OPCANCELLED
/* Win9x, NT4 */);
1938 /* try to overwrite an existing file */
1939 shfo
.pTo
= "test3.txt\0";
1940 retval
= SHFileOperationA(&shfo
);
1941 if (retval
== DE_OPCANCELLED
)
1943 /* NT4 fails and doesn't move any files */
1944 ok(file_exists("test2.txt"), "Expected test2.txt to exist\n");
1948 ok(retval
== ERROR_SUCCESS
, "Expected ERROR_SUCCESS, got %d\n", retval
);
1949 ok(!file_exists("test2.txt"), "Expected test2.txt to not exist\n");
1950 ok(file_exists("test3.txt"), "Expected test3.txt to exist\n");
1954 static void test_sh_create_dir(void)
1956 CHAR path
[MAX_PATH
];
1959 if(!pSHCreateDirectoryExA
)
1961 win_skip("skipping SHCreateDirectoryExA tests\n");
1965 set_curr_dir_path(path
, "testdir2\\test4.txt\0");
1966 ret
= pSHCreateDirectoryExA(NULL
, path
, NULL
);
1967 ok(ERROR_SUCCESS
== ret
, "SHCreateDirectoryEx failed to create directory recursively, ret = %d\n", ret
);
1968 ok(file_exists("testdir2"), "The first directory is not created\n");
1969 ok(file_exists("testdir2\\test4.txt"), "The second directory is not created\n");
1971 ret
= pSHCreateDirectoryExA(NULL
, path
, NULL
);
1972 ok(ERROR_ALREADY_EXISTS
== ret
, "SHCreateDirectoryEx should fail to create existing directory, ret = %d\n", ret
);
1974 ret
= pSHCreateDirectoryExA(NULL
, "c:\\testdir3", NULL
);
1975 ok(file_exists("c:\\testdir3"), "The directory is not created\n");
1978 static void test_sh_path_prepare(void)
1981 CHAR path
[MAX_PATH
];
1982 CHAR UNICODE_PATH_A
[MAX_PATH
];
1984 if(!pSHPathPrepareForWriteA
)
1986 win_skip("skipping SHPathPrepareForWriteA tests\n");
1990 /* directory exists, SHPPFW_NONE */
1991 set_curr_dir_path(path
, "testdir2\0");
1992 res
= pSHPathPrepareForWriteA(0, 0, path
, SHPPFW_NONE
);
1993 ok(res
== S_OK
, "res == 0x%08x, expected S_OK\n", res
);
1995 /* directory exists, SHPPFW_IGNOREFILENAME */
1996 set_curr_dir_path(path
, "testdir2\\test4.txt\0");
1997 res
= pSHPathPrepareForWriteA(0, 0, path
, SHPPFW_IGNOREFILENAME
);
1998 ok(res
== S_OK
, "res == 0x%08x, expected S_OK\n", res
);
2000 /* directory exists, SHPPFW_DIRCREATE */
2001 set_curr_dir_path(path
, "testdir2\0");
2002 res
= pSHPathPrepareForWriteA(0, 0, path
, SHPPFW_DIRCREATE
);
2003 ok(res
== S_OK
, "res == 0x%08x, expected S_OK\n", res
);
2005 /* directory exists, SHPPFW_IGNOREFILENAME|SHPPFW_DIRCREATE */
2006 set_curr_dir_path(path
, "testdir2\\test4.txt\0");
2007 res
= pSHPathPrepareForWriteA(0, 0, path
, SHPPFW_IGNOREFILENAME
|SHPPFW_DIRCREATE
);
2008 ok(res
== S_OK
, "res == 0x%08x, expected S_OK\n", res
);
2009 ok(!file_exists("nonexistent\\"), "nonexistent\\ exists but shouldn't\n");
2011 /* file exists, SHPPFW_NONE */
2012 set_curr_dir_path(path
, "test1.txt\0");
2013 res
= pSHPathPrepareForWriteA(0, 0, path
, SHPPFW_NONE
);
2014 ok(res
== HRESULT_FROM_WIN32(ERROR_DIRECTORY
) ||
2015 res
== HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
) || /* WinMe */
2016 res
== HRESULT_FROM_WIN32(ERROR_INVALID_NAME
), /* Vista */
2017 "Unexpected result : 0x%08x\n", res
);
2019 /* file exists, SHPPFW_DIRCREATE */
2020 res
= pSHPathPrepareForWriteA(0, 0, path
, SHPPFW_DIRCREATE
);
2021 ok(res
== HRESULT_FROM_WIN32(ERROR_DIRECTORY
) ||
2022 res
== HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
) || /* WinMe */
2023 res
== HRESULT_FROM_WIN32(ERROR_INVALID_NAME
), /* Vista */
2024 "Unexpected result : 0x%08x\n", res
);
2026 /* file exists, SHPPFW_NONE, trailing \ */
2027 set_curr_dir_path(path
, "test1.txt\\\0");
2028 res
= pSHPathPrepareForWriteA(0, 0, path
, SHPPFW_NONE
);
2029 ok(res
== HRESULT_FROM_WIN32(ERROR_DIRECTORY
) ||
2030 res
== HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
) || /* WinMe */
2031 res
== HRESULT_FROM_WIN32(ERROR_INVALID_NAME
), /* Vista */
2032 "Unexpected result : 0x%08x\n", res
);
2034 /* relative path exists, SHPPFW_DIRCREATE */
2035 res
= pSHPathPrepareForWriteA(0, 0, ".\\testdir2", SHPPFW_DIRCREATE
);
2036 ok(res
== S_OK
, "res == 0x%08x, expected S_OK\n", res
);
2038 /* relative path doesn't exist, SHPPFW_DIRCREATE -- Windows does not create the directory in this case */
2039 res
= pSHPathPrepareForWriteA(0, 0, ".\\testdir2\\test4.txt", SHPPFW_DIRCREATE
);
2040 ok(res
== HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)\n", res
);
2041 ok(!file_exists(".\\testdir2\\test4.txt\\"), ".\\testdir2\\test4.txt\\ exists but shouldn't\n");
2043 /* directory doesn't exist, SHPPFW_NONE */
2044 set_curr_dir_path(path
, "nonexistent\0");
2045 res
= pSHPathPrepareForWriteA(0, 0, path
, SHPPFW_NONE
);
2046 ok(res
== HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)\n", res
);
2048 /* directory doesn't exist, SHPPFW_IGNOREFILENAME */
2049 set_curr_dir_path(path
, "nonexistent\\notreal\0");
2050 res
= pSHPathPrepareForWriteA(0, 0, path
, SHPPFW_IGNOREFILENAME
);
2051 ok(res
== HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
), "res == 0x%08x, expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)\n", res
);
2052 ok(!file_exists("nonexistent\\notreal"), "nonexistent\\notreal exists but shouldn't\n");
2053 ok(!file_exists("nonexistent\\"), "nonexistent\\ exists but shouldn't\n");
2055 /* directory doesn't exist, SHPPFW_IGNOREFILENAME|SHPPFW_DIRCREATE */
2056 set_curr_dir_path(path
, "testdir2\\test4.txt\\\0");
2057 res
= pSHPathPrepareForWriteA(0, 0, path
, SHPPFW_IGNOREFILENAME
|SHPPFW_DIRCREATE
);
2058 ok(res
== S_OK
, "res == 0x%08x, expected S_OK\n", res
);
2059 ok(file_exists("testdir2\\test4.txt\\"), "testdir2\\test4.txt doesn't exist but should\n");
2061 /* nested directory doesn't exist, SHPPFW_DIRCREATE */
2062 set_curr_dir_path(path
, "nonexistent\\notreal\0");
2063 res
= pSHPathPrepareForWriteA(0, 0, path
, SHPPFW_DIRCREATE
);
2064 ok(res
== S_OK
, "res == 0x%08x, expected S_OK\n", res
);
2065 ok(file_exists("nonexistent\\notreal"), "nonexistent\\notreal doesn't exist but should\n");
2067 /* SHPPFW_ASKDIRCREATE, SHPPFW_NOWRITECHECK, and SHPPFW_MEDIACHECKONLY are untested */
2069 if(!pSHPathPrepareForWriteW
)
2071 win_skip("Skipping SHPathPrepareForWriteW tests\n");
2074 WideCharToMultiByte(CP_ACP
, 0, UNICODE_PATH
, -1, UNICODE_PATH_A
, sizeof(UNICODE_PATH_A
), NULL
, NULL
);
2076 /* unicode directory doesn't exist, SHPPFW_NONE */
2077 RemoveDirectoryA(UNICODE_PATH_A
);
2078 res
= pSHPathPrepareForWriteW(0, 0, UNICODE_PATH
, SHPPFW_NONE
);
2079 ok(res
== HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND
), "res == %08x, expected HRESULT_FROM_WIN32(ERROR_PATH_NOT_FOUND)\n", res
);
2080 ok(!file_exists(UNICODE_PATH_A
), "unicode path was created but shouldn't be\n");
2081 RemoveDirectoryA(UNICODE_PATH_A
);
2083 /* unicode directory doesn't exist, SHPPFW_DIRCREATE */
2084 res
= pSHPathPrepareForWriteW(0, 0, UNICODE_PATH
, SHPPFW_DIRCREATE
);
2085 ok(res
== S_OK
, "res == %08x, expected S_OK\n", res
);
2086 ok(file_exists(UNICODE_PATH_A
), "unicode path should've been created\n");
2088 /* unicode directory exists, SHPPFW_NONE */
2089 res
= pSHPathPrepareForWriteW(0, 0, UNICODE_PATH
, SHPPFW_NONE
);
2090 ok(res
== S_OK
, "ret == %08x, expected S_OK\n", res
);
2092 /* unicode directory exists, SHPPFW_DIRCREATE */
2093 res
= pSHPathPrepareForWriteW(0, 0, UNICODE_PATH
, SHPPFW_DIRCREATE
);
2094 ok(res
== S_OK
, "ret == %08x, expected S_OK\n", res
);
2095 RemoveDirectoryA(UNICODE_PATH_A
);
2098 static void test_sh_new_link_info(void)
2100 BOOL ret
, mustcopy
=TRUE
;
2101 CHAR linkto
[MAX_PATH
];
2102 CHAR destdir
[MAX_PATH
];
2103 CHAR result
[MAX_PATH
];
2104 CHAR result2
[MAX_PATH
];
2106 /* source file does not exist */
2107 set_curr_dir_path(linkto
, "nosuchfile.txt\0");
2108 set_curr_dir_path(destdir
, "testdir2\0");
2109 ret
= SHGetNewLinkInfoA(linkto
, destdir
, result
, &mustcopy
, 0);
2111 broken(ret
== lstrlenA(result
) + 1), /* NT4 */
2112 "SHGetNewLinkInfoA succeeded\n");
2113 ok(mustcopy
== FALSE
, "mustcopy should be FALSE\n");
2115 /* dest dir does not exist */
2116 set_curr_dir_path(linkto
, "test1.txt\0");
2117 set_curr_dir_path(destdir
, "nosuchdir\0");
2118 ret
= SHGetNewLinkInfoA(linkto
, destdir
, result
, &mustcopy
, 0);
2120 broken(ret
== lstrlenA(result
) + 1), /* NT4 */
2121 "SHGetNewLinkInfoA failed, err=%i\n", GetLastError());
2122 ok(mustcopy
== FALSE
, "mustcopy should be FALSE\n");
2124 /* source file exists */
2125 set_curr_dir_path(linkto
, "test1.txt\0");
2126 set_curr_dir_path(destdir
, "testdir2\0");
2127 ret
= SHGetNewLinkInfoA(linkto
, destdir
, result
, &mustcopy
, 0);
2129 broken(ret
== lstrlenA(result
) + 1), /* NT4 */
2130 "SHGetNewLinkInfoA failed, err=%i\n", GetLastError());
2131 ok(mustcopy
== FALSE
, "mustcopy should be FALSE\n");
2132 ok(CompareStringA(LOCALE_SYSTEM_DEFAULT
, NORM_IGNORECASE
, destdir
,
2133 lstrlenA(destdir
), result
, lstrlenA(destdir
)) == CSTR_EQUAL
,
2134 "%s does not start with %s\n", result
, destdir
);
2135 ok(lstrlenA(result
) > 4 && lstrcmpiA(result
+lstrlenA(result
)-4, ".lnk") == 0,
2136 "%s does not end with .lnk\n", result
);
2138 /* preferred target name already exists */
2139 createTestFile(result
);
2140 ret
= SHGetNewLinkInfoA(linkto
, destdir
, result2
, &mustcopy
, 0);
2142 broken(ret
== lstrlenA(result2
) + 1), /* NT4 */
2143 "SHGetNewLinkInfoA failed, err=%i\n", GetLastError());
2144 ok(mustcopy
== FALSE
, "mustcopy should be FALSE\n");
2145 ok(CompareStringA(LOCALE_SYSTEM_DEFAULT
, NORM_IGNORECASE
, destdir
,
2146 lstrlenA(destdir
), result2
, lstrlenA(destdir
)) == CSTR_EQUAL
,
2147 "%s does not start with %s\n", result2
, destdir
);
2148 ok(lstrlenA(result2
) > 4 && lstrcmpiA(result2
+lstrlenA(result2
)-4, ".lnk") == 0,
2149 "%s does not end with .lnk\n", result2
);
2150 ok(lstrcmpiA(result
, result2
) != 0, "%s and %s are the same\n", result
, result2
);
2151 DeleteFileA(result
);
2154 static void test_unicode(void)
2156 SHFILEOPSTRUCTW shfoW
;
2160 if (!pSHFileOperationW
)
2162 skip("SHFileOperationW() is missing\n");
2167 shfoW
.wFunc
= FO_DELETE
;
2168 shfoW
.pFrom
= UNICODE_PATH
;
2170 shfoW
.fFlags
= FOF_NOCONFIRMATION
| FOF_SILENT
| FOF_NOERRORUI
;
2171 shfoW
.hNameMappings
= NULL
;
2172 shfoW
.lpszProgressTitle
= NULL
;
2174 /* Clean up before start test */
2175 DeleteFileW(UNICODE_PATH
);
2176 RemoveDirectoryW(UNICODE_PATH
);
2178 /* Make sure we are on a system that supports unicode */
2179 SetLastError(0xdeadbeef);
2180 file
= CreateFileW(UNICODE_PATH
, GENERIC_WRITE
, 0, NULL
, CREATE_ALWAYS
, 0, NULL
);
2181 if (GetLastError()==ERROR_CALL_NOT_IMPLEMENTED
)
2183 skip("Unicode tests skipped on non-unicode system\n");
2188 /* Try to delete a file with unicode filename */
2189 ok(file_existsW(UNICODE_PATH
), "The file does not exist\n");
2190 ret
= pSHFileOperationW(&shfoW
);
2191 ok(!ret
, "File is not removed, ErrorCode: %d\n", ret
);
2192 ok(!file_existsW(UNICODE_PATH
), "The file should have been removed\n");
2194 /* Try to trash a file with unicode filename */
2195 createTestFileW(UNICODE_PATH
);
2196 shfoW
.fFlags
|= FOF_ALLOWUNDO
;
2197 ok(file_existsW(UNICODE_PATH
), "The file does not exist\n");
2198 ret
= pSHFileOperationW(&shfoW
);
2199 ok(!ret
, "File is not removed, ErrorCode: %d\n", ret
);
2200 ok(!file_existsW(UNICODE_PATH
), "The file should have been removed\n");
2202 if(!pSHCreateDirectoryExW
)
2204 skip("Skipping SHCreateDirectoryExW tests\n");
2208 /* Try to delete a directory with unicode filename */
2209 ret
= pSHCreateDirectoryExW(NULL
, UNICODE_PATH
, NULL
);
2210 ok(!ret
, "SHCreateDirectoryExW returned %d\n", ret
);
2211 ok(file_existsW(UNICODE_PATH
), "The directory is not created\n");
2212 shfoW
.fFlags
&= ~FOF_ALLOWUNDO
;
2213 ret
= pSHFileOperationW(&shfoW
);
2214 ok(!ret
, "Directory is not removed, ErrorCode: %d\n", ret
);
2215 ok(!file_existsW(UNICODE_PATH
), "The directory should have been removed\n");
2217 /* Try to trash a directory with unicode filename */
2218 ret
= pSHCreateDirectoryExW(NULL
, UNICODE_PATH
, NULL
);
2219 ok(!ret
, "SHCreateDirectoryExW returned %d\n", ret
);
2220 ok(file_existsW(UNICODE_PATH
), "The directory was not created\n");
2221 shfoW
.fFlags
|= FOF_ALLOWUNDO
;
2222 ret
= pSHFileOperationW(&shfoW
);
2223 ok(!ret
, "Directory is not removed, ErrorCode: %d\n", ret
);
2224 ok(!file_existsW(UNICODE_PATH
), "The directory should have been removed\n");
2227 START_TEST(shlfileop
)
2229 InitFunctionPointers();
2231 clean_after_shfo_tests();
2234 test_get_file_info();
2235 test_get_file_info_iconlist();
2236 clean_after_shfo_tests();
2240 clean_after_shfo_tests();
2244 clean_after_shfo_tests();
2248 clean_after_shfo_tests();
2252 clean_after_shfo_tests();
2254 test_sh_create_dir();
2255 clean_after_shfo_tests();
2258 test_sh_path_prepare();
2259 clean_after_shfo_tests();
2262 test_sh_new_link_info();
2263 clean_after_shfo_tests();