scrrun: Correct FileExists

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Thu Aug 16 04:38:11 CDT 2012


Hi,


Changelog:
     scrrun: Correct FileExists


Best Regards
  Alistair Leslie-Hughes
-------------- next part --------------
>From 9b8da88a64968d1a6eb693898c1870ceec1253e9 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Mon, 6 Aug 2012 08:38:17 +1000
Subject: [PATCH] Correct FileExists
To: wine-patches <wine-patches at winehq.org>

---
 dlls/scrrun/filesystem.c       |    4 +++-
 dlls/scrrun/tests/filesystem.c |   14 ++++++++++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c
index a4e6f26..e381bf3 100644
--- a/dlls/scrrun/filesystem.c
+++ b/dlls/scrrun/filesystem.c
@@ -215,11 +215,13 @@ static HRESULT WINAPI filesys_DriveExists(IFileSystem3 *iface, BSTR DriveSpec,
 
 static HRESULT WINAPI filesys_FileExists(IFileSystem3 *iface, BSTR path, VARIANT_BOOL *ret)
 {
+    DWORD attrs;
     TRACE("%p %s %p\n", iface, debugstr_w(path), ret);
 
     if (!ret) return E_POINTER;
 
-    *ret = GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES ? VARIANT_TRUE : VARIANT_FALSE;
+    attrs = GetFileAttributesW(path);
+    *ret = attrs != INVALID_FILE_ATTRIBUTES && (attrs & ~FILE_ATTRIBUTE_DIRECTORY)? VARIANT_TRUE : VARIANT_FALSE;
     return S_OK;
 }
 
diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c
index a19a835..d557acf 100644
--- a/dlls/scrrun/tests/filesystem.c
+++ b/dlls/scrrun/tests/filesystem.c
@@ -82,6 +82,20 @@ static void test_interfaces(void)
     ok(b == VARIANT_FALSE, "got %x\n", b);
     SysFreeString(path);
 
+    path = SysAllocString(file_path);
+    b = VARIANT_FALSE;
+    hr = IFileSystem3_FileExists(fs3, path, &b);
+    ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
+    ok(b == VARIANT_TRUE, "got %x\n", b);
+    SysFreeString(path);
+
+    path = SysAllocString(windows_path);
+    b = VARIANT_TRUE;
+    hr = IFileSystem3_FileExists(fs3, path, &b);
+    ok(hr == S_OK, "got 0x%08x, expected 0x%08x\n", hr, S_OK);
+    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);
-- 
1.7.9.5



More information about the wine-patches mailing list