scrrun: Implement GetSpecialFolder().
This commit is contained in:
parent
01c2af446a
commit
533323d703
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue