From 3ff33e9303df1696c1d87c21a95fe06159dc9c87 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Fri, 4 Dec 2009 18:02:59 -0600 Subject: [PATCH] ole32: Implement Revert for transacted storage objects. --- dlls/ole32/storage32.c | 18 +++++++++++++++++- dlls/ole32/tests/storage32.c | 12 +++--------- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/dlls/ole32/storage32.c b/dlls/ole32/storage32.c index bd755e9e78..479c2a54b8 100644 --- a/dlls/ole32/storage32.c +++ b/dlls/ole32/storage32.c @@ -4044,7 +4044,23 @@ static HRESULT WINAPI TransactedSnapshotImpl_Commit( static HRESULT WINAPI TransactedSnapshotImpl_Revert( IStorage* iface) { - FIXME("(%p): stub\n", iface); + TransactedSnapshotImpl* This = (TransactedSnapshotImpl*) iface; + StorageBaseImpl *newSnapshot; + HRESULT hr; + + TRACE("(%p)\n", iface); + + /* Create a new copy of the parent data. */ + hr = CreateSnapshotFile(This->transactedParent, &newSnapshot); + if (FAILED(hr)) return hr; + + /* Destroy the open objects. */ + StorageBaseImpl_DeleteAll(&This->base); + + /* Replace our current snapshot. */ + IStorage_Release((IStorage*)This->snapshot); + This->snapshot = newSnapshot; + return S_OK; } diff --git a/dlls/ole32/tests/storage32.c b/dlls/ole32/tests/storage32.c index 04943691c6..f89a787c03 100644 --- a/dlls/ole32/tests/storage32.c +++ b/dlls/ole32/tests/storage32.c @@ -1195,7 +1195,6 @@ static void test_revert(void) r = IStorage_Revert(stg); /* all open objects become invalid */ - todo_wine { r = IStream_Write(stm, "this shouldn't work\n", 20, NULL); ok(r==STG_E_REVERTED, "IStream_Write should fail %08x\n", r); @@ -1207,7 +1206,6 @@ static void test_revert(void) r = IStorage_Stat(stg3, &statstg, STATFLAG_NONAME); ok(r==STG_E_REVERTED, "IStorage_Stat should fail %08x\n", r); - } IStream_Release(stm); IStream_Release(stm2); @@ -1226,17 +1224,13 @@ static void test_revert(void) r = IStorage_OpenStorage(stg, stmname, NULL, STGM_TRANSACTED|STGM_SHARE_EXCLUSIVE|STGM_READWRITE, NULL, 0, &stg2 ); ok(r==STG_E_FILENOTFOUND, "IStorage->OpenStream failed %08x\n", r); - todo_wine { r = IStorage_OpenStream(stg, stmname, NULL, STGM_SHARE_EXCLUSIVE|STGM_READWRITE, 0, &stm ); ok(r==STG_E_FILENOTFOUND, "IStorage->OpenStream should fail %08x\n", r); - } if (r == S_OK) IStream_Release(stm); - todo_wine { r = IStorage_OpenStorage(stg, stgname2, NULL, STGM_SHARE_EXCLUSIVE|STGM_READWRITE, NULL, 0, &stg2 ); ok(r==STG_E_FILENOTFOUND, "IStorage->OpenStorage should fail %08x\n", r); - } if (r == S_OK) IStorage_Release(stg2); @@ -1258,7 +1252,7 @@ static void test_revert(void) IStorage_Release(stg3); r = IStorage_OpenStorage(stg2, stgname2, NULL, STGM_SHARE_EXCLUSIVE|STGM_READWRITE, NULL, 0, &stg3 ); - todo_wine ok(r==STG_E_FILENOTFOUND, "IStorage->OpenStorage should fail %08x\n", r); + ok(r==STG_E_FILENOTFOUND, "IStorage->OpenStorage should fail %08x\n", r); if (r == S_OK) IStorage_Release(stg3); @@ -1398,7 +1392,7 @@ static void test_nonroot_transacted(void) IStream_Release(stm); r = IStorage_OpenStream(stg2, stmname2, NULL, STGM_SHARE_EXCLUSIVE|STGM_READWRITE, 0, &stm ); - todo_wine ok(r==STG_E_FILENOTFOUND, "IStorage->OpenStream should fail %08x\n", r); + ok(r==STG_E_FILENOTFOUND, "IStorage->OpenStream should fail %08x\n", r); if (r == S_OK) IStream_Release(stm); @@ -1460,7 +1454,7 @@ static void test_nonroot_transacted(void) IStream_Release(stm); r = IStorage_OpenStream(stg2, stmname2, NULL, STGM_SHARE_EXCLUSIVE|STGM_READWRITE, 0, &stm ); - todo_wine ok(r==STG_E_FILENOTFOUND, "IStorage->OpenStream should fail %08x\n", r); + ok(r==STG_E_FILENOTFOUND, "IStorage->OpenStream should fail %08x\n", r); if (r == S_OK) IStream_Release(stm); -- 2.32.0.93.g670b81a890