diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c index 2753ecc6348..12545322cb8 100644 --- a/dlls/scrrun/filesystem.c +++ b/dlls/scrrun/filesystem.c @@ -1410,11 +1410,24 @@ static HRESULT WINAPI filesys_GetFile(IFileSystem3 *iface, BSTR FilePath, } static HRESULT WINAPI filesys_GetFolder(IFileSystem3 *iface, BSTR FolderPath, - IFolder **ppfolder) + IFolder **folder) { - FIXME("%p %s %p\n", iface, debugstr_w(FolderPath), ppfolder); + DWORD attrs; - return E_NOTIMPL; + TRACE("%p %s %p\n", iface, debugstr_w(FolderPath), folder); + + if(!folder) + return E_POINTER; + + *folder = NULL; + if(!FolderPath) + return E_INVALIDARG; + + attrs = GetFileAttributesW(FolderPath); + if((attrs == INVALID_FILE_ATTRIBUTES) || !(attrs & FILE_ATTRIBUTE_DIRECTORY)) + return CTL_E_PATHNOTFOUND; + + return create_folder(FolderPath, folder); } static HRESULT WINAPI filesys_GetSpecialFolder(IFileSystem3 *iface, diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c index ba0ff37feb1..a6c5980aae3 100644 --- a/dlls/scrrun/tests/filesystem.c +++ b/dlls/scrrun/tests/filesystem.c @@ -739,6 +739,42 @@ static void test_BuildPath(void) } } +static void test_GetFolder(void) +{ + static const WCHAR dummyW[] = {'d','u','m','m','y',0}; + WCHAR buffW[MAX_PATH]; + IFolder *folder; + HRESULT hr; + BSTR str; + + folder = (void*)0xdeadbeef; + hr = IFileSystem3_GetFolder(fs3, NULL, &folder); + ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + ok(folder == NULL, "got %p\n", folder); + + hr = IFileSystem3_GetFolder(fs3, NULL, NULL); + ok(hr == E_POINTER, "got 0x%08x\n", hr); + + /* something that doesn't exist */ + str = SysAllocString(dummyW); + + hr = IFileSystem3_GetFolder(fs3, str, NULL); + ok(hr == E_POINTER, "got 0x%08x\n", hr); + + folder = (void*)0xdeadbeef; + hr = IFileSystem3_GetFolder(fs3, str, &folder); + ok(hr == CTL_E_PATHNOTFOUND, "got 0x%08x\n", hr); + ok(folder == NULL, "got %p\n", folder); + SysFreeString(str); + + GetWindowsDirectoryW(buffW, MAX_PATH); + str = SysAllocString(buffW); + hr = IFileSystem3_GetFolder(fs3, str, &folder); + ok(hr == S_OK, "got 0x%08x\n", hr); + SysFreeString(str); + IFolder_Release(folder); +} + START_TEST(filesystem) { HRESULT hr; @@ -763,6 +799,7 @@ START_TEST(filesystem) test_GetFile(); test_CopyFolder(); test_BuildPath(); + test_GetFolder(); IFileSystem3_Release(fs3);