Commit 533323d7 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

scrrun: Implement GetSpecialFolder().

parent 01c2af44
......@@ -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)
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment