[5/8] scrrun: Implement IFileSystem3 FileExists

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Tue Mar 27 04:42:12 CDT 2012


Hi,


Changelog:
     scrrun: Implement IFileSystem3 FileExists


Best Regards
  Alistair Leslie-Hughes
-------------- next part --------------
>From d890cad3c756375eba92805a2e12423e90a2e7bf Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Mon, 26 Mar 2012 12:20:29 +1100
Subject: [PATCH] Implement IFileSystem3 FileExists
To: wine-patches <wine-patches at winehq.org>

---
 dlls/scrrun/Makefile.in        |    2 +-
 dlls/scrrun/filesystem.c       |   10 +++++++-
 dlls/scrrun/tests/Makefile.in  |    2 +-
 dlls/scrrun/tests/filesystem.c |   44 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 54 insertions(+), 4 deletions(-)

diff --git a/dlls/scrrun/Makefile.in b/dlls/scrrun/Makefile.in
index f65f052..57ebc6a 100644
--- a/dlls/scrrun/Makefile.in
+++ b/dlls/scrrun/Makefile.in
@@ -1,5 +1,5 @@
 MODULE    = scrrun.dll
-IMPORTS   = uuid
+IMPORTS   = uuid shlwapi
 
 C_SRCS = \
 	filesystem.c \
diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c
index 0228886..98496c0 100644
--- a/dlls/scrrun/filesystem.c
+++ b/dlls/scrrun/filesystem.c
@@ -25,6 +25,7 @@
 #include "winbase.h"
 #include "ole2.h"
 #include "dispex.h"
+#include "shlwapi.h"
 #include "scrrun.h"
 
 #include "wine/debug.h"
@@ -251,9 +252,14 @@ static HRESULT WINAPI filesys_FileExists(IFileSystem3 *iface, BSTR FileSpec,
 {
     FileSystem *This = impl_from_IFileSystem3(iface);
 
-    FIXME("%p %s %p\n", This, debugstr_w(FileSpec), pfExists);
+    TRACE("%p %s %p\n", This, debugstr_w(FileSpec), pfExists);
 
-    return E_NOTIMPL;
+    if(!pfExists)
+        return E_POINTER;
+
+    *pfExists = PathFileExistsW(FileSpec) ? VARIANT_TRUE : VARIANT_FALSE;
+
+    return S_OK;
 }
 
 static HRESULT WINAPI filesys_FolderExists(IFileSystem3 *iface, BSTR FolderSpec,
diff --git a/dlls/scrrun/tests/Makefile.in b/dlls/scrrun/tests/Makefile.in
index 44cef8a..326eb1a 100644
--- a/dlls/scrrun/tests/Makefile.in
+++ b/dlls/scrrun/tests/Makefile.in
@@ -1,5 +1,5 @@
 TESTDLL   = scrrun.dll
-IMPORTS   = ole32 shlwapi uuid
+IMPORTS   = ole32 shlwapi uuid oleaut32
 
 C_SRCS = \
 	filesystem.c
diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c
index b86c43c..f97bcb6 100644
--- a/dlls/scrrun/tests/filesystem.c
+++ b/dlls/scrrun/tests/filesystem.c
@@ -57,11 +57,55 @@ void test_interfaces(void)
     IDispatch_Release(disp);
 }
 
+void test_exists(void)
+{
+    HRESULT hr;
+    IDispatch *disp;
+    IFileSystem3 *fs3;
+    VARIANT_BOOL exists;
+    BSTR str;
+    static const WCHAR nonexistent_fileW[] = {
+        'c', ':', '\\', 'N', 'o', 'n', 'e', 'x', 'i', 's', 't', 'e', 'n', 't', '.', 'w', 'i', 'n', 0};
+    static const WCHAR existing_fileW[] = {
+        'c', ':', '\\', 'W', 'i', 'n', 'd', 'o', 'w', 's', '\\', 's', 'y', 's', 't', 'e', 'm', '3',
+        '2', '\\', 'n', 't', 'd', 'l', 'l', '.', 'd', 'l', 'l', 0};
+
+    hr = CoCreateInstance(&CLSID_FileSystemObject, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
+            &IID_IDispatch, (void**)&disp);
+    if(FAILED(hr)) {
+        win_skip("Could not create FileSystem object: %08x\n", hr);
+        return;
+    }
+
+    hr = IDispatch_QueryInterface(disp, &IID_IFileSystem3, (void**)&fs3);
+    ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
+
+    /* File Exists */
+    hr = IFileSystem3_FileExists(fs3, NULL, NULL);
+    ok(hr == E_POINTER, "got 0x%08x, expected 0x%08x\n", hr, E_POINTER);
+
+    str = SysAllocString(existing_fileW);
+    hr = IFileSystem3_FileExists(fs3, str, &exists);
+    ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
+    ok(exists == VARIANT_TRUE, "File doesn't exists\n");
+    SysFreeString(str);
+
+    str = SysAllocString(nonexistent_fileW);
+    hr = IFileSystem3_FileExists(fs3, str, &exists);
+    ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
+    ok(exists == VARIANT_FALSE, "File exists\n");
+    SysFreeString(str);
+
+    IFileSystem3_Release(fs3);
+    IDispatch_Release(disp);
+}
+
 START_TEST(filesystem)
 {
     CoInitialize(NULL);
 
     test_interfaces();
+    test_exists();
 
 
     CoUninitialize();
-- 
1.7.5.4



More information about the wine-patches mailing list