Commit dbb1ed48 authored by Dmitry Timoshkov's avatar Dmitry Timoshkov Committed by Alexandre Julliard

shell32: IPersistFile::Save(NULL) should use previously stored file name.

parent 3f2e572d
......@@ -367,7 +367,12 @@ static HRESULT WINAPI IPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFile
TRACE("(%p)->(%s)\n",This,debugstr_w(pszFileName));
if (!pszFileName)
return E_FAIL;
{
if (!This->filepath) return S_OK;
pszFileName = This->filepath;
fRemember = FALSE;
}
r = SHCreateStreamOnFileW( pszFileName, STGM_READWRITE | STGM_CREATE | STGM_SHARE_EXCLUSIVE, &stm );
if( SUCCEEDED( r ) )
......@@ -379,9 +384,12 @@ static HRESULT WINAPI IPersistFile_fnSave(IPersistFile* iface, LPCOLESTR pszFile
{
StartLinkProcessor( pszFileName );
/* update file path */
heap_free(This->filepath);
This->filepath = strdupW(pszFileName);
if (fRemember)
{
/* update file path */
heap_free(This->filepath);
This->filepath = strdupW(pszFileName);
}
This->bDirty = FALSE;
}
......
......@@ -388,7 +388,7 @@ static void test_get_set(void)
void create_lnk_(int line, const WCHAR* path, lnk_desc_t* desc)
{
HRESULT r;
HRESULT r, init_dirty;
IShellLinkA *sl;
IPersistFile *pf;
......@@ -451,6 +451,17 @@ void create_lnk_(int line, const WCHAR* path, lnk_desc_t* desc)
IPersistFile_GetCurFile(pf, NULL);
}
init_dirty = IPersistFile_IsDirty(pf); /* empty links start off as clean */
r = IPersistFile_Save(pf, NULL, FALSE);
lok(r == S_OK || r == E_INVALIDARG /* before Windows 7 */, "save failed (0x%08x)\n", r);
r = IPersistFile_IsDirty(pf);
lok(r == init_dirty, "dirty (0x%08x)\n", r);
r = IPersistFile_Save(pf, NULL, TRUE);
lok(r == S_OK || r == E_INVALIDARG /* before Windows 7 */, "save failed (0x%08x)\n", r);
r = IPersistFile_IsDirty(pf);
lok(r == init_dirty, "dirty (0x%08x)\n", r);
/* test GetCurFile before ::Save */
str = (LPWSTR)0xdeadbeef;
r = IPersistFile_GetCurFile(pf, &str);
......@@ -459,6 +470,18 @@ void create_lnk_(int line, const WCHAR* path, lnk_desc_t* desc)
r = IPersistFile_Save(pf, path, TRUE);
lok(r == S_OK, "save failed (0x%08x)\n", r);
r = IPersistFile_IsDirty(pf);
lok(r == S_FALSE, "dirty (0x%08x)\n", r);
/* test GetCurFile after ::Save */
r = IPersistFile_GetCurFile(pf, &str);
lok(r == S_OK, "got 0x%08x\n", r);
lok(str != NULL, "Didn't expect NULL\n");
lok(!wcscmp(path, str), "Expected %s, got %s\n", wine_dbgstr_w(path), wine_dbgstr_w(str));
CoTaskMemFree(str);
r = IPersistFile_Save(pf, NULL, TRUE);
lok(r == S_OK, "save failed (0x%08x)\n", r);
/* test GetCurFile after ::Save */
r = IPersistFile_GetCurFile(pf, &str);
......
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