ok(hr==S_OK,"failed to get path from known folder: 0x%08x\n",hr);
ok(lstrcmpiW(folderPath,sExamplePath)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sExamplePath));
CoTaskMemFree(folderPath);
/* try to set new path for folder */
hr=IKnownFolder_SetPath(folder,0,sExample2Path);
ok(hr==S_OK,"setting path failed: 0x%0x\n",hr);
/* verify modified path */
hr=IKnownFolder_GetPath(folder,0,&folderPath);
ok(hr==S_OK,"failed to get path from known folder: 0x%08x\n",hr);
ok(lstrcmpiW(folderPath,sExample2Path)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sExamplePath));
CoTaskMemFree(folderPath);
/* set again to first path, but use another way */
ok(hr==S_OK,"failed to get path from known folder: 0x%08x\n",hr);
todo_wine
ok(lstrcmpiW(folderPath,sExamplePath)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sExamplePath));
ok(hr==S_OK,"failed to get known folder: 0x%08x\n",hr);
if(SUCCEEDED(hr))
{
/* check sub folder path */
hr=IKnownFolder_GetPath(subFolder,0,&folderPath);
ok(hr==S_OK,"failed to get known folder path: 0x%08x\n",hr);
todo_wine
ok(lstrcmpiW(folderPath,sSubFolderPath)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sSubFolderPath));
ok(hr==S_OK,"failed to redirect known folder: 0x%08x, errorMsg: %s\n",hr,wine_dbgstr_w(errorMsg));
/* verify */
hr=IKnownFolder_GetPath(folder,0,&folderPath);
ok(hr==S_OK,"failed to get known folder path: 0x%08x\n",hr);
todo_wine
ok(lstrcmpiW(folderPath,sExample2Path)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sExample2Path));
CoTaskMemFree(folderPath);
/* verify sub folder - it should fail now, as we redirected it's parent folder, but we have no sub folder in new location */
hr=IKnownFolder_GetPath(subFolder,0,&folderPath);
todo_wine
ok(hr==HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND),"unexpected value from GetPath(): 0x%08x\n",hr);
todo_wine
ok(folderPath==NULL,"invalid known folder path retrieved: \"%s\" when NULL pointer was expected\n",wine_dbgstr_w(folderPath));
CoTaskMemFree(folderPath);
/* set Example path to original. Using SetPath() is valid here, as it also uses redirection internally */
hr=IKnownFolder_SetPath(folder,0,sExamplePath);
ok(hr==S_OK,"SetPath() failed: 0x%08x\n",hr);
/* verify */
hr=IKnownFolder_GetPath(folder,0,&folderPath);
ok(hr==S_OK,"failed to get known folder path: 0x%08x\n",hr);
ok(lstrcmpiW(folderPath,sExamplePath)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sExamplePath));
CoTaskMemFree(folderPath);
/* create sub folder in Temp\Example2 */
bRes=CreateDirectoryW(sSubFolder2Path,NULL);
ok(bRes,"cannot create example directory: %s\n",wine_dbgstr_w(sSubFolder2Path));
ok(hr==S_OK,"failed to redirect known folder: 0x%08x, errorMsg: %s\n",hr,wine_dbgstr_w(errorMsg));
/* verify sub folder. It should succeed now, as the required sub folder exists */
hr=IKnownFolder_GetPath(subFolder,0,&folderPath);
ok(hr==S_OK,"failed to get known folder path: 0x%08x\n",hr);
todo_wine
ok(lstrcmpiW(folderPath,sSubFolder2Path)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sSubFolder2Path));
CoTaskMemFree(folderPath);
/* remove newly created directory */
RemoveDirectoryW(sSubFolder2Path);
/* verify sub folder. It still succeedes, so Windows does not check folder presence each time */
hr=IKnownFolder_GetPath(subFolder,0,&folderPath);
ok(hr==S_OK,"failed to get known folder path: 0x%08x\n",hr);
todo_wine
ok(lstrcmpiW(folderPath,sSubFolder2Path)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sSubFolder2Path));
CoTaskMemFree(folderPath);
/* set Example path to original */
hr=IKnownFolder_SetPath(folder,0,sExamplePath);
ok(hr==S_OK,"SetPath() failed: 0x%08x\n",hr);
/* verify */
hr=IKnownFolder_GetPath(folder,0,&folderPath);
ok(hr==S_OK,"failed to get known folder path: 0x%08x\n",hr);
ok(lstrcmpiW(folderPath,sExamplePath)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sExamplePath));
CoTaskMemFree(folderPath);
/* verify sub folder */
hr=IKnownFolder_GetPath(subFolder,0,&folderPath);
ok(hr==S_OK,"failed to get known folder path: 0x%08x\n",hr);
todo_wine
ok(lstrcmpiW(folderPath,sSubFolderPath)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sSubFolderPath));
CoTaskMemFree(folderPath);
/* create sub folder in Temp\Example2 */
bRes=CreateDirectoryW(sSubFolder2Path,NULL);
ok(bRes,"cannot create example directory: %s\n",wine_dbgstr_w(sSubFolder2Path));
/* do that same redirection, but try to exclude sub-folder */
ok(hr==S_OK,"failed to redirect known folder: 0x%08x, errorMsg: %s\n",hr,wine_dbgstr_w(errorMsg));
/* verify */
hr=IKnownFolder_GetPath(folder,0,&folderPath);
ok(hr==S_OK,"failed to get known folder path: 0x%08x\n",hr);
todo_wine
ok(lstrcmpiW(folderPath,sExample2Path)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sExample2Path));
CoTaskMemFree(folderPath);
/* verify sub folder. Unexpectedly, this path was also changed. So, exclusion seems to be ignored (Windows bug)? This test however will let us know, if this behavior is changed */
hr=IKnownFolder_GetPath(subFolder,0,&folderPath);
ok(hr==S_OK,"failed to get known folder path: 0x%08x\n",hr);
todo_wine
ok(lstrcmpiW(folderPath,sSubFolder2Path)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sSubFolder2Path));
CoTaskMemFree(folderPath);
/* remove newly created directory */
RemoveDirectoryW(sSubFolder2Path);
/* set Example path to original */
hr=IKnownFolder_SetPath(folder,0,sExamplePath);
ok(hr==S_OK,"SetPath() failed: 0x%08x\n",hr);
/* verify */
hr=IKnownFolder_GetPath(folder,0,&folderPath);
ok(hr==S_OK,"failed to get known folder path: 0x%08x\n",hr);
ok(lstrcmpiW(folderPath,sExamplePath)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sExamplePath));
CoTaskMemFree(folderPath);
/* verify sub folder */
hr=IKnownFolder_GetPath(subFolder,0,&folderPath);
ok(hr==S_OK,"failed to get known folder path: 0x%08x\n",hr);
todo_wine
ok(lstrcmpiW(folderPath,sSubFolderPath)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sSubFolderPath));
CoTaskMemFree(folderPath);
/* do that same redirection again, but set it to copy content. It should also copy the sub folder, so checking it would succeed now */
ok(hr==S_OK,"failed to redirect known folder: 0x%08x, errorMsg: %s\n",hr,wine_dbgstr_w(errorMsg));
/* verify */
hr=IKnownFolder_GetPath(folder,0,&folderPath);
ok(hr==S_OK,"failed to get known folder path: 0x%08x\n",hr);
todo_wine
ok(lstrcmpiW(folderPath,sExample2Path)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sExample2Path));
CoTaskMemFree(folderPath);
/* verify sub folder */
hr=IKnownFolder_GetPath(subFolder,0,&folderPath);
ok(hr==S_OK,"failed to get known folder path: 0x%08x\n",hr);
todo_wine
ok(lstrcmpiW(folderPath,sSubFolder2Path)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sSubFolder2Path));
CoTaskMemFree(folderPath);
/* remove copied directory */
RemoveDirectoryW(sSubFolder2Path);
/* set Example path to original */
hr=IKnownFolder_SetPath(folder,0,sExamplePath);
ok(hr==S_OK,"SetPath() failed: 0x%08x\n",hr);
/* verify */
hr=IKnownFolder_GetPath(folder,0,&folderPath);
ok(hr==S_OK,"failed to get known folder path: 0x%08x\n",hr);
ok(lstrcmpiW(folderPath,sExamplePath)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sExamplePath));
CoTaskMemFree(folderPath);
/* verify sub folder */
hr=IKnownFolder_GetPath(subFolder,0,&folderPath);
ok(hr==S_OK,"failed to get known folder path: 0x%08x\n",hr);
todo_wine
ok(lstrcmpiW(folderPath,sSubFolderPath)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sSubFolderPath));
CoTaskMemFree(folderPath);
/* redirect again, set it to copy content and remove originals */
ok(hr==S_OK,"failed to redirect known folder: 0x%08x, errorMsg: %s\n",hr,wine_dbgstr_w(errorMsg));
/* verify */
hr=IKnownFolder_GetPath(folder,0,&folderPath);
ok(hr==S_OK,"failed to get known folder path: 0x%08x\n",hr);
todo_wine
ok(lstrcmpiW(folderPath,sExample2Path)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sExample2Path));
CoTaskMemFree(folderPath);
/* verify sub folder */
hr=IKnownFolder_GetPath(subFolder,0,&folderPath);
ok(hr==S_OK,"failed to get known folder path: 0x%08x\n",hr);
todo_wine
ok(lstrcmpiW(folderPath,sSubFolder2Path)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sSubFolder2Path));
CoTaskMemFree(folderPath);
/* check if original directory was really removed */
dwAttributes=GetFileAttributesW(sExamplePath);
todo_wine
ok(dwAttributes==INVALID_FILE_ATTRIBUTES,"directory should not exist, but has attributes: 0x%08x\n",dwAttributes);
ok(hr==S_OK,"failed to redirect known folder: 0x%08x, errorMsg: %s\n",hr,wine_dbgstr_w(errorMsg));
/* verify */
hr=IKnownFolder_GetPath(folder,0,&folderPath);
ok(hr==S_OK,"failed to get known folder path: 0x%08x\n",hr);
ok(lstrcmpiW(folderPath,sExamplePath)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sExamplePath));
CoTaskMemFree(folderPath);
/* verify sub folder */
hr=IKnownFolder_GetPath(subFolder,0,&folderPath);
ok(hr==S_OK,"failed to get known folder path: 0x%08x\n",hr);
todo_wine
ok(lstrcmpiW(folderPath,sSubFolderPath)==0,"invalid known folder path retrieved: \"%s\" when \"%s\" was expected\n",wine_dbgstr_w(folderPath),wine_dbgstr_w(sSubFolderPath));