Module: wine Branch: master Commit: 533323d70397a53a2ce5002dc2038bcf5f122344 URL: http://source.winehq.org/git/wine.git/?a=commit;h=533323d70397a53a2ce5002dc2...
Author: Nikolay Sivov nsivov@codeweavers.com Date: Mon Apr 6 12:50:23 2015 +0300
scrrun: Implement GetSpecialFolder().
---
dlls/scrrun/filesystem.c | 36 ++++++++++++++++++++++++++++--- dlls/scrrun/tests/filesystem.c | 49 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 3 deletions(-)
diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c index 5e0fc28..8b771c7 100644 --- a/dlls/scrrun/filesystem.c +++ b/dlls/scrrun/filesystem.c @@ -3285,11 +3285,41 @@ static HRESULT WINAPI filesys_GetFolder(IFileSystem3 *iface, BSTR FolderPath,
static HRESULT WINAPI filesys_GetSpecialFolder(IFileSystem3 *iface, SpecialFolderConst SpecialFolder, - IFolder **ppfolder) + IFolder **folder) { - FIXME("%p %d %p\n", iface, SpecialFolder, ppfolder); + WCHAR pathW[MAX_PATH]; + DWORD ret;
- return E_NOTIMPL; + TRACE("%p %d %p\n", iface, SpecialFolder, folder); + + if (!folder) + return E_POINTER; + + *folder = NULL; + + switch (SpecialFolder) + { + case WindowsFolder: + ret = GetWindowsDirectoryW(pathW, sizeof(pathW)/sizeof(WCHAR)); + break; + case SystemFolder: + ret = GetSystemDirectoryW(pathW, sizeof(pathW)/sizeof(WCHAR)); + break; + case TemporaryFolder: + ret = GetTempPathW(sizeof(pathW)/sizeof(WCHAR), pathW); + /* we don't want trailing backslash */ + if (ret && pathW[ret-1] == '\') + pathW[ret-1] = 0; + break; + default: + FIXME("unknown special folder type, %d\n", SpecialFolder); + return E_INVALIDARG; + } + + if (!ret) + return HRESULT_FROM_WIN32(GetLastError()); + + return create_folder(pathW, folder); }
static inline HRESULT delete_file(const WCHAR *file, DWORD file_len, VARIANT_BOOL force) diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c index 987ecba..db7c338 100644 --- a/dlls/scrrun/tests/filesystem.c +++ b/dlls/scrrun/tests/filesystem.c @@ -1907,6 +1907,54 @@ static void test_GetExtensionName(void) } }
+static void test_GetSpecialFolder(void) +{ + WCHAR pathW[MAX_PATH]; + IFolder *folder; + HRESULT hr; + DWORD ret; + BSTR path; + + hr = IFileSystem3_GetSpecialFolder(fs3, WindowsFolder, NULL); + ok(hr == E_POINTER, "got 0x%08x\n", hr); + + hr = IFileSystem3_GetSpecialFolder(fs3, TemporaryFolder+1, NULL); + ok(hr == E_POINTER, "got 0x%08x\n", hr); + + hr = IFileSystem3_GetSpecialFolder(fs3, TemporaryFolder+1, &folder); + ok(hr == E_INVALIDARG, "got 0x%08x\n", hr); + + hr = IFileSystem3_GetSpecialFolder(fs3, WindowsFolder, &folder); + ok(hr == S_OK, "got 0x%08x\n", hr); + hr = IFolder_get_Path(folder, &path); + ok(hr == S_OK, "got 0x%08x\n", hr); + GetWindowsDirectoryW(pathW, sizeof(pathW)/sizeof(WCHAR)); + ok(!lstrcmpiW(pathW, path), "got %s, expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(pathW)); + SysFreeString(path); + IFolder_Release(folder); + + hr = IFileSystem3_GetSpecialFolder(fs3, SystemFolder, &folder); + ok(hr == S_OK, "got 0x%08x\n", hr); + hr = IFolder_get_Path(folder, &path); + ok(hr == S_OK, "got 0x%08x\n", hr); + GetSystemDirectoryW(pathW, sizeof(pathW)/sizeof(WCHAR)); + ok(!lstrcmpiW(pathW, path), "got %s, expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(pathW)); + SysFreeString(path); + IFolder_Release(folder); + + hr = IFileSystem3_GetSpecialFolder(fs3, TemporaryFolder, &folder); + ok(hr == S_OK, "got 0x%08x\n", hr); + hr = IFolder_get_Path(folder, &path); + ok(hr == S_OK, "got 0x%08x\n", hr); + ret = GetTempPathW(sizeof(pathW)/sizeof(WCHAR), pathW); + if (ret && pathW[ret-1] == '\') + pathW[ret-1] = 0; + + ok(!lstrcmpiW(pathW, path), "got %s, expected %s\n", wine_dbgstr_w(path), wine_dbgstr_w(pathW)); + SysFreeString(path); + IFolder_Release(folder); +} + START_TEST(filesystem) { HRESULT hr; @@ -1942,6 +1990,7 @@ START_TEST(filesystem) test_GetDriveName(); test_SerialNumber(); test_GetExtensionName(); + test_GetSpecialFolder();
IFileSystem3_Release(fs3);