ws2_32: Define IP_UNICAST_IF if not found on linux.
[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     DWORD attrs;
219     TRACE("%p %s %p\n", iface, debugstr_w(path), ret);
220
221     if (!ret) return E_POINTER;
222
223     attrs = GetFileAttributesW(path);
224     *ret = attrs != INVALID_FILE_ATTRIBUTES && !(attrs & FILE_ATTRIBUTE_DIRECTORY) ? VARIANT_TRUE : VARIANT_FALSE;
225     return S_OK;
226 }
227
228 static HRESULT WINAPI filesys_FolderExists(IFileSystem3 *iface, BSTR path, VARIANT_BOOL *ret)
229 {
230     DWORD attrs;
231     TRACE("%p %s %p\n", iface, debugstr_w(path), ret);
232
233     if (!ret) return E_POINTER;
234
235     attrs = GetFileAttributesW(path);
236     *ret = attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY) ? VARIANT_TRUE : VARIANT_FALSE;
237
238     return S_OK;
239 }
240
241 static HRESULT WINAPI filesys_GetDrive(IFileSystem3 *iface, BSTR DriveSpec,
242                                             IDrive **ppdrive)
243 {
244     FIXME("%p %s %p\n", iface, debugstr_w(DriveSpec), ppdrive);
245
246     return E_NOTIMPL;
247 }
248
249 static HRESULT WINAPI filesys_GetFile(IFileSystem3 *iface, BSTR FilePath,
250                                             IFile **ppfile)
251 {
252     FIXME("%p %s %p\n", iface, debugstr_w(FilePath), ppfile);
253
254     return E_NOTIMPL;
255 }
256
257 static HRESULT WINAPI filesys_GetFolder(IFileSystem3 *iface, BSTR FolderPath,
258                                             IFolder **ppfolder)
259 {
260     FIXME("%p %s %p\n", iface, debugstr_w(FolderPath), ppfolder);
261
262     return E_NOTIMPL;
263 }
264
265 static HRESULT WINAPI filesys_GetSpecialFolder(IFileSystem3 *iface,
266                                             SpecialFolderConst SpecialFolder,
267                                             IFolder **ppfolder)
268 {
269     FIXME("%p %d %p\n", iface, SpecialFolder, ppfolder);
270
271     return E_NOTIMPL;
272 }
273
274 static HRESULT WINAPI filesys_DeleteFile(IFileSystem3 *iface, BSTR FileSpec,
275                                             VARIANT_BOOL Force)
276 {
277     FIXME("%p %s %d\n", iface, debugstr_w(FileSpec), Force);
278
279     return E_NOTIMPL;
280 }
281
282 static HRESULT WINAPI filesys_DeleteFolder(IFileSystem3 *iface, BSTR FolderSpec,
283                                             VARIANT_BOOL Force)
284 {
285     FIXME("%p %s %d\n", iface, debugstr_w(FolderSpec), Force);
286
287     return E_NOTIMPL;
288 }
289
290 static HRESULT WINAPI filesys_MoveFile(IFileSystem3 *iface, BSTR Source,
291                                             BSTR Destination)
292 {
293     FIXME("%p %s %s\n", iface, debugstr_w(Source), debugstr_w(Destination));
294
295     return E_NOTIMPL;
296 }
297
298 static HRESULT WINAPI filesys_MoveFolder(IFileSystem3 *iface,BSTR Source,
299                                             BSTR Destination)
300 {
301     FIXME("%p %s %s\n", iface, debugstr_w(Source), debugstr_w(Destination));
302
303     return E_NOTIMPL;
304 }
305
306 static HRESULT WINAPI filesys_CopyFile(IFileSystem3 *iface, BSTR Source,
307                                             BSTR Destination, VARIANT_BOOL OverWriteFiles)
308 {
309     FIXME("%p %s %s %d\n", iface, debugstr_w(Source), debugstr_w(Destination), OverWriteFiles);
310
311     return E_NOTIMPL;
312 }
313
314 static HRESULT WINAPI filesys_CopyFolder(IFileSystem3 *iface, BSTR Source,
315                                             BSTR Destination, VARIANT_BOOL OverWriteFiles)
316 {
317     FIXME("%p %s %s %d\n", iface, debugstr_w(Source), debugstr_w(Destination), OverWriteFiles);
318
319     return E_NOTIMPL;
320 }
321
322 static HRESULT WINAPI filesys_CreateFolder(IFileSystem3 *iface, BSTR Path,
323                                             IFolder **ppfolder)
324 {
325     FIXME("%p %s %p\n", iface, debugstr_w(Path), ppfolder);
326
327     return E_NOTIMPL;
328 }
329
330 static HRESULT WINAPI filesys_CreateTextFile(IFileSystem3 *iface, BSTR FileName,
331                                             VARIANT_BOOL Overwrite, VARIANT_BOOL Unicode,
332                                             ITextStream **ppts)
333 {
334     FIXME("%p %s %d %d %p\n", iface, debugstr_w(FileName), Overwrite, Unicode, ppts);
335
336     return E_NOTIMPL;
337 }
338
339 static HRESULT WINAPI filesys_OpenTextFile(IFileSystem3 *iface, BSTR FileName,
340                                             IOMode IOMode, VARIANT_BOOL Create,
341                                             Tristate Format, ITextStream **ppts)
342 {
343     FIXME("%p %s %d %d %d %p\n", iface, debugstr_w(FileName), IOMode, Create, Format, ppts);
344
345     return E_NOTIMPL;
346 }
347
348 static HRESULT WINAPI filesys_GetStandardStream(IFileSystem3 *iface,
349                                             StandardStreamTypes StandardStreamType,
350                                             VARIANT_BOOL Unicode,
351                                             ITextStream **ppts)
352 {
353     FIXME("%p %d %d %p\n", iface, StandardStreamType, Unicode, ppts);
354
355     return E_NOTIMPL;
356 }
357
358 static HRESULT WINAPI filesys_GetFileVersion(IFileSystem3 *iface, BSTR FileName,
359                                             BSTR *FileVersion)
360 {
361     FIXME("%p %s %p\n", iface, debugstr_w(FileName), FileVersion);
362
363     return E_NOTIMPL;
364 }
365
366 static const struct IFileSystem3Vtbl filesys_vtbl =
367 {
368     filesys_QueryInterface,
369     filesys_AddRef,
370     filesys_Release,
371     filesys_GetTypeInfoCount,
372     filesys_GetTypeInfo,
373     filesys_GetIDsOfNames,
374     filesys_Invoke,
375     filesys_get_Drives,
376     filesys_BuildPath,
377     filesys_GetDriveName,
378     filesys_GetParentFolderName,
379     filesys_GetFileName,
380     filesys_GetBaseName,
381     filesys_GetExtensionName,
382     filesys_GetAbsolutePathName,
383     filesys_GetTempName,
384     filesys_DriveExists,
385     filesys_FileExists,
386     filesys_FolderExists,
387     filesys_GetDrive,
388     filesys_GetFile,
389     filesys_GetFolder,
390     filesys_GetSpecialFolder,
391     filesys_DeleteFile,
392     filesys_DeleteFolder,
393     filesys_MoveFile,
394     filesys_MoveFolder,
395     filesys_CopyFile,
396     filesys_CopyFolder,
397     filesys_CreateFolder,
398     filesys_CreateTextFile,
399     filesys_OpenTextFile,
400     filesys_GetStandardStream,
401     filesys_GetFileVersion
402 };
403
404 static IFileSystem3 filesystem = { &filesys_vtbl };
405
406 HRESULT WINAPI FileSystem_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
407 {
408     TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
409
410     return IFileSystem3_QueryInterface(&filesystem, riid, ppv);
411 }