Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
63f88b3d
Commit
63f88b3d
authored
Sep 22, 2006
by
Andrey Turkin
Committed by
Alexandre Julliard
Sep 28, 2006
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ole32: StgOpenStorage on non-existent file should create it (with test).
parent
b19c9848
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
5 deletions
+35
-5
storage32.c
dlls/ole32/storage32.c
+15
-5
storage32.c
dlls/ole32/tests/storage32.c
+20
-0
No files found.
dlls/ole32/storage32.c
View file @
63f88b3d
...
...
@@ -5946,7 +5946,7 @@ HRESULT WINAPI StgOpenStorage(
DWORD
shareMode
;
DWORD
accessMode
;
WCHAR
fullname
[
MAX_PATH
];
DWORD
length
;
BOOL
newFile
;
TRACE
(
"(%s, %p, %lx, %p, %ld, %p)
\n
"
,
debugstr_w
(
pwcsName
),
pstgPriority
,
grfMode
,
...
...
@@ -6036,6 +6036,16 @@ 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
,
...
...
@@ -6043,6 +6053,7 @@ HRESULT WINAPI StgOpenStorage(
OPEN_EXISTING
,
FILE_ATTRIBUTE_NORMAL
|
FILE_FLAG_RANDOM_ACCESS
,
0
);
}
if
(
hFile
==
INVALID_HANDLE_VALUE
)
{
...
...
@@ -6080,8 +6091,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
*/
length
=
GetFileSize
(
hFile
,
NULL
);
if
(
length
<
0x100
)
if
(
!
newFile
&&
GetFileSize
(
hFile
,
NULL
)
<
0x100
)
{
CloseHandle
(
hFile
);
hr
=
STG_E_FILEALREADYEXISTS
;
...
...
@@ -6099,7 +6109,7 @@ HRESULT WINAPI StgOpenStorage(
goto
end
;
}
/* if
the file's length was zero
, initialize the storage */
/* if
we created new file
, initialize the storage */
hr
=
StorageImpl_Construct
(
newStorage
,
hFile
,
...
...
@@ -6107,7 +6117,7 @@ HRESULT WINAPI StgOpenStorage(
NULL
,
grfMode
,
TRUE
,
FALSE
);
newFile
);
if
(
FAILED
(
hr
))
{
...
...
dlls/ole32/tests/storage32.c
View file @
63f88b3d
...
...
@@ -349,6 +349,18 @@ static BOOL is_zero_length(LPCWSTR filename)
return
len
==
0
;
}
static
BOOL
is_existing_file
(
LPCWSTR
filename
)
{
HANDLE
file
;
file
=
CreateFileW
(
filename
,
GENERIC_READ
,
0
,
NULL
,
OPEN_EXISTING
,
0
,
NULL
);
if
(
file
==
INVALID_HANDLE_VALUE
)
return
FALSE
;
CloseHandle
(
file
);
return
TRUE
;
}
static
void
test_open_storage
(
void
)
{
static
const
WCHAR
szPrefix
[]
=
{
's'
,
't'
,
'g'
,
0
};
...
...
@@ -376,6 +388,14 @@ static void test_open_storage(void)
DeleteFileW
(
filename
);
/* try opening a non-existant file - it should 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%08lx
\n
"
,
r
);
if
(
r
==
S_OK
)
IStorage_Release
(
stg
);
ok
(
is_existing_file
(
filename
),
"StgOpenStorage didn't create a file
\n
"
);
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
"
);
...
...
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