Module: wine Branch: master Commit: f9d8449db26ffc94c67074532e213f3ac8c4de87 URL: http://source.winehq.org/git/wine.git/?a=commit;h=f9d8449db26ffc94c67074532e...
Author: Michael Gardiner mikegardiner@bigpond.com Date: Mon Jan 1 15:09:51 2007 +1100
ole32: Stop StgOpenStorage from creating a file when it does not already exist.
---
dlls/ole32/storage32.c | 32 ++++++++++---------------------- dlls/ole32/tests/storage32.c | 6 +++--- 2 files changed, 13 insertions(+), 25 deletions(-)
diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index 733f659..ac8264d 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -5945,7 +5945,6 @@ HRESULT WINAPI StgOpenStorage( DWORD shareMode; DWORD accessMode; WCHAR fullname[MAX_PATH]; - BOOL newFile;
TRACE("(%s, %p, %x, %p, %d, %p)\n", debugstr_w(pwcsName), pstgPriority, grfMode, @@ -6035,24 +6034,13 @@ HRESULT WINAPI StgOpenStorage( */ *ppstgOpen = 0;
- if ((accessMode & GENERIC_WRITE) && /* try to create a file if no yet exists */ - ((hFile = CreateFileW( pwcsName, accessMode, shareMode, NULL, CREATE_NEW, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, 0)) - != INVALID_HANDLE_VALUE)) - { - newFile = TRUE; - } - else - { - newFile = FALSE; - hFile = CreateFileW( pwcsName, - accessMode, - shareMode, - NULL, - OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, - 0); - } + hFile = CreateFileW( pwcsName, + accessMode, + shareMode, + NULL, + OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS, + 0);
if (hFile==INVALID_HANDLE_VALUE) { @@ -6090,7 +6078,7 @@ HRESULT WINAPI StgOpenStorage( * Refuse to open the file if it's too small to be a structured storage file * FIXME: verify the file when reading instead of here */ - if (!newFile && GetFileSize(hFile, NULL) < 0x100) + if (GetFileSize(hFile, NULL) < 0x100) { CloseHandle(hFile); hr = STG_E_FILEALREADYEXISTS; @@ -6108,7 +6096,7 @@ HRESULT WINAPI StgOpenStorage( goto end; }
- /* if we created new file, initialize the storage */ + /* Initialize the storage */ hr = StorageImpl_Construct( newStorage, hFile, @@ -6116,7 +6104,7 @@ HRESULT WINAPI StgOpenStorage( NULL, grfMode, TRUE, - newFile ); + FALSE );
if (FAILED(hr)) { diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c index 6b3b15b..80b6cb0 100644 --- a/dlls/ole32/tests/storage32.c +++ b/dlls/ole32/tests/storage32.c @@ -388,12 +388,12 @@ static void test_open_storage(void)
DeleteFileW(filename);
- /* try opening a nonexistent file - it should create it */ + /* try opening a nonexistent file - it should not create it */ stgm = STGM_DIRECT | STGM_SHARE_EXCLUSIVE | STGM_READWRITE; r = StgOpenStorage( filename, NULL, stgm, NULL, 0, &stg); - ok(r==S_OK, "StgOpenStorage failed: 0x%08x\n", r); + ok(r!=S_OK, "StgOpenStorage failed: 0x%08x\n", r); if (r==S_OK) IStorage_Release(stg); - ok(is_existing_file(filename), "StgOpenStorage didn't create a file\n"); + ok(!is_existing_file(filename), "StgOpenStorage should not create a file\n"); DeleteFileW(filename);
/* create the file */