Andrew Eikum : ole32: Overwrite previous CompObj instead of failing.
Alexandre Julliard
julliard at winehq.org
Fri Aug 28 10:17:42 CDT 2009
Module: wine
Branch: master
Commit: a0d262c545ef23bbdf739021daba446a66ccc752
URL: http://source.winehq.org/git/wine.git/?a=commit;h=a0d262c545ef23bbdf739021daba446a66ccc752
Author: Andrew Eikum <aeikum at codeweavers.com>
Date: Thu Aug 27 13:03:26 2009 -0500
ole32: Overwrite previous CompObj instead of failing.
---
dlls/ole32/storage32.c | 4 +-
dlls/ole32/tests/storage32.c | 66 ++++++++++++++++++++++++++++++++++++++++++
2 files changed, 68 insertions(+), 2 deletions(-)
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index b06578b..ac53510 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -7193,9 +7193,9 @@ static HRESULT STORAGE_WriteCompObj( LPSTORAGE pstg, CLSID *clsid,
debugstr_w(lpszUserType), debugstr_w(szClipName),
debugstr_w(szProgIDName));
- /* Create a CompObj stream if it doesn't exist */
+ /* Create a CompObj stream */
r = IStorage_CreateStream(pstg, szwStreamName,
- STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pstm );
+ STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE, 0, 0, &pstm );
if( FAILED (r) )
return r;
diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c
index 5fef82c..fec854e 100644
--- a/dlls/ole32/tests/storage32.c
+++ b/dlls/ole32/tests/storage32.c
@@ -1405,6 +1405,71 @@ static void test_simple(void)
DeleteFileA(filenameA);
}
+static void test_fmtusertypestg(void)
+{
+ IStorage *stg;
+ IEnumSTATSTG *stat;
+ HRESULT hr;
+ static const WCHAR fileW[] = {'f','m','t','t','e','s','t',0};
+ static WCHAR userTypeW[] = {'S','t','g','U','s','r','T','y','p','e',0};
+ static WCHAR strmNameW[] = {1,'C','o','m','p','O','b','j',0};
+
+ hr = StgCreateDocfile( fileW, STGM_CREATE | STGM_SHARE_EXCLUSIVE | STGM_READWRITE, 0, &stg);
+ ok(hr == S_OK, "should succeed, res=%x\n", hr);
+
+ if (SUCCEEDED(hr))
+ {
+ /* try to write the stream */
+ hr = WriteFmtUserTypeStg(stg, 0, userTypeW);
+ ok(hr == S_OK, "should succeed, res=%x\n", hr);
+
+ /* check that the stream was created */
+ hr = IStorage_EnumElements(stg, 0, NULL, 0, &stat);
+ ok(hr == S_OK, "should succeed, res=%x\n", hr);
+ if (SUCCEEDED(hr))
+ {
+ BOOL found = FALSE;
+ STATSTG statstg;
+ DWORD got;
+ while ((hr = IEnumSTATSTG_Next(stat, 1, &statstg, &got)) == S_OK && got == 1)
+ {
+ if (lstrcmpW(statstg.pwcsName, strmNameW) == 0)
+ found = TRUE;
+ else
+ ok(0, "found unexpected stream or storage\n");
+ }
+ ok(found == TRUE, "expected storage to contain stream \\0001CompObj\n");
+ IEnumSTATSTG_Release(stat);
+ }
+
+ /* re-write the stream */
+ hr = WriteFmtUserTypeStg(stg, 0, userTypeW);
+ ok(hr == S_OK, "should succeed, res=%x\n", hr);
+
+ /* check that the stream is still there */
+ hr = IStorage_EnumElements(stg, 0, NULL, 0, &stat);
+ ok(hr == S_OK, "should succeed, res=%x\n", hr);
+ if (SUCCEEDED(hr))
+ {
+ BOOL found = FALSE;
+ STATSTG statstg;
+ DWORD got;
+ while ((hr = IEnumSTATSTG_Next(stat, 1, &statstg, &got)) == S_OK && got == 1)
+ {
+ if (lstrcmpW(statstg.pwcsName, strmNameW) == 0)
+ found = TRUE;
+ else
+ ok(0, "found unexpected stream or storage\n");
+ }
+ ok(found == TRUE, "expected storage to contain stream \\0001CompObj\n");
+ IEnumSTATSTG_Release(stat);
+ }
+
+ IStorage_Release(stg);
+ DeleteFileW( fileW );
+ }
+}
+
START_TEST(storage32)
{
CHAR temp[MAX_PATH];
@@ -1431,4 +1496,5 @@ START_TEST(storage32)
test_writeclassstg();
test_readonly();
test_simple();
+ test_fmtusertypestg();
}
More information about the wine-cvs
mailing list