Mariusz Pluciński : shell32: Check for known folder existance.
Alexandre Julliard
julliard at winehq.org
Fri Jul 1 14:11:04 CDT 2011
Module: wine
Branch: master
Commit: 08186a9c26e954aea26ad0129cae35f24f18054e
URL: http://source.winehq.org/git/wine.git/?a=commit;h=08186a9c26e954aea26ad0129cae35f24f18054e
Author: Mariusz Pluciński <vshader at gmail.com>
Date: Thu Jun 30 14:59:46 2011 +0200
shell32: Check for known folder existance.
---
dlls/shell32/shellpath.c | 11 +++++++++++
dlls/shell32/tests/shellpath.c | 8 ++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/dlls/shell32/shellpath.c b/dlls/shell32/shellpath.c
index 598122f..017f101 100644
--- a/dlls/shell32/shellpath.c
+++ b/dlls/shell32/shellpath.c
@@ -3435,6 +3435,7 @@ static HRESULT WINAPI knownfolder_GetPath(
struct knownfolder *knownfolder = impl_from_IKnownFolder( iface );
HRESULT hr;
WCHAR sGuid[39];
+ DWORD dwAttributes;
TRACE("(%p, 0x%08x, %p)\n", knownfolder, dwFlags, ppszPath);
@@ -3449,6 +3450,16 @@ static HRESULT WINAPI knownfolder_GetPath(
else
hr = SHGetKnownFolderPath( &knownfolder->id, dwFlags, NULL, ppszPath );
+ /* check if known folder really exists */
+ dwAttributes = GetFileAttributesW(*ppszPath);
+ if(dwAttributes == INVALID_FILE_ATTRIBUTES || !(dwAttributes & FILE_ATTRIBUTE_DIRECTORY) )
+ {
+ TRACE("directory %s not found\n", debugstr_w(*ppszPath));
+ CoTaskMemFree(*ppszPath);
+ *ppszPath = NULL;
+ hr = HRESULT_FROM_WIN32(ERROR_FILE_NOT_FOUND);
+ }
+
return hr;
}
diff --git a/dlls/shell32/tests/shellpath.c b/dlls/shell32/tests/shellpath.c
index 932aa0e..8cdae30 100644
--- a/dlls/shell32/tests/shellpath.c
+++ b/dlls/shell32/tests/shellpath.c
@@ -1242,9 +1242,7 @@ static void test_knownFolders(void)
/* 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);
@@ -1279,7 +1277,9 @@ static void test_knownFolders(void)
/* verify sub folder. It still succeedes, so Windows does not check folder presence each time */
hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
+ todo_wine
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);
@@ -1354,7 +1354,9 @@ static void test_knownFolders(void)
/* verify sub folder */
hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
+ todo_wine
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);
@@ -1391,7 +1393,9 @@ static void test_knownFolders(void)
/* verify sub folder */
hr = IKnownFolder_GetPath(subFolder, 0, &folderPath);
+ todo_wine
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);
More information about the wine-cvs
mailing list