3 * Copyright 2012 Alistair Leslie-Hughes
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
29 #include "wine/test.h"
34 static IFileSystem3
*fs3
;
36 static void test_interfaces(void)
38 static const WCHAR nonexistent_dirW
[] = {
39 'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', 0};
40 static const WCHAR pathW
[] = {'p','a','t','h',0};
41 static const WCHAR file_kernel32W
[] = {
42 '\\', 'k', 'e', 'r', 'n', 'e', 'l', '3', '2', '.', 'd', 'l', 'l', 0};
46 IObjectWithSite
*site
;
49 WCHAR windows_path
[MAX_PATH
];
50 WCHAR file_path
[MAX_PATH
];
52 IFileSystem3_QueryInterface(fs3
, &IID_IDispatch
, (void**)&disp
);
54 GetSystemDirectoryW(windows_path
, MAX_PATH
);
55 lstrcpyW(file_path
, windows_path
);
56 lstrcatW(file_path
, file_kernel32W
);
58 hr
= IDispatch_QueryInterface(disp
, &IID_IObjectWithSite
, (void**)&site
);
59 ok(hr
== E_NOINTERFACE
, "got 0x%08x, expected 0x%08x\n", hr
, E_NOINTERFACE
);
61 hr
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
62 ok(hr
== E_NOINTERFACE
, "got 0x%08x, expected 0x%08x\n", hr
, E_NOINTERFACE
);
65 hr
= IFileSystem3_FileExists(fs3
, NULL
, &b
);
66 ok(hr
== S_OK
, "got 0x%08x, expected 0x%08x\n", hr
, S_OK
);
67 ok(b
== VARIANT_FALSE
, "got %x\n", b
);
69 hr
= IFileSystem3_FileExists(fs3
, NULL
, NULL
);
70 ok(hr
== E_POINTER
, "got 0x%08x, expected 0x%08x\n", hr
, E_POINTER
);
72 path
= SysAllocString(pathW
);
74 hr
= IFileSystem3_FileExists(fs3
, path
, &b
);
75 ok(hr
== S_OK
, "got 0x%08x, expected 0x%08x\n", hr
, S_OK
);
76 ok(b
== VARIANT_FALSE
, "got %x\n", b
);
79 path
= SysAllocString(file_path
);
81 hr
= IFileSystem3_FileExists(fs3
, path
, &b
);
82 ok(hr
== S_OK
, "got 0x%08x, expected 0x%08x\n", hr
, S_OK
);
83 ok(b
== VARIANT_TRUE
, "got %x\n", b
);
86 path
= SysAllocString(windows_path
);
88 hr
= IFileSystem3_FileExists(fs3
, path
, &b
);
89 ok(hr
== S_OK
, "got 0x%08x, expected 0x%08x\n", hr
, S_OK
);
90 ok(b
== VARIANT_FALSE
, "got %x\n", b
);
94 hr
= IFileSystem3_FolderExists(fs3
, NULL
, NULL
);
95 ok(hr
== E_POINTER
, "got 0x%08x, expected 0x%08x\n", hr
, E_POINTER
);
97 path
= SysAllocString(windows_path
);
98 hr
= IFileSystem3_FolderExists(fs3
, path
, &b
);
99 ok(hr
== S_OK
, "got 0x%08x, expected 0x%08x\n", hr
, S_OK
);
100 ok(b
== VARIANT_TRUE
, "Folder doesn't exists\n");
103 path
= SysAllocString(nonexistent_dirW
);
104 hr
= IFileSystem3_FolderExists(fs3
, path
, &b
);
105 ok(hr
== S_OK
, "got 0x%08x, expected 0x%08x\n", hr
, S_OK
);
106 ok(b
== VARIANT_FALSE
, "Folder exists\n");
109 path
= SysAllocString(file_path
);
110 hr
= IFileSystem3_FolderExists(fs3
, path
, &b
);
111 ok(hr
== S_OK
, "got 0x%08x, expected 0x%08x\n", hr
, S_OK
);
112 ok(b
== VARIANT_FALSE
, "Folder exists\n");
115 IDispatch_Release(disp
);
118 static void test_createfolder(void)
121 WCHAR pathW
[MAX_PATH
];
125 /* create existing directory */
126 GetCurrentDirectoryW(sizeof(pathW
)/sizeof(WCHAR
), pathW
);
127 path
= SysAllocString(pathW
);
128 folder
= (void*)0xdeabeef;
129 hr
= IFileSystem3_CreateFolder(fs3
, path
, &folder
);
130 ok(hr
== CTL_E_FILEALREADYEXISTS
, "got 0x%08x\n", hr
);
131 ok(folder
== NULL
, "got %p\n", folder
);
135 static void test_textstream(void)
137 static WCHAR testfileW
[] = {'t','e','s','t','f','i','l','e','.','t','x','t',0};
144 file
= CreateFileW(testfileW
, GENERIC_READ
, 0, NULL
, CREATE_ALWAYS
, FILE_ATTRIBUTE_NORMAL
, NULL
);
147 name
= SysAllocString(testfileW
);
149 hr
= IFileSystem3_FileExists(fs3
, name
, &b
);
150 ok(hr
== S_OK
, "got 0x%08x, expected 0x%08x\n", hr
, S_OK
);
151 ok(b
== VARIANT_TRUE
, "got %x\n", b
);
153 hr
= IFileSystem3_OpenTextFile(fs3
, name
, ForReading
, VARIANT_FALSE
, TristateFalse
, &stream
);
154 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
157 hr
= ITextStream_get_AtEndOfStream(stream
, &b
);
159 ok(hr
== S_FALSE
|| broken(hr
== S_OK
), "got 0x%08x\n", hr
);
160 ok(b
== VARIANT_TRUE
, "got 0x%x\n", b
);
162 ITextStream_Release(stream
);
164 hr
= IFileSystem3_OpenTextFile(fs3
, name
, ForWriting
, VARIANT_FALSE
, TristateFalse
, &stream
);
165 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
168 hr
= ITextStream_get_AtEndOfStream(stream
, &b
);
170 ok(hr
== CTL_E_BADFILEMODE
, "got 0x%08x\n", hr
);
171 ok(b
== VARIANT_TRUE
|| broken(b
== 10), "got 0x%x\n", b
);
174 hr
= ITextStream_get_AtEndOfLine(stream
, &b
);
176 ok(hr
== CTL_E_BADFILEMODE
, "got 0x%08x\n", hr
);
177 ok(b
== VARIANT_FALSE
|| broken(b
== 10), "got 0x%x\n", b
);
179 hr
= ITextStream_Read(stream
, 1, &data
);
180 ok(hr
== CTL_E_BADFILEMODE
, "got 0x%08x\n", hr
);
182 hr
= ITextStream_ReadLine(stream
, &data
);
183 ok(hr
== CTL_E_BADFILEMODE
, "got 0x%08x\n", hr
);
185 hr
= ITextStream_ReadAll(stream
, &data
);
186 ok(hr
== CTL_E_BADFILEMODE
, "got 0x%08x\n", hr
);
188 ITextStream_Release(stream
);
190 hr
= IFileSystem3_OpenTextFile(fs3
, name
, ForAppending
, VARIANT_FALSE
, TristateFalse
, &stream
);
191 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
195 hr
= ITextStream_get_AtEndOfStream(stream
, &b
);
197 ok(hr
== CTL_E_BADFILEMODE
, "got 0x%08x\n", hr
);
198 ok(b
== VARIANT_TRUE
|| broken(b
== 10), "got 0x%x\n", b
);
201 hr
= ITextStream_get_AtEndOfLine(stream
, &b
);
203 ok(hr
== CTL_E_BADFILEMODE
, "got 0x%08x\n", hr
);
204 ok(b
== VARIANT_FALSE
|| broken(b
== 10), "got 0x%x\n", b
);
206 hr
= ITextStream_Read(stream
, 1, &data
);
207 ok(hr
== CTL_E_BADFILEMODE
, "got 0x%08x\n", hr
);
209 hr
= ITextStream_ReadLine(stream
, &data
);
210 ok(hr
== CTL_E_BADFILEMODE
, "got 0x%08x\n", hr
);
212 hr
= ITextStream_ReadAll(stream
, &data
);
213 ok(hr
== CTL_E_BADFILEMODE
, "got 0x%08x\n", hr
);
215 ITextStream_Release(stream
);
217 DeleteFileW(testfileW
);
220 static void test_GetFileVersion(void)
222 static const WCHAR k32W
[] = {'\\','k','e','r','n','e','l','3','2','.','d','l','l',0};
223 static const WCHAR k33W
[] = {'\\','k','e','r','n','e','l','3','3','.','d','l','l',0};
224 WCHAR pathW
[MAX_PATH
], filenameW
[MAX_PATH
];
228 GetSystemDirectoryW(pathW
, sizeof(pathW
)/sizeof(WCHAR
));
230 lstrcpyW(filenameW
, pathW
);
231 lstrcatW(filenameW
, k32W
);
233 path
= SysAllocString(filenameW
);
234 hr
= IFileSystem3_GetFileVersion(fs3
, path
, &version
);
235 ok(hr
== S_OK
, "got 0x%08x\n", hr
);
236 ok(*version
!= 0, "got %s\n", wine_dbgstr_w(version
));
237 SysFreeString(version
);
240 lstrcpyW(filenameW
, pathW
);
241 lstrcatW(filenameW
, k33W
);
243 path
= SysAllocString(filenameW
);
244 version
= (void*)0xdeadbeef;
245 hr
= IFileSystem3_GetFileVersion(fs3
, path
, &version
);
246 ok(broken(hr
== S_OK
) || hr
== HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND
), "got 0x%08x\n", hr
);
249 ok(*version
== 0, "got %s\n", wine_dbgstr_w(version
));
250 SysFreeString(version
);
253 ok(version
== (void*)0xdeadbeef, "got %p\n", version
);
257 static void test_GetParentFolderName(void)
259 static const WCHAR path1
[] = {'a',0};
260 static const WCHAR path2
[] = {'a','/','a','/','a',0};
261 static const WCHAR path3
[] = {'a','\\','a','\\','a',0};
262 static const WCHAR path4
[] = {'a','/','a','/','/','\\','\\',0};
263 static const WCHAR path5
[] = {'c',':','\\','\\','a',0};
264 static const WCHAR path6
[] = {'a','c',':','\\','a',0};
265 static const WCHAR result2
[] = {'a','/','a',0};
266 static const WCHAR result3
[] = {'a','\\','a',0};
267 static const WCHAR result4
[] = {'a',0};
268 static const WCHAR result5
[] = {'c',':','\\',0};
269 static const WCHAR result6
[] = {'a','c',':',0};
271 static const struct {
288 hr
= IFileSystem3_GetParentFolderName(fs3
, NULL
, NULL
);
289 ok(hr
== E_POINTER
, "GetParentFolderName returned %x, expected E_POINTER\n", hr
);
291 for(i
=0; i
<sizeof(tests
)/sizeof(tests
[0]); i
++) {
292 result
= (BSTR
)0xdeadbeef;
293 path
= tests
[i
].path
? SysAllocString(tests
[i
].path
) : NULL
;
294 hr
= IFileSystem3_GetParentFolderName(fs3
, path
, &result
);
295 ok(hr
== S_OK
, "%d) GetParentFolderName returned %x, expected S_OK\n", i
, hr
);
297 ok(!result
, "%d) result = %s\n", i
, wine_dbgstr_w(result
));
299 ok(!lstrcmpW(result
, tests
[i
].result
), "%d) result = %s\n", i
, wine_dbgstr_w(result
));
301 SysFreeString(result
);
305 static void test_GetFileName(void)
307 static const WCHAR path1
[] = {'a',0};
308 static const WCHAR path2
[] = {'a','/','a','.','b',0};
309 static const WCHAR path3
[] = {'a','\\',0};
310 static const WCHAR path4
[] = {'c',':',0};
311 static const WCHAR path5
[] = {'/','\\',0};
312 static const WCHAR result2
[] = {'a','.','b',0};
313 static const WCHAR result3
[] = {'a',0};
315 static const struct {
331 hr
= IFileSystem3_GetFileName(fs3
, NULL
, NULL
);
332 ok(hr
== E_POINTER
, "GetFileName returned %x, expected E_POINTER\n", hr
);
334 for(i
=0; i
<sizeof(tests
)/sizeof(tests
[0]); i
++) {
335 result
= (BSTR
)0xdeadbeef;
336 path
= tests
[i
].path
? SysAllocString(tests
[i
].path
) : NULL
;
337 hr
= IFileSystem3_GetFileName(fs3
, path
, &result
);
338 ok(hr
== S_OK
, "%d) GetFileName returned %x, expected S_OK\n", i
, hr
);
340 ok(!result
, "%d) result = %s\n", i
, wine_dbgstr_w(result
));
342 ok(!lstrcmpW(result
, tests
[i
].result
), "%d) result = %s\n", i
, wine_dbgstr_w(result
));
344 SysFreeString(result
);
348 static void test_GetBaseName(void)
350 static const WCHAR path1
[] = {'a',0};
351 static const WCHAR path2
[] = {'a','/','a','.','b','.','c',0};
352 static const WCHAR path3
[] = {'a','.','b','\\',0};
353 static const WCHAR path4
[] = {'c',':',0};
354 static const WCHAR path5
[] = {'/','\\',0};
355 static const WCHAR path6
[] = {'.','a',0};
356 static const WCHAR result1
[] = {'a',0};
357 static const WCHAR result2
[] = {'a','.','b',0};
358 static const WCHAR result6
[] = {0};
360 static const struct {
377 hr
= IFileSystem3_GetBaseName(fs3
, NULL
, NULL
);
378 ok(hr
== E_POINTER
, "GetBaseName returned %x, expected E_POINTER\n", hr
);
380 for(i
=0; i
<sizeof(tests
)/sizeof(tests
[0]); i
++) {
381 result
= (BSTR
)0xdeadbeef;
382 path
= tests
[i
].path
? SysAllocString(tests
[i
].path
) : NULL
;
383 hr
= IFileSystem3_GetBaseName(fs3
, path
, &result
);
384 ok(hr
== S_OK
, "%d) GetBaseName returned %x, expected S_OK\n", i
, hr
);
386 ok(!result
, "%d) result = %s\n", i
, wine_dbgstr_w(result
));
388 ok(!lstrcmpW(result
, tests
[i
].result
), "%d) result = %s\n", i
, wine_dbgstr_w(result
));
390 SysFreeString(result
);
394 static void test_GetAbsolutePathName(void)
396 static const WCHAR dir1
[] = {'t','e','s','t','_','d','i','r','1',0};
397 static const WCHAR dir2
[] = {'t','e','s','t','_','d','i','r','2',0};
398 static const WCHAR dir_match1
[] = {'t','e','s','t','_','d','i','r','*',0};
399 static const WCHAR dir_match2
[] = {'t','e','s','t','_','d','i','*',0};
400 static const WCHAR cur_dir
[] = {'.',0};
402 WIN32_FIND_DATAW fdata
;
404 WCHAR buf
[MAX_PATH
], buf2
[MAX_PATH
];
408 hr
= IFileSystem3_GetAbsolutePathName(fs3
, NULL
, NULL
);
409 ok(hr
== E_POINTER
, "GetAbsolutePathName returned %x, expected E_POINTER\n", hr
);
411 hr
= IFileSystem3_GetAbsolutePathName(fs3
, NULL
, &result
);
412 ok(hr
== S_OK
, "GetAbsolutePathName returned %x, expected S_OK\n", hr
);
413 GetFullPathNameW(cur_dir
, MAX_PATH
, buf
, NULL
);
414 ok(!lstrcmpW(buf
, result
), "result = %s, expected %s\n", wine_dbgstr_w(result
), wine_dbgstr_w(buf
));
415 SysFreeString(result
);
417 find
= FindFirstFileW(dir_match2
, &fdata
);
418 if(find
!= INVALID_HANDLE_VALUE
) {
419 skip("GetAbsolutePathName tests\n");
424 path
= SysAllocString(dir_match1
);
425 hr
= IFileSystem3_GetAbsolutePathName(fs3
, path
, &result
);
426 ok(hr
== S_OK
, "GetAbsolutePathName returned %x, expected S_OK\n", hr
);
427 GetFullPathNameW(dir_match1
, MAX_PATH
, buf2
, NULL
);
428 ok(!lstrcmpW(buf2
, result
), "result = %s, expected %s\n", wine_dbgstr_w(result
), wine_dbgstr_w(buf2
));
429 SysFreeString(result
);
431 ok(CreateDirectoryW(dir1
, NULL
), "CreateDirectory(%s) failed\n", wine_dbgstr_w(dir1
));
432 hr
= IFileSystem3_GetAbsolutePathName(fs3
, path
, &result
);
433 ok(hr
== S_OK
, "GetAbsolutePathName returned %x, expected S_OK\n", hr
);
434 GetFullPathNameW(dir1
, MAX_PATH
, buf
, NULL
);
435 ok(!lstrcmpW(buf
, result
) || broken(!lstrcmpW(buf2
, result
)), "result = %s, expected %s\n",
436 wine_dbgstr_w(result
), wine_dbgstr_w(buf
));
437 SysFreeString(result
);
439 ok(CreateDirectoryW(dir2
, NULL
), "CreateDirectory(%s) failed\n", wine_dbgstr_w(dir2
));
440 hr
= IFileSystem3_GetAbsolutePathName(fs3
, path
, &result
);
441 ok(hr
== S_OK
, "GetAbsolutePathName returned %x, expected S_OK\n", hr
);
442 if(!lstrcmpW(buf
, result
) || !lstrcmpW(buf2
, result
)) {
443 ok(!lstrcmpW(buf
, result
) || broken(!lstrcmpW(buf2
, result
)), "result = %s, expected %s\n",
444 wine_dbgstr_w(result
), wine_dbgstr_w(buf
));
446 GetFullPathNameW(dir2
, MAX_PATH
, buf
, NULL
);
447 ok(!lstrcmpW(buf
, result
), "result = %s, expected %s\n",
448 wine_dbgstr_w(result
), wine_dbgstr_w(buf
));
450 SysFreeString(result
);
453 path
= SysAllocString(dir_match2
);
454 hr
= IFileSystem3_GetAbsolutePathName(fs3
, path
, &result
);
455 ok(hr
== S_OK
, "GetAbsolutePathName returned %x, expected S_OK\n", hr
);
456 GetFullPathNameW(dir_match2
, MAX_PATH
, buf
, NULL
);
457 ok(!lstrcmpW(buf
, result
), "result = %s, expected %s\n", wine_dbgstr_w(result
), wine_dbgstr_w(buf
));
458 SysFreeString(result
);
461 RemoveDirectoryW(dir1
);
462 RemoveDirectoryW(dir2
);
465 static void test_GetFile(void)
467 static const WCHAR get_file
[] = {'g','e','t','_','f','i','l','e','.','t','s','t',0};
469 BSTR path
= SysAllocString(get_file
);
477 hr
= IFileSystem3_GetFile(fs3
, path
, NULL
);
478 ok(hr
== E_POINTER
, "GetFile returned %x, expected E_POINTER\n", hr
);
479 hr
= IFileSystem3_GetFile(fs3
, NULL
, &file
);
480 ok(hr
== E_INVALIDARG
, "GetFile returned %x, expected E_INVALIDARG\n", hr
);
482 if(GetFileAttributesW(path
) != INVALID_FILE_ATTRIBUTES
) {
483 skip("File already exists, skipping GetFile tests\n");
488 file
= (IFile
*)0xdeadbeef;
489 hr
= IFileSystem3_GetFile(fs3
, path
, &file
);
490 ok(!file
, "file != NULL\n");
491 ok(hr
== CTL_E_FILENOTFOUND
, "GetFile returned %x, expected CTL_E_FILENOTFOUND\n", hr
);
493 hf
= CreateFileW(path
, GENERIC_WRITE
, 0, NULL
, CREATE_NEW
, FILE_ATTRIBUTE_READONLY
, NULL
);
494 if(hf
== INVALID_HANDLE_VALUE
) {
495 skip("Can't create temporary file\n");
501 hr
= IFileSystem3_GetFile(fs3
, path
, &file
);
502 ok(hr
== S_OK
, "GetFile returned %x, expected S_OK\n", hr
);
504 hr
= IFile_get_Attributes(file
, &fa
);
505 gfa
= GetFileAttributesW(get_file
) & (FILE_ATTRIBUTE_READONLY
| FILE_ATTRIBUTE_HIDDEN
|
506 FILE_ATTRIBUTE_SYSTEM
| FILE_ATTRIBUTE_DIRECTORY
| FILE_ATTRIBUTE_ARCHIVE
|
507 FILE_ATTRIBUTE_REPARSE_POINT
| FILE_ATTRIBUTE_COMPRESSED
);
508 ok(hr
== S_OK
, "get_Attributes returned %x, expected S_OK\n", hr
);
509 ok(fa
== gfa
, "fa = %x, expected %x\n", fa
, gfa
);
511 hr
= IFile_get_Size(file
, &size
);
512 ok(hr
== S_OK
, "get_Size returned %x, expected S_OK\n", hr
);
513 ok(V_VT(&size
) == VT_I4
, "V_VT(&size) = %d, expected VT_I4\n", V_VT(&size
));
514 ok(V_I4(&size
) == 0, "V_I4(&size) = %d, expected 0\n", V_I4(&size
));
517 hr
= IFileSystem3_DeleteFile(fs3
, path
, FALSE
);
518 ok(hr
==CTL_E_PERMISSIONDENIED
|| broken(hr
==S_OK
),
519 "DeleteFile returned %x, expected CTL_E_PERMISSIONDENIED\n", hr
);
521 hr
= IFileSystem3_DeleteFile(fs3
, path
, TRUE
);
522 ok(hr
== S_OK
, "DeleteFile returned %x, expected S_OK\n", hr
);
524 hr
= IFileSystem3_DeleteFile(fs3
, path
, TRUE
);
525 ok(hr
== CTL_E_FILENOTFOUND
, "DeleteFile returned %x, expected CTL_E_FILENOTFOUND\n", hr
);
530 static inline BOOL
create_file(const WCHAR
*name
)
532 HANDLE f
= CreateFileW(name
, GENERIC_WRITE
, 0, NULL
, CREATE_NEW
, 0, NULL
);
534 return f
!= INVALID_HANDLE_VALUE
;
537 static inline void create_path(const WCHAR
*folder
, const WCHAR
*name
, WCHAR
*ret
)
539 DWORD len
= lstrlenW(folder
);
540 memmove(ret
, folder
, len
*sizeof(WCHAR
));
542 memmove(ret
+len
+1, name
, (lstrlenW(name
)+1)*sizeof(WCHAR
));
545 static void test_CopyFolder(void)
547 static const WCHAR filesystem3_dir
[] = {'f','i','l','e','s','y','s','t','e','m','3','_','t','e','s','t',0};
548 static const WCHAR s1
[] = {'s','r','c','1',0};
549 static const WCHAR s
[] = {'s','r','c','*',0};
550 static const WCHAR d
[] = {'d','s','t',0};
551 static const WCHAR empty
[] = {0};
557 if(!CreateDirectoryW(filesystem3_dir
, NULL
)) {
558 skip("can't create temporary directory\n");
562 create_path(filesystem3_dir
, s1
, tmp
);
563 bsrc
= SysAllocString(tmp
);
564 create_path(filesystem3_dir
, d
, tmp
);
565 bdst
= SysAllocString(tmp
);
566 hr
= IFileSystem3_CopyFile(fs3
, bsrc
, bdst
, VARIANT_TRUE
);
567 ok(hr
== CTL_E_FILENOTFOUND
, "CopyFile returned %x, expected CTL_E_FILENOTFOUND\n", hr
);
569 hr
= IFileSystem3_CopyFolder(fs3
, bsrc
, bdst
, VARIANT_TRUE
);
570 ok(hr
== CTL_E_PATHNOTFOUND
, "CopyFolder returned %x, expected CTL_E_PATHNOTFOUND\n", hr
);
572 ok(create_file(bsrc
), "can't create %s file\n", wine_dbgstr_w(bsrc
));
573 hr
= IFileSystem3_CopyFile(fs3
, bsrc
, bdst
, VARIANT_TRUE
);
574 ok(hr
== S_OK
, "CopyFile returned %x, expected S_OK\n", hr
);
576 hr
= IFileSystem3_CopyFolder(fs3
, bsrc
, bdst
, VARIANT_TRUE
);
577 ok(hr
== CTL_E_PATHNOTFOUND
, "CopyFolder returned %x, expected CTL_E_PATHNOTFOUND\n", hr
);
579 hr
= IFileSystem3_DeleteFile(fs3
, bsrc
, VARIANT_FALSE
);
580 ok(hr
== S_OK
, "DeleteFile returned %x, expected S_OK\n", hr
);
582 ok(CreateDirectoryW(bsrc
, NULL
), "can't create %s\n", wine_dbgstr_w(bsrc
));
583 hr
= IFileSystem3_CopyFile(fs3
, bsrc
, bdst
, VARIANT_TRUE
);
584 ok(hr
== CTL_E_FILENOTFOUND
, "CopyFile returned %x, expected CTL_E_FILENOTFOUND\n", hr
);
586 hr
= IFileSystem3_CopyFolder(fs3
, bsrc
, bdst
, VARIANT_TRUE
);
587 ok(hr
== CTL_E_FILEALREADYEXISTS
, "CopyFolder returned %x, expected CTL_E_FILEALREADYEXISTS\n", hr
);
589 hr
= IFileSystem3_DeleteFile(fs3
, bdst
, VARIANT_TRUE
);
590 ok(hr
== S_OK
, "DeleteFile returned %x, expected S_OK\n", hr
);
592 hr
= IFileSystem3_CopyFolder(fs3
, bsrc
, bdst
, VARIANT_TRUE
);
593 ok(hr
== S_OK
, "CopyFolder returned %x, expected S_OK\n", hr
);
595 hr
= IFileSystem3_CopyFolder(fs3
, bsrc
, bdst
, VARIANT_TRUE
);
596 ok(hr
== S_OK
, "CopyFolder returned %x, expected S_OK\n", hr
);
597 create_path(tmp
, s1
, tmp
);
598 ok(GetFileAttributesW(tmp
) == INVALID_FILE_ATTRIBUTES
,
599 "%s file exists\n", wine_dbgstr_w(tmp
));
601 create_path(filesystem3_dir
, d
, tmp
);
602 create_path(tmp
, empty
, tmp
);
604 bdst
= SysAllocString(tmp
);
605 hr
= IFileSystem3_CopyFolder(fs3
, bsrc
, bdst
, VARIANT_TRUE
);
606 ok(hr
== S_OK
, "CopyFolder returned %x, expected S_OK\n", hr
);
607 create_path(tmp
, s1
, tmp
);
608 ok(GetFileAttributesW(tmp
) != INVALID_FILE_ATTRIBUTES
,
609 "%s directory doesn't exist\n", wine_dbgstr_w(tmp
));
610 ok(RemoveDirectoryW(tmp
), "can't remove %s directory\n", wine_dbgstr_w(tmp
));
611 create_path(filesystem3_dir
, d
, tmp
);
613 bdst
= SysAllocString(tmp
);
616 create_path(filesystem3_dir
, s
, tmp
);
618 bsrc
= SysAllocString(tmp
);
619 hr
= IFileSystem3_CopyFolder(fs3
, bsrc
, bdst
, VARIANT_TRUE
);
620 ok(hr
== S_OK
, "CopyFolder returned %x, expected S_OK\n", hr
);
621 create_path(filesystem3_dir
, d
, tmp
);
622 create_path(tmp
, s1
, tmp
);
623 ok(GetFileAttributesW(tmp
) != INVALID_FILE_ATTRIBUTES
,
624 "%s directory doesn't exist\n", wine_dbgstr_w(tmp
));
626 hr
= IFileSystem3_DeleteFolder(fs3
, bdst
, VARIANT_FALSE
);
627 ok(hr
== S_OK
, "DeleteFolder returned %x, expected S_OK\n", hr
);
629 hr
= IFileSystem3_CopyFolder(fs3
, bsrc
, bdst
, VARIANT_TRUE
);
630 ok(hr
== CTL_E_PATHNOTFOUND
, "CopyFolder returned %x, expected CTL_E_PATHNOTFOUND\n", hr
);
632 create_path(filesystem3_dir
, s1
, tmp
);
634 bsrc
= SysAllocString(tmp
);
635 create_path(tmp
, s1
, tmp
);
636 ok(create_file(tmp
), "can't create %s file\n", wine_dbgstr_w(tmp
));
637 hr
= IFileSystem3_CopyFolder(fs3
, bsrc
, bdst
, VARIANT_FALSE
);
638 ok(hr
== S_OK
, "CopyFolder returned %x, expected S_OK\n", hr
);
640 hr
= IFileSystem3_CopyFolder(fs3
, bsrc
, bdst
, VARIANT_FALSE
);
641 ok(hr
== CTL_E_FILEALREADYEXISTS
, "CopyFolder returned %x, expected CTL_E_FILEALREADYEXISTS\n", hr
);
643 hr
= IFileSystem3_CopyFolder(fs3
, bsrc
, bdst
, VARIANT_TRUE
);
644 ok(hr
== S_OK
, "CopyFolder returned %x, expected S_OK\n", hr
);
648 bsrc
= SysAllocString(filesystem3_dir
);
649 hr
= IFileSystem3_DeleteFolder(fs3
, bsrc
, VARIANT_FALSE
);
650 ok(hr
== S_OK
, "DeleteFolder returned %x, expected S_OK\n", hr
);
654 START_TEST(filesystem
)
660 hr
= CoCreateInstance(&CLSID_FileSystemObject
, NULL
, CLSCTX_INPROC_SERVER
|CLSCTX_INPROC_HANDLER
,
661 &IID_IFileSystem3
, (void**)&fs3
);
663 win_skip("Could not create FileSystem object: %08x\n", hr
);
670 test_GetFileVersion();
671 test_GetParentFolderName();
674 test_GetAbsolutePathName();
678 IFileSystem3_Release(fs3
);