Commit e6d9f824 authored by Alistair Leslie-Hughes's avatar Alistair Leslie-Hughes Committed by Alexandre Julliard

scrrun: Implement IFileSystem3 FolderExists.

parent dcc09efe
......@@ -223,12 +223,17 @@ static HRESULT WINAPI filesys_FileExists(IFileSystem3 *iface, BSTR path, VARIANT
return S_OK;
}
static HRESULT WINAPI filesys_FolderExists(IFileSystem3 *iface, BSTR FolderSpec,
VARIANT_BOOL *pfExists)
static HRESULT WINAPI filesys_FolderExists(IFileSystem3 *iface, BSTR path, VARIANT_BOOL *ret)
{
FIXME("%p %s %p\n", iface, debugstr_w(FolderSpec), pfExists);
DWORD attrs;
TRACE("%p %s %p\n", iface, debugstr_w(path), ret);
return E_NOTIMPL;
if (!ret) return E_POINTER;
attrs = GetFileAttributesW(path);
*ret = attrs != INVALID_FILE_ATTRIBUTES && (attrs & FILE_ATTRIBUTE_DIRECTORY) ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
static HRESULT WINAPI filesys_GetDrive(IFileSystem3 *iface, BSTR DriveSpec,
......
......@@ -33,6 +33,10 @@
static void test_interfaces(void)
{
static const WCHAR pathW[] = {'p','a','t','h',0};
static const WCHAR nonexistent_dirW[] = {
'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', 0};
static const WCHAR file_kernel32W[] = {
'\\', 'k', 'e', 'r', 'n', 'e', 'l', '3', '2', '.', 'd', 'l', 'l', 0};
HRESULT hr;
IDispatch *disp;
IDispatchEx *dispex;
......@@ -40,6 +44,8 @@ static void test_interfaces(void)
IObjectWithSite *site;
VARIANT_BOOL b;
BSTR path;
WCHAR windows_path[MAX_PATH];
WCHAR file_path[MAX_PATH];
hr = CoCreateInstance(&CLSID_FileSystemObject, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
&IID_IDispatch, (void**)&disp);
......@@ -48,6 +54,10 @@ static void test_interfaces(void)
return;
}
GetSystemDirectoryW(windows_path, MAX_PATH);
lstrcpyW(file_path, windows_path);
lstrcatW(file_path, file_kernel32W);
hr = IDispatch_QueryInterface(disp, &IID_IFileSystem3, (void**)&fs3);
ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
......@@ -72,6 +82,28 @@ static void test_interfaces(void)
ok(b == VARIANT_FALSE, "got %x\n", b);
SysFreeString(path);
/* Folder Exists */
hr = IFileSystem3_FolderExists(fs3, NULL, NULL);
ok(hr == E_POINTER, "got 0x%08x, expected 0x%08x\n", hr, E_POINTER);
path = SysAllocString(windows_path);
hr = IFileSystem3_FolderExists(fs3, path, &b);
ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
ok(b == VARIANT_TRUE, "Folder doesn't exists\n");
SysFreeString(path);
path = SysAllocString(nonexistent_dirW);
hr = IFileSystem3_FolderExists(fs3, path, &b);
ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
ok(b == VARIANT_FALSE, "Folder exists\n");
SysFreeString(path);
path = SysAllocString(file_path);
hr = IFileSystem3_FolderExists(fs3, path, &b);
ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
ok(b == VARIANT_FALSE, "Folder exists\n");
SysFreeString(path);
IFileSystem3_Release(fs3);
IDispatch_Release(disp);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment