scrrun: Correct FileExists for directories.

This commit is contained in:
Alistair Leslie-Hughes 2012-08-06 08:38:17 +10:00 committed by Alexandre Julliard
parent 3d845b1242
commit 50fe9b87ed
2 changed files with 17 additions and 1 deletions

View File

@ -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;
}

View File

@ -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);