Commit 18988663 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

- Use more specific error codes than E_FAIL, where possible.

- Move vtable to end, give it the const modifier, and remove unneeded function declarations.
parent 2515ff77
...@@ -42,42 +42,11 @@ ...@@ -42,42 +42,11 @@
WINE_DEFAULT_DEBUG_CHANNEL(shell); WINE_DEFAULT_DEBUG_CHANNEL(shell);
static HRESULT WINAPI IStream_fnQueryInterface(IStream *iface, REFIID riid, LPVOID *ppvObj); static const IStreamVtbl stvt;
static ULONG WINAPI IStream_fnAddRef(IStream *iface);
static ULONG WINAPI IStream_fnRelease(IStream *iface);
static HRESULT WINAPI IStream_fnRead (IStream * iface, void* pv, ULONG cb, ULONG* pcbRead);
static HRESULT WINAPI IStream_fnWrite (IStream * iface, const void* pv, ULONG cb, ULONG* pcbWritten);
static HRESULT WINAPI IStream_fnSeek (IStream * iface, LARGE_INTEGER dlibMove, DWORD dwOrigin, ULARGE_INTEGER* plibNewPosition);
static HRESULT WINAPI IStream_fnSetSize (IStream * iface, ULARGE_INTEGER libNewSize);
static HRESULT WINAPI IStream_fnCopyTo (IStream * iface, IStream* pstm, ULARGE_INTEGER cb, ULARGE_INTEGER* pcbRead, ULARGE_INTEGER* pcbWritten);
static HRESULT WINAPI IStream_fnCommit (IStream * iface, DWORD grfCommitFlags);
static HRESULT WINAPI IStream_fnRevert (IStream * iface);
static HRESULT WINAPI IStream_fnLockRegion (IStream * iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
static HRESULT WINAPI IStream_fnUnlockRegion (IStream * iface, ULARGE_INTEGER libOffset, ULARGE_INTEGER cb, DWORD dwLockType);
static HRESULT WINAPI IStream_fnStat (IStream * iface, STATSTG* pstatstg, DWORD grfStatFlag);
static HRESULT WINAPI IStream_fnClone (IStream * iface, IStream** ppstm);
static IStreamVtbl stvt =
{
IStream_fnQueryInterface,
IStream_fnAddRef,
IStream_fnRelease,
IStream_fnRead,
IStream_fnWrite,
IStream_fnSeek,
IStream_fnSetSize,
IStream_fnCopyTo,
IStream_fnCommit,
IStream_fnRevert,
IStream_fnLockRegion,
IStream_fnUnlockRegion,
IStream_fnStat,
IStream_fnClone
};
typedef struct typedef struct
{ IStreamVtbl *lpvtst; {
const IStreamVtbl *lpvtst;
DWORD ref; DWORD ref;
HANDLE handle; HANDLE handle;
} ISHFileStream; } ISHFileStream;
...@@ -110,12 +79,12 @@ HRESULT CreateStreamOnFile (LPCWSTR pszFilename, DWORD grfMode, IStream ** ppstm ...@@ -110,12 +79,12 @@ HRESULT CreateStreamOnFile (LPCWSTR pszFilename, DWORD grfMode, IStream ** ppstm
handle = CreateFileW( pszFilename, access, FILE_SHARE_READ, NULL, creat, 0, NULL ); handle = CreateFileW( pszFilename, access, FILE_SHARE_READ, NULL, creat, 0, NULL );
if( handle == INVALID_HANDLE_VALUE ) if( handle == INVALID_HANDLE_VALUE )
return E_FAIL; return HRESULT_FROM_WIN32(GetLastError());
fstr = (ISHFileStream*)HeapAlloc(GetProcessHeap(), fstr = (ISHFileStream*)HeapAlloc(GetProcessHeap(),
HEAP_ZERO_MEMORY,sizeof(ISHFileStream)); HEAP_ZERO_MEMORY,sizeof(ISHFileStream));
if( !fstr ) if( !fstr )
return E_FAIL; return E_OUTOFMEMORY;
fstr->lpvtst=&stvt; fstr->lpvtst=&stvt;
fstr->ref = 1; fstr->ref = 1;
fstr->handle = handle; fstr->handle = handle;
...@@ -192,7 +161,7 @@ static HRESULT WINAPI IStream_fnRead (IStream * iface, void* pv, ULONG cb, ULONG ...@@ -192,7 +161,7 @@ static HRESULT WINAPI IStream_fnRead (IStream * iface, void* pv, ULONG cb, ULONG
return STG_E_INVALIDPOINTER; return STG_E_INVALIDPOINTER;
if ( ! ReadFile( This->handle, pv, cb, pcbRead, NULL ) ) if ( ! ReadFile( This->handle, pv, cb, pcbRead, NULL ) )
return E_FAIL; return S_FALSE;
return S_OK; return S_OK;
} }
...@@ -306,3 +275,22 @@ static HRESULT WINAPI IStream_fnClone (IStream * iface, IStream** ppstm) ...@@ -306,3 +275,22 @@ static HRESULT WINAPI IStream_fnClone (IStream * iface, IStream** ppstm)
return E_NOTIMPL; return E_NOTIMPL;
} }
static const IStreamVtbl stvt =
{
IStream_fnQueryInterface,
IStream_fnAddRef,
IStream_fnRelease,
IStream_fnRead,
IStream_fnWrite,
IStream_fnSeek,
IStream_fnSetSize,
IStream_fnCopyTo,
IStream_fnCommit,
IStream_fnRevert,
IStream_fnLockRegion,
IStream_fnUnlockRegion,
IStream_fnStat,
IStream_fnClone
};
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