scrrun: Implement IFileSystem3 FolderExists (try 2)
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Sat Aug 4 04:12:22 CDT 2012
Hi,
Changelog:
scrrun: Implement IFileSystem3 FolderExists
Best Regards
Alistair Leslie-Hughes
-------------- next part --------------
>From 174ffe81bbe0d2ba5acdab0a02a22fac4039d291 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Mon, 30 Jul 2012 09:02:39 +1000
Subject: [PATCH] Implement IFileSystem3 FolderExists
To: wine-patches <wine-patches at winehq.org>
---
dlls/scrrun/filesystem.c | 13 +++++++++----
dlls/scrrun/tests/filesystem.c | 32 ++++++++++++++++++++++++++++++++
2 files changed, 41 insertions(+), 4 deletions(-)
diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c
index 5c8fb7d..a4e6f26 100644
--- a/dlls/scrrun/filesystem.c
+++ b/dlls/scrrun/filesystem.c
@@ -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,
diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c
index ff1856e..a19a835 100644
--- a/dlls/scrrun/tests/filesystem.c
+++ b/dlls/scrrun/tests/filesystem.c
@@ -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);
}
--
1.7.9.5
More information about the wine-patches
mailing list