Module: wine Branch: master Commit: 2f41a3ad21ff5689e12e78031d102c8cdf10373a URL: http://source.winehq.org/git/wine.git/?a=commit;h=2f41a3ad21ff5689e12e78031d...
Author: Vincent Povirk vincent@codeweavers.com Date: Tue Apr 27 10:20:42 2010 -0500
windowscodecs: Implement IWICStream_InitializeFromFilename.
---
dlls/windowscodecs/Makefile.in | 2 +- dlls/windowscodecs/stream.c | 32 ++++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/dlls/windowscodecs/Makefile.in b/dlls/windowscodecs/Makefile.in index 7ff3ae2..0516161 100644 --- a/dlls/windowscodecs/Makefile.in +++ b/dlls/windowscodecs/Makefile.in @@ -4,7 +4,7 @@ SRCDIR = @srcdir@ VPATH = @srcdir@ MODULE = windowscodecs.dll IMPORTLIB = windowscodecs -IMPORTS = uuid ole32 advapi32 kernel32 +IMPORTS = uuid ole32 shlwapi advapi32 kernel32 EXTRAINCL = @PNGINCL@
C_SRCS = \ diff --git a/dlls/windowscodecs/stream.c b/dlls/windowscodecs/stream.c index bd5592b..bee27db 100644 --- a/dlls/windowscodecs/stream.c +++ b/dlls/windowscodecs/stream.c @@ -23,6 +23,7 @@ #include "winbase.h" #include "winreg.h" #include "objbase.h" +#include "shlwapi.h" #include "wincodec.h" #include "wincodecs_private.h"
@@ -434,8 +435,35 @@ static HRESULT WINAPI IWICStreamImpl_InitializeFromIStream(IWICStream *iface, static HRESULT WINAPI IWICStreamImpl_InitializeFromFilename(IWICStream *iface, LPCWSTR wzFileName, DWORD dwDesiredAccess) { - FIXME("(%p): stub\n", iface); - return E_NOTIMPL; + IWICStreamImpl *This = (IWICStreamImpl*)iface; + HRESULT hr; + DWORD dwMode; + IStream *stream; + + TRACE("(%p, %s, %u)\n", iface, debugstr_w(wzFileName), dwDesiredAccess); + + if (This->pStream) return WINCODEC_ERR_WRONGSTATE; + + if(dwDesiredAccess & GENERIC_WRITE) + dwMode = STGM_SHARE_DENY_WRITE | STGM_WRITE | STGM_CREATE; + else if(dwDesiredAccess & GENERIC_READ) + dwMode = STGM_SHARE_DENY_WRITE | STGM_READ | STGM_FAILIFTHERE; + else + return E_INVALIDARG; + + hr = SHCreateStreamOnFileW(wzFileName, dwMode, &stream); + + if (SUCCEEDED(hr)) + { + if (InterlockedCompareExchangePointer((void**)&This->pStream, stream, NULL)) + { + /* Some other thread set the stream first. */ + IStream_Release(stream); + hr = WINCODEC_ERR_WRONGSTATE; + } + } + + return hr; }
/******************************************