Alistair Leslie-Hughes : scrrun: Correct FileExists for directories.

Alexandre Julliard julliard at winehq.org
Thu Aug 16 15:26:13 CDT 2012


Module: wine
Branch: master
Commit: 50fe9b87eda4de4aa2f03172f6e0f83ec89a93dd
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=50fe9b87eda4de4aa2f03172f6e0f83ec89a93dd

Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date:   Mon Aug  6 08:38:17 2012 +1000

scrrun: Correct FileExists for directories.

---

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

diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c
index a4e6f26..ade3310 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);




More information about the wine-cvs mailing list