Mike Hearn : ole32: Add StgCreateFile test and conformance fix.
Alexandre Julliard
julliard at wine.codeweavers.com
Mon May 8 09:06:29 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: 27800ef4ccee02dfb74821be318fbcce8d3c5f15
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=27800ef4ccee02dfb74821be318fbcce8d3c5f15
Author: Mike Hearn <mike at plan99.net>
Date: Mon May 1 18:33:26 2006 +0100
ole32: Add StgCreateFile test and conformance fix.
---
dlls/ole32/storage32.c | 25 ++++++++++++-------------
dlls/ole32/tests/storage32.c | 19 +++++++++++++++----
2 files changed, 27 insertions(+), 17 deletions(-)
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c
index fdb3946..a42841a 100644
--- a/dlls/ole32/storage32.c
+++ b/dlls/ole32/storage32.c
@@ -5646,7 +5646,7 @@ HRESULT WINAPI StgCreateDocfile(
if ( FAILED( validateSTGM(grfMode) ))
goto end;
- /* StgCreateDocFile always opens for write */
+ /* StgCreateDocFile seems to refuse readonly access, despite MSDN */
switch(STGM_ACCESS_MODE(grfMode))
{
case STGM_WRITE:
@@ -5656,21 +5656,20 @@ HRESULT WINAPI StgCreateDocfile(
goto end;
}
- /* can't share write */
- switch(STGM_SHARE_MODE(grfMode))
- {
- case STGM_SHARE_EXCLUSIVE:
- case STGM_SHARE_DENY_WRITE:
- break;
- default:
- goto end;
- }
+ /* if no share mode given then DENY_NONE is the default */
+ if (STGM_SHARE_MODE(grfMode) == 0)
+ grfMode |= STGM_SHARE_DENY_NONE;
- /* shared reading requires transacted mode */
- if( STGM_SHARE_MODE(grfMode) == STGM_SHARE_DENY_WRITE &&
- !(grfMode&STGM_TRANSACTED) )
+ /* must have at least one access mode */
+ if (STGM_ACCESS_MODE(grfMode) == 0)
+ goto end;
+
+ /* in direct mode, can only use SHARE_EXCLUSIVE */
+ if (!(grfMode & STGM_TRANSACTED) && (STGM_SHARE_MODE(grfMode) != STGM_SHARE_EXCLUSIVE))
goto end;
+ /* but in transacted mode, any share mode is valid */
+
/*
* Generate a unique name.
*/
diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c
index 7085089..e579897 100644
--- a/dlls/ole32/tests/storage32.c
+++ b/dlls/ole32/tests/storage32.c
@@ -116,15 +116,15 @@ static void test_create_storage_modes(vo
ok(r==STG_E_INVALIDFLAG, "StgCreateDocfile succeeded\n");
ok(stg == NULL, "stg was set\n");
- /* check what happens if the file already exists */
+ /* check what happens if the file already exists (which is how it's meant to be used) */
r = StgCreateDocfile( filename, STGM_SHARE_EXCLUSIVE | STGM_READWRITE, 0, &stg);
ok(r==S_OK, "StgCreateDocfile failed\n");
r = IStorage_Release(stg);
ok(r == 0, "storage not released\n");
r = StgCreateDocfile( filename, STGM_SHARE_EXCLUSIVE | STGM_READWRITE |STGM_TRANSACTED, 0, &stg);
- ok(r==STG_E_FILEALREADYEXISTS, "StgCreateDocfile wrong error\n");
+ ok(r==STG_E_FILEALREADYEXISTS, "StgCreateDocfile wrong error\n"); /* FAILIFTHERE is default */
r = StgCreateDocfile( filename, STGM_READ, 0, &stg);
- ok(r==STG_E_INVALIDFLAG, "StgCreateDocfile succeeded\n");
+ ok(r==STG_E_INVALIDFLAG, "StgCreateDocfile succeeded\n"); /* need at least readmode and sharemode */
r = StgCreateDocfile( filename, STGM_SHARE_EXCLUSIVE, 0, &stg);
ok(r==STG_E_INVALIDFLAG, "StgCreateDocfile succeeded\n");
r = StgCreateDocfile( filename, STGM_SHARE_DENY_WRITE, 0, &stg);
@@ -141,6 +141,8 @@ static void test_create_storage_modes(vo
ok(r==STG_E_INVALIDFLAG, "StgCreateDocfile failed\n");
r = StgCreateDocfile( filename, STGM_SHARE_DENY_WRITE | STGM_READ, 0, &stg);
ok(r==STG_E_INVALIDFLAG, "StgCreateDocfile wrong error\n");
+ r = StgCreateDocfile( filename, STGM_TRANSACTED | STGM_SHARE_DENY_WRITE | STGM_READ, 0, &stg);
+ ok(r==STG_E_INVALIDFLAG, "StgCreateDocfile wrong error\n");
ok(DeleteFileW(filename), "failed to delete file\n");
r = StgCreateDocfile( filename, STGM_SHARE_EXCLUSIVE | STGM_READWRITE |STGM_TRANSACTED, 0, &stg);
@@ -158,7 +160,6 @@ static void test_create_storage_modes(vo
ok(r==S_OK, "StgCreateDocfile failed\n");
r = IStorage_Release(stg);
ok(r == 0, "storage not released\n");
-
ok(DeleteFileW(filename), "failed to delete file\n");
/* test the way excel uses StgCreateDocFile */
@@ -171,6 +172,16 @@ static void test_create_storage_modes(vo
ok(DeleteFileW(filename), "failed to delete file\n");
}
+ /* and the way windows media uses it ... */
+ r = StgCreateDocfile( filename, STGM_CREATE | STGM_SHARE_DENY_NONE | STGM_READWRITE | STGM_TRANSACTED, 0, &stg);
+ ok(r==S_OK, "StgCreateDocfile the windows media way failed\n");
+ if (r == S_OK)
+ {
+ r = IStorage_Release(stg);
+ ok(r == 0, "storage not released\n");
+ ok(DeleteFileW(filename), "failed to delete file\n");
+ }
+
/* looks like we need STGM_TRANSACTED or STGM_CREATE */
r = StgCreateDocfile( filename, STGM_TRANSACTED|STGM_SHARE_DENY_WRITE|STGM_READWRITE, 0, &stg);
ok(r==S_OK, "StgCreateDocfile the excel way failed\n");
More information about the wine-cvs
mailing list