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 void test_interfaces(void)
36 static const WCHAR nonexistent_dirW[] = {
37 'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', 0};
38 static const WCHAR pathW[] = {'p','a','t','h',0};
39 static const WCHAR file_kernel32W[] = {
40 '\\', 'k', 'e', 'r', 'n', 'e', 'l', '3', '2', '.', 'd', 'l', 'l', 0};
45 IObjectWithSite *site;
48 WCHAR windows_path[MAX_PATH];
49 WCHAR file_path[MAX_PATH];
51 hr = CoCreateInstance(&CLSID_FileSystemObject, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
52 &IID_IDispatch, (void**)&disp);
54 win_skip("Could not create FileSystem object: %08x\n", hr);
58 GetSystemDirectoryW(windows_path, MAX_PATH);
59 lstrcpyW(file_path, windows_path);
60 lstrcatW(file_path, file_kernel32W);
62 hr = IDispatch_QueryInterface(disp, &IID_IFileSystem3, (void**)&fs3);
63 ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
65 hr = IDispatch_QueryInterface(disp, &IID_IObjectWithSite, (void**)&site);
66 ok(hr == E_NOINTERFACE, "got 0x%08x, expected 0x%08x\n", hr, E_NOINTERFACE);
68 hr = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&dispex);
69 ok(hr == E_NOINTERFACE, "got 0x%08x, expected 0x%08x\n", hr, E_NOINTERFACE);
72 hr = IFileSystem3_FileExists(fs3, NULL, &b);
73 ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
74 ok(b == VARIANT_FALSE, "got %x\n", b);
76 hr = IFileSystem3_FileExists(fs3, NULL, NULL);
77 ok(hr == E_POINTER, "got 0x%08x, expected 0x%08x\n", hr, E_POINTER);
79 path = SysAllocString(pathW);
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_FALSE, "got %x\n", b);
86 path = SysAllocString(file_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_TRUE, "got %x\n", b);
93 path = SysAllocString(windows_path);
95 hr = IFileSystem3_FileExists(fs3, path, &b);
96 ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
97 ok(b == VARIANT_FALSE, "got %x\n", b);
101 hr = IFileSystem3_FolderExists(fs3, NULL, NULL);
102 ok(hr == E_POINTER, "got 0x%08x, expected 0x%08x\n", hr, E_POINTER);
104 path = SysAllocString(windows_path);
105 hr = IFileSystem3_FolderExists(fs3, path, &b);
106 ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
107 ok(b == VARIANT_TRUE, "Folder doesn't exists\n");
110 path = SysAllocString(nonexistent_dirW);
111 hr = IFileSystem3_FolderExists(fs3, path, &b);
112 ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
113 ok(b == VARIANT_FALSE, "Folder exists\n");
116 path = SysAllocString(file_path);
117 hr = IFileSystem3_FolderExists(fs3, path, &b);
118 ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
119 ok(b == VARIANT_FALSE, "Folder exists\n");
122 IFileSystem3_Release(fs3);
123 IDispatch_Release(disp);
126 static void test_createfolder(void)
130 WCHAR pathW[MAX_PATH];
134 hr = CoCreateInstance(&CLSID_FileSystemObject, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
135 &IID_IFileSystem3, (void**)&fs3);
137 win_skip("Could not create FileSystem object: %08x\n", hr);
141 /* create existing directory */
142 GetCurrentDirectoryW(sizeof(pathW)/sizeof(WCHAR), pathW);
143 path = SysAllocString(pathW);
144 folder = (void*)0xdeabeef;
145 hr = IFileSystem3_CreateFolder(fs3, path, &folder);
146 ok(hr == CTL_E_FILEALREADYEXISTS, "got 0x%08x\n", hr);
147 ok(folder == NULL, "got %p\n", folder);
150 IFileSystem3_Release(fs3);
153 START_TEST(filesystem)