Robert Shearman : ole32:
STGM_PRIORITY allows other IStorage objects to be opened in transacted
mode with read /write access.
Alexandre Julliard
julliard at wine.codeweavers.com
Fri May 5 15:24:21 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: 6dd5dbef64037e6b68c8a0ecdcaaa31ffa8b1da7
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=6dd5dbef64037e6b68c8a0ecdcaaa31ffa8b1da7
Author: Robert Shearman <rob at codeweavers.com>
Date: Wed May 3 22:23:12 2006 +0100
ole32: STGM_PRIORITY allows other IStorage objects to be opened in transacted mode with read/write access.
---
dlls/ole32/storage32.c | 12 +++++++++---
dlls/ole32/tests/storage32.c | 20 ++++++++++++++++++--
2 files changed, 27 insertions(+), 5 deletions(-)
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index 18f248c..ae1fd80 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -5914,7 +5914,6 @@ HRESULT WINAPI StgOpenStorage(
goto end;
}
- /* STGM_PRIORITY implies exclusive access */
if (grfMode & STGM_PRIORITY)
{
if (grfMode & (STGM_TRANSACTED|STGM_SIMPLE|STGM_NOSCRATCH|STGM_NOSNAPSHOT))
@@ -5924,13 +5923,20 @@ HRESULT WINAPI StgOpenStorage(
if(STGM_ACCESS_MODE(grfMode) != STGM_READ)
return STG_E_INVALIDFLAG;
grfMode &= ~0xf0; /* remove the existing sharing mode */
- grfMode |= STGM_SHARE_DENY_WRITE;
+ grfMode |= STGM_SHARE_DENY_NONE;
+
+ /* STGM_PRIORITY stops other IStorage objects on the same file from
+ * committing until the STGM_PRIORITY IStorage is closed. it also
+ * stops non-transacted mode StgOpenStorage calls with write access from
+ * succeeding. obviously, both of these cannot be achieved through just
+ * file share flags */
+ FIXME("STGM_PRIORITY mode not implemented correctly\n");
}
/*
* Validate the sharing mode
*/
- if (!(grfMode & STGM_TRANSACTED))
+ if (!(grfMode & (STGM_TRANSACTED|STGM_PRIORITY)))
switch(STGM_SHARE_MODE(grfMode))
{
case STGM_SHARE_EXCLUSIVE:
diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c
index 1936150..7085089 100644
--- a/dlls/ole32/tests/storage32.c
+++ b/dlls/ole32/tests/storage32.c
@@ -626,6 +626,7 @@ static void test_storage_refcount(void)
static const WCHAR szDot[] = { '.',0 };
WCHAR filename[MAX_PATH];
IStorage *stg = NULL;
+ IStorage *stgprio = NULL;
HRESULT r;
IStream *stm = NULL;
static const WCHAR stmname[] = { 'C','O','N','T','E','N','T','S',0 };
@@ -673,10 +674,24 @@ static void test_storage_refcount(void)
r = IStream_Release(stm);
ok (r == 0, "stream not released\n");
- /* test for grfMode open issue */
+ /* tests that STGM_PRIORITY doesn't prevent readwrite access from other
+ * StgOpenStorage calls in transacted mode */
+ r = StgOpenStorage( filename, NULL, STGM_PRIORITY, NULL, 0, &stgprio);
+ ok(r==S_OK, "StgOpenStorage failed with error 0x%08lx\n", r);
+
+ todo_wine {
+ /* non-transacted mode read/write fails */
+ r = StgOpenStorage( filename, NULL, STGM_SHARE_EXCLUSIVE|STGM_READWRITE, NULL, 0, &stg);
+ ok(r==STG_E_LOCKVIOLATION, "StgOpenStorage should return STG_E_LOCKVIOLATION instead of 0x%08lx\n", r);
+ }
+
+ /* non-transacted mode read-only succeeds */
+ r = StgOpenStorage( filename, NULL, STGM_SHARE_DENY_WRITE|STGM_READ, NULL, 0, &stg);
+ ok(r==S_OK, "StgOpenStorage failed with error 0x%08lx\n", r);
+ IStorage_Release(stg);
r = StgOpenStorage( filename, NULL, STGM_TRANSACTED|STGM_SHARE_DENY_WRITE|STGM_READWRITE, NULL, 0, &stg);
- ok(r==S_OK, "StgOpenStorage failed\n");
+ ok(r==S_OK, "StgOpenStorage failed with error 0x%08lx\n", r);
if(stg)
{
static const WCHAR stgname[] = { ' ',' ',' ','2','9',0 };
@@ -727,6 +742,7 @@ static void test_storage_refcount(void)
r = IStorage_Release(stg);
ok(r == 0, "wrong ref count\n");
}
+ IStorage_Release(stgprio);
DeleteFileW(filename);
}
More information about the wine-cvs
mailing list