Commit 5ea0d9d8 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

ole32: Storage sharing should be implemented in ole32, not the lower-level file API.

parent 0e6bfb3b
...@@ -6362,70 +6362,69 @@ struct access_res ...@@ -6362,70 +6362,69 @@ struct access_res
{ {
BOOL gothandle; BOOL gothandle;
DWORD lasterr; DWORD lasterr;
BOOL todo;
}; };
struct access_res create[16] = static const struct access_res create[16] =
{ {
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ TRUE, ERROR_SUCCESS, TRUE }, { TRUE, ERROR_SUCCESS },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ TRUE, ERROR_SUCCESS, TRUE }, { TRUE, ERROR_SUCCESS },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ TRUE, ERROR_SUCCESS, TRUE } { TRUE, ERROR_SUCCESS }
}; };
struct access_res create_commit[16] = static const struct access_res create_commit[16] =
{ {
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ TRUE, ERROR_SUCCESS, TRUE }, { TRUE, ERROR_SUCCESS },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ TRUE, ERROR_SUCCESS, TRUE }, { TRUE, ERROR_SUCCESS },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ TRUE, ERROR_SUCCESS, TRUE } { TRUE, ERROR_SUCCESS }
}; };
struct access_res create_close[16] = static const struct access_res create_close[16] =
{ {
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE } { TRUE, ERROR_SUCCESS }
}; };
static void _test_file_access(LPCSTR file, struct access_res *ares, DWORD line) static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line)
{ {
DWORD access = 0, share = 0; DWORD access = 0, share = 0;
DWORD lasterr; DWORD lasterr;
...@@ -6450,37 +6449,15 @@ static void _test_file_access(LPCSTR file, struct access_res *ares, DWORD line) ...@@ -6450,37 +6449,15 @@ static void _test_file_access(LPCSTR file, struct access_res *ares, DWORD line)
hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING, hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0); FILE_ATTRIBUTE_NORMAL, 0);
lasterr = GetLastError(); lasterr = GetLastError();
if (ares[idx].todo)
{ ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle,
todo_wine "(%d, handle, %d): Expected %d, got %d\n",
{ line, idx, ares[idx].gothandle,
ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle, (hfile != INVALID_HANDLE_VALUE));
"(%d, handle, %d): Expected %d, got %d\n",
line, idx, ares[idx].gothandle, ok(lasterr == ares[idx].lasterr,
(hfile != INVALID_HANDLE_VALUE)); "(%d, lasterr, %d): Expected %d, got %d\n",
} line, idx, ares[idx].lasterr, lasterr);
}
else
ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle,
"(%d, handle, %d): Expected %d, got %d\n",
line, idx, ares[idx].gothandle,
(hfile != INVALID_HANDLE_VALUE));
if (ares[idx].todo)
{
todo_wine
{
ok(lasterr == ares[idx].lasterr,
"(%d, lasterr, %d): Expected %d, got %d\n",
line, idx, ares[idx].lasterr, lasterr);
}
}
else
{
ok(lasterr == ares[idx].lasterr,
"(%d, lasterr, %d): Expected %d, got %d\n",
line, idx, ares[idx].lasterr, lasterr);
}
CloseHandle(hfile); CloseHandle(hfile);
idx++; idx++;
......
...@@ -5727,7 +5727,7 @@ HRESULT WINAPI StgCreateDocfile( ...@@ -5727,7 +5727,7 @@ HRESULT WINAPI StgCreateDocfile(
/* /*
* Interpret the STGM value grfMode * Interpret the STGM value grfMode
*/ */
shareMode = GetShareModeFromSTGM(grfMode); shareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
accessMode = GetAccessModeFromSTGM(grfMode); accessMode = GetAccessModeFromSTGM(grfMode);
if (grfMode & STGM_DELETEONRELEASE) if (grfMode & STGM_DELETEONRELEASE)
...@@ -5735,6 +5735,9 @@ HRESULT WINAPI StgCreateDocfile( ...@@ -5735,6 +5735,9 @@ HRESULT WINAPI StgCreateDocfile(
else else
fileAttributes = FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS; fileAttributes = FILE_ATTRIBUTE_NORMAL | FILE_FLAG_RANDOM_ACCESS;
if (STGM_SHARE_MODE(grfMode) && !(grfMode & STGM_SHARE_DENY_NONE))
FIXME("Storage share mode not implemented.\n");
if (grfMode & STGM_TRANSACTED) if (grfMode & STGM_TRANSACTED)
FIXME("Transacted mode not implemented.\n"); FIXME("Transacted mode not implemented.\n");
......
...@@ -1003,70 +1003,69 @@ struct access_res ...@@ -1003,70 +1003,69 @@ struct access_res
{ {
BOOL gothandle; BOOL gothandle;
DWORD lasterr; DWORD lasterr;
BOOL todo;
}; };
struct access_res create[16] = static const struct access_res create[16] =
{ {
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ TRUE, ERROR_SUCCESS, TRUE }, { TRUE, ERROR_SUCCESS },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ TRUE, ERROR_SUCCESS, TRUE }, { TRUE, ERROR_SUCCESS },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ TRUE, ERROR_SUCCESS, TRUE } { TRUE, ERROR_SUCCESS }
}; };
struct access_res create_commit[16] = static const struct access_res create_commit[16] =
{ {
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ TRUE, ERROR_SUCCESS, TRUE }, { TRUE, ERROR_SUCCESS },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ TRUE, ERROR_SUCCESS, TRUE }, { TRUE, ERROR_SUCCESS },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ FALSE, ERROR_SHARING_VIOLATION, FALSE }, { FALSE, ERROR_SHARING_VIOLATION },
{ TRUE, ERROR_SUCCESS, TRUE } { TRUE, ERROR_SUCCESS }
}; };
struct access_res create_close[16] = static const struct access_res create_close[16] =
{ {
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE }, { TRUE, ERROR_SUCCESS },
{ TRUE, ERROR_SUCCESS, FALSE } { TRUE, ERROR_SUCCESS }
}; };
static void _test_file_access(LPCSTR file, struct access_res *ares, DWORD line) static void _test_file_access(LPCSTR file, const struct access_res *ares, DWORD line)
{ {
DWORD access = 0, share = 0; DWORD access = 0, share = 0;
DWORD lasterr; DWORD lasterr;
...@@ -1091,37 +1090,15 @@ static void _test_file_access(LPCSTR file, struct access_res *ares, DWORD line) ...@@ -1091,37 +1090,15 @@ static void _test_file_access(LPCSTR file, struct access_res *ares, DWORD line)
hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING, hfile = CreateFileA(file, access, share, NULL, OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, 0); FILE_ATTRIBUTE_NORMAL, 0);
lasterr = GetLastError(); lasterr = GetLastError();
if (ares[idx].todo)
{ ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle,
todo_wine "(%d, handle, %d): Expected %d, got %d\n",
{ line, idx, ares[idx].gothandle,
ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle, (hfile != INVALID_HANDLE_VALUE));
"(%d, handle, %d): Expected %d, got %d\n",
line, idx, ares[idx].gothandle, ok(lasterr == ares[idx].lasterr,
(hfile != INVALID_HANDLE_VALUE)); "(%d, lasterr, %d): Expected %d, got %d\n",
} line, idx, ares[idx].lasterr, lasterr);
}
else
ok((hfile != INVALID_HANDLE_VALUE) == ares[idx].gothandle,
"(%d, handle, %d): Expected %d, got %d\n",
line, idx, ares[idx].gothandle,
(hfile != INVALID_HANDLE_VALUE));
if (ares[idx].todo)
{
todo_wine
{
ok(lasterr == ares[idx].lasterr,
"(%d, lasterr, %d): Expected %d, got %d\n",
line, idx, ares[idx].lasterr, lasterr);
}
}
else
{
ok(lasterr == ares[idx].lasterr,
"(%d, lasterr, %d): Expected %d, got %d\n",
line, idx, ares[idx].lasterr, lasterr);
}
CloseHandle(hfile); CloseHandle(hfile);
idx++; idx++;
...@@ -1176,6 +1153,62 @@ static void test_access(void) ...@@ -1176,6 +1153,62 @@ static void test_access(void)
DeleteFileA("winetest"); DeleteFileA("winetest");
/* STGM_SHARE_DENY_NONE */
hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE |
STGM_SHARE_DENY_NONE | STGM_TRANSACTED, 0, &stg);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
test_file_access("winetest", create);
hr = IStorage_Commit(stg, STGC_DEFAULT);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
test_file_access("winetest", create_commit);
IStorage_Release(stg);
test_file_access("winetest", create_close);
DeleteFileA("winetest");
/* STGM_SHARE_DENY_READ */
hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE |
STGM_SHARE_DENY_READ | STGM_TRANSACTED, 0, &stg);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
test_file_access("winetest", create);
hr = IStorage_Commit(stg, STGC_DEFAULT);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
test_file_access("winetest", create_commit);
IStorage_Release(stg);
test_file_access("winetest", create_close);
DeleteFileA("winetest");
/* STGM_SHARE_DENY_WRITE */
hr = StgCreateDocfile(fileW, STGM_CREATE | STGM_READWRITE |
STGM_SHARE_DENY_WRITE | STGM_TRANSACTED, 0, &stg);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
test_file_access("winetest", create);
hr = IStorage_Commit(stg, STGC_DEFAULT);
ok(hr == S_OK, "Expected S_OK, got %08x\n", hr);
test_file_access("winetest", create_commit);
IStorage_Release(stg);
test_file_access("winetest", create_close);
DeleteFileA("winetest");
} }
START_TEST(storage32) START_TEST(storage32)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment