2 * Copyright 2012 Alistair Leslie-Hughes
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.
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.
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
30 #include "scrrun_private.h"
32 #include "wine/debug.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(scrrun);
37 IFolder IFolder_iface;
41 static inline struct folder *impl_from_IFolder(IFolder *iface)
43 return CONTAINING_RECORD(iface, struct folder, IFolder_iface);
46 static HRESULT WINAPI folder_QueryInterface(IFolder *iface, REFIID riid, void **obj)
48 struct folder *This = impl_from_IFolder(iface);
50 TRACE("(%p)->(%s %p)\n", This, debugstr_guid(riid), obj);
54 if (IsEqualGUID( riid, &IID_IFolder ) ||
55 IsEqualGUID( riid, &IID_IUnknown))
58 IFolder_AddRef(iface);
66 static ULONG WINAPI folder_AddRef(IFolder *iface)
68 struct folder *This = impl_from_IFolder(iface);
69 ULONG ref = InterlockedIncrement(&This->ref);
70 TRACE("(%p)->(%d)\n", This, ref);
74 static ULONG WINAPI folder_Release(IFolder *iface)
76 struct folder *This = impl_from_IFolder(iface);
77 ULONG ref = InterlockedDecrement(&This->ref);
78 TRACE("(%p)->(%d)\n", This, ref);
86 static HRESULT WINAPI folder_GetTypeInfoCount(IFolder *iface, UINT *pctinfo)
88 struct folder *This = impl_from_IFolder(iface);
89 TRACE("(%p)->(%p)\n", This, pctinfo);
94 static HRESULT WINAPI folder_GetTypeInfo(IFolder *iface, UINT iTInfo,
95 LCID lcid, ITypeInfo **ppTInfo)
97 struct folder *This = impl_from_IFolder(iface);
98 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
99 return get_typeinfo(IFolder_tid, ppTInfo);
102 static HRESULT WINAPI folder_GetIDsOfNames(IFolder *iface, REFIID riid,
103 LPOLESTR *rgszNames, UINT cNames,
104 LCID lcid, DISPID *rgDispId)
106 struct folder *This = impl_from_IFolder(iface);
110 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
112 hr = get_typeinfo(IFolder_tid, &typeinfo);
115 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
116 ITypeInfo_Release(typeinfo);
122 static HRESULT WINAPI folder_Invoke(IFolder *iface, DISPID dispIdMember,
123 REFIID riid, LCID lcid, WORD wFlags,
124 DISPPARAMS *pDispParams, VARIANT *pVarResult,
125 EXCEPINFO *pExcepInfo, UINT *puArgErr)
127 struct folder *This = impl_from_IFolder(iface);
131 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
132 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
134 hr = get_typeinfo(IFolder_tid, &typeinfo);
137 hr = ITypeInfo_Invoke(typeinfo, iface, dispIdMember, wFlags,
138 pDispParams, pVarResult, pExcepInfo, puArgErr);
139 ITypeInfo_Release(typeinfo);
145 static HRESULT WINAPI folder_get_Path(IFolder *iface, BSTR *path)
147 struct folder *This = impl_from_IFolder(iface);
148 FIXME("(%p)->(%p): stub\n", This, path);
152 static HRESULT WINAPI folder_get_Name(IFolder *iface, BSTR *name)
154 struct folder *This = impl_from_IFolder(iface);
155 FIXME("(%p)->(%p): stub\n", This, name);
159 static HRESULT WINAPI folder_put_Name(IFolder *iface, BSTR name)
161 struct folder *This = impl_from_IFolder(iface);
162 FIXME("(%p)->(%s): stub\n", This, debugstr_w(name));
166 static HRESULT WINAPI folder_get_ShortPath(IFolder *iface, BSTR *path)
168 struct folder *This = impl_from_IFolder(iface);
169 FIXME("(%p)->(%p): stub\n", This, path);
173 static HRESULT WINAPI folder_get_ShortName(IFolder *iface, BSTR *name)
175 struct folder *This = impl_from_IFolder(iface);
176 FIXME("(%p)->(%p): stub\n", This, name);
180 static HRESULT WINAPI folder_get_Drive(IFolder *iface, IDrive **drive)
182 struct folder *This = impl_from_IFolder(iface);
183 FIXME("(%p)->(%p): stub\n", This, drive);
187 static HRESULT WINAPI folder_get_ParentFolder(IFolder *iface, IFolder **parent)
189 struct folder *This = impl_from_IFolder(iface);
190 FIXME("(%p)->(%p): stub\n", This, parent);
194 static HRESULT WINAPI folder_get_Attributes(IFolder *iface, FileAttribute *attr)
196 struct folder *This = impl_from_IFolder(iface);
197 FIXME("(%p)->(%p): stub\n", This, attr);
201 static HRESULT WINAPI folder_put_Attributes(IFolder *iface, FileAttribute attr)
203 struct folder *This = impl_from_IFolder(iface);
204 FIXME("(%p)->(0x%x): stub\n", This, attr);
208 static HRESULT WINAPI folder_get_DateCreated(IFolder *iface, DATE *date)
210 struct folder *This = impl_from_IFolder(iface);
211 FIXME("(%p)->(%p): stub\n", This, date);
215 static HRESULT WINAPI folder_get_DateLastModified(IFolder *iface, DATE *date)
217 struct folder *This = impl_from_IFolder(iface);
218 FIXME("(%p)->(%p): stub\n", This, date);
222 static HRESULT WINAPI folder_get_DateLastAccessed(IFolder *iface, DATE *date)
224 struct folder *This = impl_from_IFolder(iface);
225 FIXME("(%p)->(%p): stub\n", This, date);
229 static HRESULT WINAPI folder_get_Type(IFolder *iface, BSTR *type)
231 struct folder *This = impl_from_IFolder(iface);
232 FIXME("(%p)->(%p): stub\n", This, type);
236 static HRESULT WINAPI folder_Delete(IFolder *iface, VARIANT_BOOL force)
238 struct folder *This = impl_from_IFolder(iface);
239 FIXME("(%p)->(%x): stub\n", This, force);
243 static HRESULT WINAPI folder_Copy(IFolder *iface, BSTR dest, VARIANT_BOOL overwrite)
245 struct folder *This = impl_from_IFolder(iface);
246 FIXME("(%p)->(%s %x): stub\n", This, debugstr_w(dest), overwrite);
250 static HRESULT WINAPI folder_Move(IFolder *iface, BSTR dest)
252 struct folder *This = impl_from_IFolder(iface);
253 FIXME("(%p)->(%s): stub\n", This, debugstr_w(dest));
257 static HRESULT WINAPI folder_get_IsRootFolder(IFolder *iface, VARIANT_BOOL *isroot)
259 struct folder *This = impl_from_IFolder(iface);
260 FIXME("(%p)->(%p): stub\n", This, isroot);
264 static HRESULT WINAPI folder_get_Size(IFolder *iface, VARIANT *size)
266 struct folder *This = impl_from_IFolder(iface);
267 FIXME("(%p)->(%p): stub\n", This, size);
271 static HRESULT WINAPI folder_get_SubFolders(IFolder *iface, IFolderCollection **folders)
273 struct folder *This = impl_from_IFolder(iface);
274 FIXME("(%p)->(%p): stub\n", This, folders);
278 static HRESULT WINAPI folder_get_Files(IFolder *iface, IFileCollection **files)
280 struct folder *This = impl_from_IFolder(iface);
281 FIXME("(%p)->(%p): stub\n", This, files);
285 static HRESULT WINAPI folder_CreateTextFile(IFolder *iface, BSTR filename, VARIANT_BOOL overwrite,
286 VARIANT_BOOL unicode, ITextStream **stream)
288 struct folder *This = impl_from_IFolder(iface);
289 FIXME("(%p)->(%s %x %x %p): stub\n", This, debugstr_w(filename), overwrite, unicode, stream);
293 static const IFolderVtbl foldervtbl = {
294 folder_QueryInterface,
297 folder_GetTypeInfoCount,
299 folder_GetIDsOfNames,
304 folder_get_ShortPath,
305 folder_get_ShortName,
307 folder_get_ParentFolder,
308 folder_get_Attributes,
309 folder_put_Attributes,
310 folder_get_DateCreated,
311 folder_get_DateLastModified,
312 folder_get_DateLastAccessed,
317 folder_get_IsRootFolder,
319 folder_get_SubFolders,
321 folder_CreateTextFile
324 static HRESULT create_folder(IFolder **folder)
328 This = heap_alloc(sizeof(struct folder));
329 if (!This) return E_OUTOFMEMORY;
331 This->IFolder_iface.lpVtbl = &foldervtbl;
334 *folder = &This->IFolder_iface;
339 static HRESULT WINAPI filesys_QueryInterface(IFileSystem3 *iface, REFIID riid, void **ppvObject)
341 TRACE("%p %s %p\n", iface, debugstr_guid(riid), ppvObject);
343 if ( IsEqualGUID( riid, &IID_IFileSystem3 ) ||
344 IsEqualGUID( riid, &IID_IFileSystem ) ||
345 IsEqualGUID( riid, &IID_IDispatch ) ||
346 IsEqualGUID( riid, &IID_IUnknown ) )
350 else if ( IsEqualGUID( riid, &IID_IDispatchEx ))
352 TRACE("Interface IDispatchEx not supported - returning NULL\n");
354 return E_NOINTERFACE;
356 else if ( IsEqualGUID( riid, &IID_IObjectWithSite ))
358 TRACE("Interface IObjectWithSite not supported - returning NULL\n");
360 return E_NOINTERFACE;
364 FIXME("Unsupported interface %s\n", debugstr_guid(riid));
365 return E_NOINTERFACE;
368 IFileSystem3_AddRef(iface);
373 static ULONG WINAPI filesys_AddRef(IFileSystem3 *iface)
375 TRACE("%p\n", iface);
380 static ULONG WINAPI filesys_Release(IFileSystem3 *iface)
382 TRACE("%p\n", iface);
387 static HRESULT WINAPI filesys_GetTypeInfoCount(IFileSystem3 *iface, UINT *pctinfo)
389 TRACE("(%p)->(%p)\n", iface, pctinfo);
395 static HRESULT WINAPI filesys_GetTypeInfo(IFileSystem3 *iface, UINT iTInfo,
396 LCID lcid, ITypeInfo **ppTInfo)
398 TRACE("(%p)->(%u %u %p)\n", iface, iTInfo, lcid, ppTInfo);
399 return get_typeinfo(IFileSystem3_tid, ppTInfo);
402 static HRESULT WINAPI filesys_GetIDsOfNames(IFileSystem3 *iface, REFIID riid,
403 LPOLESTR *rgszNames, UINT cNames,
404 LCID lcid, DISPID *rgDispId)
409 TRACE("(%p)->(%s %p %u %u %p)\n", iface, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
411 hr = get_typeinfo(IFileSystem3_tid, &typeinfo);
414 hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
415 ITypeInfo_Release(typeinfo);
421 static HRESULT WINAPI filesys_Invoke(IFileSystem3 *iface, DISPID dispIdMember,
422 REFIID riid, LCID lcid, WORD wFlags,
423 DISPPARAMS *pDispParams, VARIANT *pVarResult,
424 EXCEPINFO *pExcepInfo, UINT *puArgErr)
429 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", iface, dispIdMember, debugstr_guid(riid),
430 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
432 hr = get_typeinfo(IFileSystem3_tid, &typeinfo);
435 hr = ITypeInfo_Invoke(typeinfo, iface, dispIdMember, wFlags,
436 pDispParams, pVarResult, pExcepInfo, puArgErr);
437 ITypeInfo_Release(typeinfo);
443 static HRESULT WINAPI filesys_get_Drives(IFileSystem3 *iface, IDriveCollection **ppdrives)
445 FIXME("%p %p\n", iface, ppdrives);
450 static HRESULT WINAPI filesys_BuildPath(IFileSystem3 *iface, BSTR Path,
451 BSTR Name, BSTR *pbstrResult)
453 FIXME("%p %s %s %p\n", iface, debugstr_w(Path), debugstr_w(Name), pbstrResult);
458 static HRESULT WINAPI filesys_GetDriveName(IFileSystem3 *iface, BSTR Path,
461 FIXME("%p %s %p\n", iface, debugstr_w(Path), pbstrResult);
466 static HRESULT WINAPI filesys_GetParentFolderName(IFileSystem3 *iface, BSTR Path,
469 FIXME("%p %s %p\n", iface, debugstr_w(Path), pbstrResult);
474 static HRESULT WINAPI filesys_GetFileName(IFileSystem3 *iface, BSTR Path,
477 FIXME("%p %s %p\n", iface, debugstr_w(Path), pbstrResult);
482 static HRESULT WINAPI filesys_GetBaseName(IFileSystem3 *iface, BSTR Path,
485 FIXME("%p %s %p\n", iface, debugstr_w(Path), pbstrResult);
490 static HRESULT WINAPI filesys_GetExtensionName(IFileSystem3 *iface, BSTR Path,
493 FIXME("%p %s %p\n", iface, debugstr_w(Path), pbstrResult);
498 static HRESULT WINAPI filesys_GetAbsolutePathName(IFileSystem3 *iface, BSTR Path,
501 FIXME("%p %s %p\n", iface, debugstr_w(Path), pbstrResult);
506 static HRESULT WINAPI filesys_GetTempName(IFileSystem3 *iface, BSTR *pbstrResult)
508 FIXME("%p %p\n", iface, pbstrResult);
513 static HRESULT WINAPI filesys_DriveExists(IFileSystem3 *iface, BSTR DriveSpec,
514 VARIANT_BOOL *pfExists)
516 FIXME("%p %s %p\n", iface, debugstr_w(DriveSpec), pfExists);
521 static HRESULT WINAPI filesys_FileExists(IFileSystem3 *iface, BSTR path, VARIANT_BOOL *ret)
524 TRACE("%p %s %p\n", iface, debugstr_w(path), ret);
526 if (!ret) return E_POINTER;
528 attrs = GetFileAttributesW(path);
529 *ret = attrs != INVALID_FILE_ATTRIBUTES && !(attrs & FILE_ATTRIBUTE_DIRECTORY) ? VARIANT_TRUE : VARIANT_FALSE;
533 static HRESULT WINAPI filesys_FolderExists(IFileSystem3 *iface, BSTR path, VARIANT_BOOL *ret)
536 TRACE("%p %s %p\n", iface, debugstr_w(path), ret);
538 if (!ret) return E_POINTER;
540 attrs = GetFileAttributesW(path);
541 *ret = attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY) ? VARIANT_TRUE : VARIANT_FALSE;
546 static HRESULT WINAPI filesys_GetDrive(IFileSystem3 *iface, BSTR DriveSpec,
549 FIXME("%p %s %p\n", iface, debugstr_w(DriveSpec), ppdrive);
554 static HRESULT WINAPI filesys_GetFile(IFileSystem3 *iface, BSTR FilePath,
557 FIXME("%p %s %p\n", iface, debugstr_w(FilePath), ppfile);
562 static HRESULT WINAPI filesys_GetFolder(IFileSystem3 *iface, BSTR FolderPath,
565 FIXME("%p %s %p\n", iface, debugstr_w(FolderPath), ppfolder);
570 static HRESULT WINAPI filesys_GetSpecialFolder(IFileSystem3 *iface,
571 SpecialFolderConst SpecialFolder,
574 FIXME("%p %d %p\n", iface, SpecialFolder, ppfolder);
579 static HRESULT WINAPI filesys_DeleteFile(IFileSystem3 *iface, BSTR FileSpec,
582 FIXME("%p %s %d\n", iface, debugstr_w(FileSpec), Force);
587 static HRESULT WINAPI filesys_DeleteFolder(IFileSystem3 *iface, BSTR FolderSpec,
590 FIXME("%p %s %d\n", iface, debugstr_w(FolderSpec), Force);
595 static HRESULT WINAPI filesys_MoveFile(IFileSystem3 *iface, BSTR Source,
598 FIXME("%p %s %s\n", iface, debugstr_w(Source), debugstr_w(Destination));
603 static HRESULT WINAPI filesys_MoveFolder(IFileSystem3 *iface,BSTR Source,
606 FIXME("%p %s %s\n", iface, debugstr_w(Source), debugstr_w(Destination));
611 static HRESULT WINAPI filesys_CopyFile(IFileSystem3 *iface, BSTR Source,
612 BSTR Destination, VARIANT_BOOL OverWriteFiles)
614 FIXME("%p %s %s %d\n", iface, debugstr_w(Source), debugstr_w(Destination), OverWriteFiles);
619 static HRESULT WINAPI filesys_CopyFolder(IFileSystem3 *iface, BSTR Source,
620 BSTR Destination, VARIANT_BOOL OverWriteFiles)
622 FIXME("%p %s %s %d\n", iface, debugstr_w(Source), debugstr_w(Destination), OverWriteFiles);
627 static HRESULT WINAPI filesys_CreateFolder(IFileSystem3 *iface, BSTR path,
632 TRACE("(%p)->(%s %p)\n", iface, debugstr_w(path), folder);
634 ret = CreateDirectoryW(path, NULL);
638 if (GetLastError() == ERROR_ALREADY_EXISTS) return CTL_E_FILEALREADYEXISTS;
639 return HRESULT_FROM_WIN32(GetLastError());
642 return create_folder(folder);
645 static HRESULT WINAPI filesys_CreateTextFile(IFileSystem3 *iface, BSTR FileName,
646 VARIANT_BOOL Overwrite, VARIANT_BOOL Unicode,
649 FIXME("%p %s %d %d %p\n", iface, debugstr_w(FileName), Overwrite, Unicode, ppts);
654 static HRESULT WINAPI filesys_OpenTextFile(IFileSystem3 *iface, BSTR FileName,
655 IOMode IOMode, VARIANT_BOOL Create,
656 Tristate Format, ITextStream **ppts)
658 FIXME("%p %s %d %d %d %p\n", iface, debugstr_w(FileName), IOMode, Create, Format, ppts);
663 static HRESULT WINAPI filesys_GetStandardStream(IFileSystem3 *iface,
664 StandardStreamTypes StandardStreamType,
665 VARIANT_BOOL Unicode,
668 FIXME("%p %d %d %p\n", iface, StandardStreamType, Unicode, ppts);
673 static HRESULT WINAPI filesys_GetFileVersion(IFileSystem3 *iface, BSTR FileName,
676 FIXME("%p %s %p\n", iface, debugstr_w(FileName), FileVersion);
681 static const struct IFileSystem3Vtbl filesys_vtbl =
683 filesys_QueryInterface,
686 filesys_GetTypeInfoCount,
688 filesys_GetIDsOfNames,
692 filesys_GetDriveName,
693 filesys_GetParentFolderName,
696 filesys_GetExtensionName,
697 filesys_GetAbsolutePathName,
701 filesys_FolderExists,
705 filesys_GetSpecialFolder,
707 filesys_DeleteFolder,
712 filesys_CreateFolder,
713 filesys_CreateTextFile,
714 filesys_OpenTextFile,
715 filesys_GetStandardStream,
716 filesys_GetFileVersion
719 static IFileSystem3 filesystem = { &filesys_vtbl };
721 HRESULT WINAPI FileSystem_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **ppv)
723 TRACE("(%p %s %p)\n", outer, debugstr_guid(riid), ppv);
725 return IFileSystem3_QueryInterface(&filesystem, riid, ppv);