wbemprox: Add support for enumerating class properties.
[wine] / dlls / scrrun / filesystem.c
1 /*
2  * Copyright 2012 Alistair Leslie-Hughes
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #define COBJMACROS
20
21 #include "config.h"
22 #include <stdarg.h>
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "ole2.h"
27 #include "dispex.h"
28 #include "scrrun.h"
29 #include "scrrun_private.h"
30
31 #include "wine/debug.h"
32
33 WINE_DEFAULT_DEBUG_CHANNEL(scrrun);
34
35 static HRESULT WINAPI filesys_QueryInterface(IFileSystem3 *iface, REFIID riid, void **ppvObject)
36 {
37     TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject);
38
39     if ( IsEqualGUID( riid, &IID_IFileSystem3 ) ||
40          IsEqualGUID( riid, &IID_IFileSystem ) ||
41          IsEqualGUID( riid, &IID_IDispatch ) ||
42          IsEqualGUID( riid, &IID_IUnknown ) )
43     {
44         *ppvObject = iface;
45     }
46     else if ( IsEqualGUID( riid, &IID_IDispatchEx ))
47     {
48         TRACE("Interface IDispatchEx not supported - returning NULL\n");
49         *ppvObject = NULL;
50         return E_NOINTERFACE;
51     }
52     else if ( IsEqualGUID( riid, &IID_IObjectWithSite ))
53     {
54         TRACE("Interface IObjectWithSite not supported - returning NULL\n");
55         *ppvObject = NULL;
56         return E_NOINTERFACE;
57     }
58     else
59     {
60         FIXME("Unsupported interface %s\n", debugstr_guid(riid));
61         return E_NOINTERFACE;
62     }
63
64     IFileSystem3_AddRef(iface);
65
66     return S_OK;
67 }
68
69 static ULONG WINAPI filesys_AddRef(IFileSystem3 *iface)
70 {
71     TRACE("%p\n", iface);
72
73     return 2;
74 }
75
76 static ULONG WINAPI filesys_Release(IFileSystem3 *iface)
77 {
78     TRACE("%p\n", iface);
79
80     return 1;
81 }
82
83 static HRESULT WINAPI filesys_GetTypeInfoCount(IFileSystem3 *iface, UINT *pctinfo)
84 {
85     TRACE("(%p)->(%p)\n", iface, pctinfo);
86
87     *pctinfo = 1;
88     return S_OK;
89 }
90
91 static HRESULT WINAPI filesys_GetTypeInfo(IFileSystem3 *iface, UINT iTInfo,
92                                         LCID lcid, ITypeInfo **ppTInfo)
93 {
94     TRACE("(%p)->(%u %u %p)\n", iface, iTInfo, lcid, ppTInfo);
95     return get_typeinfo(IFileSystem3_tid, ppTInfo);}
96
97 static HRESULT WINAPI filesys_GetIDsOfNames(IFileSystem3 *iface, REFIID riid,
98                                         LPOLESTR *rgszNames, UINT cNames,
99                                         LCID lcid, DISPID *rgDispId)
100 {
101     ITypeInfo *typeinfo;
102     HRESULT hr;
103
104     TRACE("(%p)->(%s %p %u %u %p)\n", iface, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
105
106     hr = get_typeinfo(IFileSystem3_tid, &typeinfo);
107     if(SUCCEEDED(hr))
108     {
109         hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
110         ITypeInfo_Release(typeinfo);
111     }
112
113     return hr;
114 }
115
116 static HRESULT WINAPI filesys_Invoke(IFileSystem3 *iface, DISPID dispIdMember,
117                                       REFIID riid, LCID lcid, WORD wFlags,
118                                       DISPPARAMS *pDispParams, VARIANT *pVarResult,
119                                       EXCEPINFO *pExcepInfo, UINT *puArgErr)
120 {
121     ITypeInfo *typeinfo;
122     HRESULT hr;
123
124     TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", iface, dispIdMember, debugstr_guid(riid),
125            lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
126
127     hr = get_typeinfo(IFileSystem3_tid, &typeinfo);
128     if(SUCCEEDED(hr))
129     {
130         hr = ITypeInfo_Invoke(typeinfo, &iface, dispIdMember, wFlags,
131                 pDispParams, pVarResult, pExcepInfo, puArgErr);
132         ITypeInfo_Release(typeinfo);
133     }
134
135     return hr;
136 }
137
138 static HRESULT WINAPI filesys_get_Drives(IFileSystem3 *iface, IDriveCollection **ppdrives)
139 {
140     FIXME("%p %p\n", iface, ppdrives);
141
142     return E_NOTIMPL;
143 }
144
145 static HRESULT WINAPI filesys_BuildPath(IFileSystem3 *iface, BSTR Path,
146                                             BSTR Name, BSTR *pbstrResult)
147 {
148     FIXME("%p %s %s %p\n", iface, debugstr_w(Path), debugstr_w(Name), pbstrResult);
149
150     return E_NOTIMPL;
151 }
152
153 static HRESULT WINAPI filesys_GetDriveName(IFileSystem3 *iface, BSTR Path,
154                                             BSTR *pbstrResult)
155 {
156     FIXME("%p %s %p\n", iface, debugstr_w(Path), pbstrResult);
157
158     return E_NOTIMPL;
159 }
160
161 static HRESULT WINAPI filesys_GetParentFolderName(IFileSystem3 *iface, BSTR Path,
162                                             BSTR *pbstrResult)
163 {
164     FIXME("%p %s %p\n", iface, debugstr_w(Path), pbstrResult);
165
166     return E_NOTIMPL;
167 }
168
169 static HRESULT WINAPI filesys_GetFileName(IFileSystem3 *iface, BSTR Path,
170                                             BSTR *pbstrResult)
171 {
172     FIXME("%p %s %p\n", iface, debugstr_w(Path), pbstrResult);
173
174     return E_NOTIMPL;
175 }
176
177 static HRESULT WINAPI filesys_GetBaseName(IFileSystem3 *iface, BSTR Path,
178                                             BSTR *pbstrResult)
179 {
180     FIXME("%p %s %p\n", iface, debugstr_w(Path), pbstrResult);
181
182     return E_NOTIMPL;
183 }
184
185 static HRESULT WINAPI filesys_GetExtensionName(IFileSystem3 *iface, BSTR Path,
186                                             BSTR *pbstrResult)
187 {
188     FIXME("%p %s %p\n", iface, debugstr_w(Path), pbstrResult);
189
190     return E_NOTIMPL;
191 }
192
193 static HRESULT WINAPI filesys_GetAbsolutePathName(IFileSystem3 *iface, BSTR Path,
194                                             BSTR *pbstrResult)
195 {
196     FIXME("%p %s %p\n", iface, debugstr_w(Path), pbstrResult);
197
198     return E_NOTIMPL;
199 }
200
201 static HRESULT WINAPI filesys_GetTempName(IFileSystem3 *iface, BSTR *pbstrResult)
202 {
203     FIXME("%p %p\n", iface, pbstrResult);
204
205     return E_NOTIMPL;
206 }
207
208 static HRESULT WINAPI filesys_DriveExists(IFileSystem3 *iface, BSTR DriveSpec,
209                                             VARIANT_BOOL *pfExists)
210 {
211     FIXME("%p %s %p\n", iface, debugstr_w(DriveSpec), pfExists);
212
213     return E_NOTIMPL;
214 }
215
216 static HRESULT WINAPI filesys_FileExists(IFileSystem3 *iface, BSTR path, VARIANT_BOOL *ret)
217 {
218     TRACE("%p %s %p\n", iface, debugstr_w(path), ret);
219
220     if (!ret) return E_POINTER;
221
222     *ret = GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES ? VARIANT_TRUE : VARIANT_FALSE;
223     return S_OK;
224 }
225
226 static HRESULT WINAPI filesys_FolderExists(IFileSystem3 *iface, BSTR FolderSpec,
227                                             VARIANT_BOOL *pfExists)
228 {
229     FIXME("%p %s %p\n", iface, debugstr_w(FolderSpec), pfExists);
230
231     return E_NOTIMPL;
232 }
233
234 static HRESULT WINAPI filesys_GetDrive(IFileSystem3 *iface, BSTR DriveSpec,
235                                             IDrive **ppdrive)
236 {
237     FIXME("%p %s %p\n", iface, debugstr_w(DriveSpec), ppdrive);
238
239     return E_NOTIMPL;
240 }
241
242 static HRESULT WINAPI filesys_GetFile(IFileSystem3 *iface, BSTR FilePath,
243                                             IFile **ppfile)
244 {
245     FIXME("%p %s %p\n", iface, debugstr_w(FilePath), ppfile);
246
247     return E_NOTIMPL;
248 }
249
250 static HRESULT WINAPI filesys_GetFolder(IFileSystem3 *iface, BSTR FolderPath,
251                                             IFolder **ppfolder)
252 {
253     FIXME("%p %s %p\n", iface, debugstr_w(FolderPath), ppfolder);
254
255     return E_NOTIMPL;
256 }
257
258 static HRESULT WINAPI filesys_GetSpecialFolder(IFileSystem3 *iface,
259                                             SpecialFolderConst SpecialFolder,
260                                             IFolder **ppfolder)
261 {
262     FIXME("%p %d %p\n", iface, SpecialFolder, ppfolder);
263
264     return E_NOTIMPL;
265 }
266
267 static HRESULT WINAPI filesys_DeleteFile(IFileSystem3 *iface, BSTR FileSpec,
268                                             VARIANT_BOOL Force)
269 {
270     FIXME("%p %s %d\n", iface, debugstr_w(FileSpec), Force);
271
272     return E_NOTIMPL;
273 }
274
275 static HRESULT WINAPI filesys_DeleteFolder(IFileSystem3 *iface, BSTR FolderSpec,
276                                             VARIANT_BOOL Force)
277 {
278     FIXME("%p %s %d\n", iface, debugstr_w(FolderSpec), Force);
279
280     return E_NOTIMPL;
281 }
282
283 static HRESULT WINAPI filesys_MoveFile(IFileSystem3 *iface, BSTR Source,
284                                             BSTR Destination)
285 {
286     FIXME("%p %s %s\n", iface, debugstr_w(Source), debugstr_w(Destination));
287
288     return E_NOTIMPL;
289 }
290
291 static HRESULT WINAPI filesys_MoveFolder(IFileSystem3 *iface,BSTR Source,
292                                             BSTR Destination)
293 {
294     FIXME("%p %s %s\n", iface, debugstr_w(Source), debugstr_w(Destination));
295
296     return E_NOTIMPL;
297 }
298
299 static HRESULT WINAPI filesys_CopyFile(IFileSystem3 *iface, BSTR Source,
300                                             BSTR Destination, VARIANT_BOOL OverWriteFiles)
301 {
302     FIXME("%p %s %s %d\n", iface, debugstr_w(Source), debugstr_w(Destination), OverWriteFiles);
303
304     return E_NOTIMPL;
305 }
306
307 static HRESULT WINAPI filesys_CopyFolder(IFileSystem3 *iface, BSTR Source,
308                                             BSTR Destination, VARIANT_BOOL OverWriteFiles)
309 {
310     FIXME("%p %s %s %d\n", iface, debugstr_w(Source), debugstr_w(Destination), OverWriteFiles);
311
312     return E_NOTIMPL;
313 }
314
315 static HRESULT WINAPI filesys_CreateFolder(IFileSystem3 *iface, BSTR Path,
316                                             IFolder **ppfolder)
317 {
318     FIXME("%p %s %p\n", iface, debugstr_w(Path), ppfolder);
319
320     return E_NOTIMPL;
321 }
322
323 static HRESULT WINAPI filesys_CreateTextFile(IFileSystem3 *iface, BSTR FileName,
324                                             VARIANT_BOOL Overwrite, VARIANT_BOOL Unicode,
325                                             ITextStream **ppts)
326 {
327     FIXME("%p %s %d %d %p\n", iface, debugstr_w(FileName), Overwrite, Unicode, ppts);
328
329     return E_NOTIMPL;
330 }
331
332 static HRESULT WINAPI filesys_OpenTextFile(IFileSystem3 *iface, BSTR FileName,
333                                             IOMode IOMode, VARIANT_BOOL Create,
334                                             Tristate Format, ITextStream **ppts)
335 {
336     FIXME("%p %s %d %d %d %p\n", iface, debugstr_w(FileName), IOMode, Create, Format, ppts);
337
338     return E_NOTIMPL;
339 }
340
341 static HRESULT WINAPI filesys_GetStandardStream(IFileSystem3 *iface,
342                                             StandardStreamTypes StandardStreamType,
343                                             VARIANT_BOOL Unicode,
344                                             ITextStream **ppts)
345 {
346     FIXME("%p %d %d %p\n", iface, StandardStreamType, Unicode, ppts);
347
348     return E_NOTIMPL;
349 }
350
351 static HRESULT WINAPI filesys_GetFileVersion(IFileSystem3 *iface, BSTR FileName,
352                                             BSTR *FileVersion)
353 {
354     FIXME("%p %s %p\n", iface, debugstr_w(FileName), FileVersion);
355
356     return E_NOTIMPL;
357 }
358
359 static const struct IFileSystem3Vtbl filesys_vtbl =
360 {
361     filesys_QueryInterface,
362     filesys_AddRef,
363     filesys_Release,
364     filesys_GetTypeInfoCount,
365     filesys_GetTypeInfo,
366     filesys_GetIDsOfNames,
367     filesys_Invoke,
368     filesys_get_Drives,
369     filesys_BuildPath,
370     filesys_GetDriveName,
371     filesys_GetParentFolderName,
372     filesys_GetFileName,
373     filesys_GetBaseName,
374     filesys_GetExtensionName,
375     filesys_GetAbsolutePathName,
376     filesys_GetTempName,
377     filesys_DriveExists,
378     filesys_FileExists,
379     filesys_FolderExists,
380     filesys_GetDrive,
381     filesys_GetFile,
382     filesys_GetFolder,
383     filesys_GetSpecialFolder,
384     filesys_DeleteFile,
385     filesys_DeleteFolder,
386     filesys_MoveFile,
387     filesys_MoveFolder,
388     filesys_CopyFile,
389     filesys_CopyFolder,
390     filesys_CreateFolder,
391     filesys_CreateTextFile,
392     filesys_OpenTextFile,
393     filesys_GetStandardStream,
394     filesys_GetFileVersion
395 };
396
397 static IFileSystem3 filesystem = { &filesys_vtbl };
398
399 HRESULT WINAPI FileSystem_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
400 {
401     TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
402
403     return IFileSystem3_QueryInterface(&filesystem, riid, ppv);
404 }