Commit 8d58a91f authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

ole32: Allow CopyTo to succeed in spite of already open source streams.

parent 2bb93d39
...@@ -1599,11 +1599,15 @@ static HRESULT WINAPI StorageBaseImpl_CopyTo( ...@@ -1599,11 +1599,15 @@ static HRESULT WINAPI StorageBaseImpl_CopyTo(
SNB snbExclude, /* [unique][in] */ SNB snbExclude, /* [unique][in] */
IStorage* pstgDest) /* [unique][in] */ IStorage* pstgDest) /* [unique][in] */
{ {
StorageBaseImpl* const This=(StorageBaseImpl*)iface;
IEnumSTATSTG *elements = 0; IEnumSTATSTG *elements = 0;
STATSTG curElement, strStat; STATSTG curElement, strStat;
HRESULT hr; HRESULT hr;
IStorage *pstgTmp, *pstgChild; IStorage *pstgTmp, *pstgChild;
IStream *pstrTmp, *pstrChild; IStream *pstrTmp, *pstrChild;
DirRef srcEntryRef;
DirEntry srcEntry;
BOOL skip = FALSE, skip_storage = FALSE, skip_stream = FALSE; BOOL skip = FALSE, skip_storage = FALSE, skip_stream = FALSE;
int i; int i;
...@@ -1728,11 +1732,25 @@ static HRESULT WINAPI StorageBaseImpl_CopyTo( ...@@ -1728,11 +1732,25 @@ static HRESULT WINAPI StorageBaseImpl_CopyTo(
goto cleanup; goto cleanup;
/* /*
* open child stream storage * open child stream storage. This operation must succeed even if the
* stream is already open, so we use internal functions to do it.
*/ */
hr = IStorage_OpenStream( iface, curElement.pwcsName, NULL, srcEntryRef = findElement( This, This->storageDirEntry, curElement.pwcsName,
STGM_READ|STGM_SHARE_EXCLUSIVE, &srcEntry);
0, &pstrChild ); if (!srcEntryRef)
{
ERR("source stream not found\n");
hr = STG_E_DOCFILECORRUPT;
}
if (hr == S_OK)
{
pstrChild = (IStream*)StgStreamImpl_Construct(This, STGM_READ|STGM_SHARE_EXCLUSIVE, srcEntryRef);
if (pstrChild)
IStream_AddRef(pstrChild);
else
hr = E_OUTOFMEMORY;
}
if (hr == S_OK) if (hr == S_OK)
{ {
......
...@@ -2750,7 +2750,7 @@ static void test_copyto_locking(void) ...@@ -2750,7 +2750,7 @@ static void test_copyto_locking(void)
/* Try to copy the storage while the stream is open */ /* Try to copy the storage while the stream is open */
r = IStorage_CopyTo(stg2, 0, NULL, NULL, stg3); r = IStorage_CopyTo(stg2, 0, NULL, NULL, stg3);
todo_wine ok(r==S_OK, "IStorage->CopyTo failed, hr=%08x\n", r); ok(r==S_OK, "IStorage->CopyTo failed, hr=%08x\n", r);
IStream_Release(stm); IStream_Release(stm);
......
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