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
fd40ace3
Commit
fd40ace3
authored
Mar 19, 2005
by
Mike McCormack
Committed by
Alexandre Julliard
Mar 19, 2005
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix usage of STGM_ enumerations, remove forward declaration.
parent
2597b1be
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
55 deletions
+66
-55
memorystream.c
dlls/shell32/memorystream.c
+66
-55
No files found.
dlls/shell32/memorystream.c
View file @
fd40ace3
...
...
@@ -42,59 +42,18 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
shell
);
static
const
IStreamVtbl
stvt
;
#define STGM_ACCESS_MODE(stgm) ((stgm)&0x0000f)
#define STGM_SHARE_MODE(stgm) ((stgm)&0x000f0)
#define STGM_CREATE_MODE(stgm) ((stgm)&0x0f000)
typedef
struct
{
const
IStreamVtbl
*
lpvtst
;
DWORD
ref
;
HANDLE
handle
;
DWORD
ref
;
HANDLE
handle
;
}
ISHFileStream
;
/**************************************************************************
* CreateStreamOnFile()
*
* similar to CreateStreamOnHGlobal
*/
HRESULT
CreateStreamOnFile
(
LPCWSTR
pszFilename
,
DWORD
grfMode
,
IStream
**
ppstm
)
{
ISHFileStream
*
fstr
;
HANDLE
handle
;
DWORD
access
=
GENERIC_READ
,
creat
;
if
(
grfMode
&
STGM_TRANSACTED
)
return
E_INVALIDARG
;
if
(
grfMode
&
STGM_WRITE
)
access
|=
GENERIC_WRITE
;
if
(
grfMode
&
STGM_READWRITE
)
access
=
GENERIC_WRITE
|
GENERIC_READ
;
if
(
grfMode
&
STGM_CREATE
)
creat
=
CREATE_ALWAYS
;
else
creat
=
OPEN_EXISTING
;
TRACE
(
"Opening %s
\n
"
,
debugstr_w
(
pszFilename
)
);
handle
=
CreateFileW
(
pszFilename
,
access
,
FILE_SHARE_READ
,
NULL
,
creat
,
0
,
NULL
);
if
(
handle
==
INVALID_HANDLE_VALUE
)
return
HRESULT_FROM_WIN32
(
GetLastError
());
fstr
=
(
ISHFileStream
*
)
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
ISHFileStream
));
if
(
!
fstr
)
return
E_OUTOFMEMORY
;
fstr
->
lpvtst
=&
stvt
;
fstr
->
ref
=
1
;
fstr
->
handle
=
handle
;
(
*
ppstm
)
=
(
IStream
*
)
fstr
;
return
S_OK
;
}
/**************************************************************************
* IStream_fnQueryInterface
*/
static
HRESULT
WINAPI
IStream_fnQueryInterface
(
IStream
*
iface
,
REFIID
riid
,
LPVOID
*
ppvObj
)
...
...
@@ -105,17 +64,14 @@ static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVO
*
ppvObj
=
NULL
;
if
(
IsEqualIID
(
riid
,
&
IID_IUnknown
)
||
IsEqualIID
(
riid
,
&
IID_IStream
))
{
*
ppvObj
=
This
;
}
if
(
IsEqualIID
(
riid
,
&
IID_IUnknown
)
||
IsEqualIID
(
riid
,
&
IID_IStream
))
*
ppvObj
=
This
;
if
(
*
ppvObj
)
{
IStream_AddRef
((
IStream
*
)
*
ppvObj
);
TRACE
(
"-- Interface: (%p)->(%p)
\n
"
,
ppvObj
,
*
ppvObj
);
return
S_OK
;
IStream_AddRef
((
IStream
*
)
*
ppvObj
);
TRACE
(
"-- Interface: (%p)->(%p)
\n
"
,
ppvObj
,
*
ppvObj
);
return
S_OK
;
}
TRACE
(
"-- Interface: E_NOINTERFACE
\n
"
);
return
E_NOINTERFACE
;
...
...
@@ -294,5 +250,60 @@ static const IStreamVtbl stvt =
IStream_fnUnlockRegion
,
IStream_fnStat
,
IStream_fnClone
};
/**************************************************************************
* CreateStreamOnFile()
*
* similar to CreateStreamOnHGlobal
*/
HRESULT
CreateStreamOnFile
(
LPCWSTR
pszFilename
,
DWORD
grfMode
,
IStream
**
ppstm
)
{
ISHFileStream
*
fstr
;
HANDLE
handle
;
DWORD
access
=
GENERIC_READ
,
creat
;
if
(
grfMode
&
STGM_TRANSACTED
)
return
E_INVALIDARG
;
switch
(
STGM_ACCESS_MODE
(
grfMode
)
)
{
case
STGM_READ
:
access
=
GENERIC_READ
;
break
;
case
STGM_WRITE
:
case
STGM_READWRITE
:
access
=
GENERIC_WRITE
|
GENERIC_READ
;
break
;
default:
return
STG_E_INVALIDFLAG
;
}
switch
(
STGM_CREATE_MODE
(
grfMode
)
)
{
case
STGM_CREATE
:
creat
=
CREATE_ALWAYS
;
break
;
case
STGM_FAILIFTHERE
:
creat
=
OPEN_EXISTING
;
break
;
default:
return
STG_E_INVALIDFLAG
;
}
handle
=
CreateFileW
(
pszFilename
,
access
,
FILE_SHARE_READ
,
NULL
,
creat
,
0
,
NULL
);
if
(
handle
==
INVALID_HANDLE_VALUE
)
return
HRESULT_FROM_WIN32
(
GetLastError
());
fstr
=
HeapAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
sizeof
(
ISHFileStream
));
if
(
!
fstr
)
return
E_OUTOFMEMORY
;
fstr
->
lpvtst
=
&
stvt
;
fstr
->
ref
=
1
;
fstr
->
handle
=
handle
;
(
*
ppstm
)
=
(
IStream
*
)
fstr
;
return
S_OK
;
}
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