Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
71424b80
Commit
71424b80
authored
Jan 11, 2005
by
Mike McCormack
Committed by
Alexandre Julliard
Jan 11, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Tests and fixes for StgOpenStorage.
parent
fed06be7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
86 additions
and
5 deletions
+86
-5
storage32.c
dlls/ole32/storage32.c
+32
-5
storage32.c
dlls/ole32/tests/storage32.c
+54
-0
No files found.
dlls/ole32/storage32.c
View file @
71424b80
...
...
@@ -51,6 +51,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(storage);
#define FILE_BEGIN 0
#define STGM_SHARE_MODE(stgm) ((stgm)&0xf0)
/* Used for OleConvertIStorageToOLESTREAM and OleConvertOLESTREAMToIStorage */
#define OLESTREAM_ID 0x501
...
...
@@ -5580,18 +5581,44 @@ HRESULT WINAPI StgOpenStorage(
snbExclude
,
reserved
,
ppstgOpen
);
/*
* Perform
a sanity check
* Perform
sanity checks
*/
if
((
pwcsName
==
0
)
||
(
ppstgOpen
==
0
)
)
if
(
pwcsName
==
0
)
{
hr
=
STG_E_INVALIDNAME
;
goto
end
;
}
if
(
ppstgOpen
==
0
)
{
hr
=
STG_E_INVALIDPOINTER
;
goto
end
;
}
if
(
reserved
)
{
hr
=
STG_E_INVALIDPARAMETER
;
goto
end
;
}
/*
* Validate the sharing mode
*/
switch
(
STGM_SHARE_MODE
(
grfMode
))
{
case
STGM_SHARE_EXCLUSIVE
:
case
STGM_SHARE_DENY_WRITE
:
break
;
default:
hr
=
STG_E_INVALIDFLAG
;
goto
end
;
}
/*
* Validate the STGM flags
*/
if
(
FAILED
(
validateSTGM
(
grfMode
)
))
if
(
FAILED
(
validateSTGM
(
grfMode
)
)
||
(
grfMode
&
STGM_CREATE
))
{
hr
=
STG_E_INVALIDFLAG
;
goto
end
;
...
...
@@ -5616,8 +5643,6 @@ HRESULT WINAPI StgOpenStorage(
FILE_ATTRIBUTE_NORMAL
|
FILE_FLAG_RANDOM_ACCESS
,
0
);
length
=
GetFileSize
(
hFile
,
NULL
);
if
(
hFile
==
INVALID_HANDLE_VALUE
)
{
DWORD
last_error
=
GetLastError
();
...
...
@@ -5650,6 +5675,8 @@ HRESULT WINAPI StgOpenStorage(
goto
end
;
}
length
=
GetFileSize
(
hFile
,
NULL
);
/*
* Allocate and initialize the new IStorage32object.
*/
...
...
dlls/ole32/tests/storage32.c
View file @
71424b80
...
...
@@ -256,9 +256,63 @@ void test_storage_stream(void)
ok
(
r
==
TRUE
,
"file should exist
\n
"
);
}
void
test_open_storage
(
void
)
{
static
const
WCHAR
szPrefix
[]
=
{
's'
,
't'
,
'g'
,
0
};
static
const
WCHAR
szNonExist
[]
=
{
'n'
,
'o'
,
'n'
,
'e'
,
'x'
,
'i'
,
's'
,
't'
,
0
};
static
const
WCHAR
szDot
[]
=
{
'.'
,
0
};
WCHAR
filename
[
MAX_PATH
];
IStorage
*
stg
=
NULL
,
*
stg2
=
NULL
;
HRESULT
r
;
if
(
!
GetTempFileNameW
(
szDot
,
szPrefix
,
0
,
filename
))
return
;
DeleteFileW
(
filename
);
/* create the file */
r
=
StgCreateDocfile
(
filename
,
STGM_CREATE
|
STGM_SHARE_EXCLUSIVE
|
STGM_READWRITE
|
STGM_TRANSACTED
,
0
,
&
stg
);
ok
(
r
==
S_OK
,
"StgCreateDocfile failed
\n
"
);
IStorage_Release
(
stg
);
r
=
StgOpenStorage
(
filename
,
NULL
,
0
,
NULL
,
0
,
&
stg
);
ok
(
r
==
STG_E_INVALIDFLAG
,
"StgOpenStorage wrong error
\n
"
);
r
=
StgOpenStorage
(
NULL
,
NULL
,
STGM_SHARE_EXCLUSIVE
,
NULL
,
0
,
&
stg
);
ok
(
r
==
STG_E_INVALIDNAME
,
"StgOpenStorage wrong error
\n
"
);
r
=
StgOpenStorage
(
filename
,
NULL
,
STGM_SHARE_EXCLUSIVE
|
STGM_READ
,
NULL
,
0
,
NULL
);
ok
(
r
==
STG_E_INVALIDPOINTER
,
"StgOpenStorage wrong error
\n
"
);
r
=
StgOpenStorage
(
filename
,
NULL
,
STGM_SHARE_EXCLUSIVE
|
STGM_READ
,
NULL
,
1
,
&
stg
);
ok
(
r
==
STG_E_INVALIDPARAMETER
,
"StgOpenStorage wrong error
\n
"
);
r
=
StgOpenStorage
(
szNonExist
,
NULL
,
STGM_SHARE_EXCLUSIVE
|
STGM_READ
,
NULL
,
0
,
&
stg
);
ok
(
r
==
STG_E_FILENOTFOUND
,
"StgOpenStorage failed
\n
"
);
r
=
StgOpenStorage
(
filename
,
NULL
,
STGM_CREATE
|
STGM_SHARE_EXCLUSIVE
|
STGM_READ
,
NULL
,
0
,
&
stg
);
ok
(
r
==
STG_E_INVALIDFLAG
,
"StgOpenStorage failed
\n
"
);
r
=
StgOpenStorage
(
filename
,
NULL
,
STGM_SHARE_DENY_NONE
|
STGM_READ
,
NULL
,
0
,
&
stg
);
ok
(
r
==
STG_E_INVALIDFLAG
,
"StgOpenStorage failed
\n
"
);
r
=
StgOpenStorage
(
filename
,
NULL
,
STGM_SHARE_DENY_READ
|
STGM_READ
,
NULL
,
0
,
&
stg
);
ok
(
r
==
STG_E_INVALIDFLAG
,
"StgOpenStorage failed
\n
"
);
/* open it for real */
r
=
StgOpenStorage
(
filename
,
NULL
,
STGM_SHARE_DENY_WRITE
|
STGM_READ
,
NULL
,
0
,
&
stg
);
ok
(
r
==
S_OK
,
"StgOpenStorage failed
\n
"
);
r
=
IStorage_Release
(
stg
);
ok
(
r
==
0
,
"wrong ref count
\n
"
);
r
=
StgOpenStorage
(
filename
,
NULL
,
STGM_SHARE_EXCLUSIVE
|
STGM_READ
,
NULL
,
0
,
&
stg
);
ok
(
r
==
S_OK
,
"StgOpenStorage failed
\n
"
);
r
=
StgOpenStorage
(
filename
,
NULL
,
STGM_SHARE_EXCLUSIVE
|
STGM_READ
,
NULL
,
0
,
&
stg2
);
ok
(
r
==
STG_E_SHAREVIOLATION
,
"StgOpenStorage failed
\n
"
);
r
=
IStorage_Release
(
stg
);
ok
(
r
==
0
,
"wrong ref count
\n
"
);
r
=
DeleteFileW
(
filename
);
ok
(
r
,
"file didn't exist
\n
"
);
}
START_TEST
(
storage32
)
{
test_hglobal_storage_stat
();
test_create_storage_modes
();
test_storage_stream
();
test_open_storage
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment