msado15: Implement _Stream_ReadText and _Stream_WriteText.
Signed-off-by: Hans Leidekker <hans@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
3e6b9394bc
commit
65200440fd
|
@ -400,15 +400,65 @@ static HRESULT WINAPI stream_LoadFromFile( _Stream *iface, BSTR filename )
|
|||
|
||||
static HRESULT WINAPI stream_ReadText( _Stream *iface, LONG len, BSTR *ret )
|
||||
{
|
||||
FIXME( "%p, %d, %p\n", iface, len, ret );
|
||||
struct stream *stream = impl_from_Stream( iface );
|
||||
BSTR str;
|
||||
|
||||
TRACE( "%p, %d, %p\n", stream, len, ret );
|
||||
if (len == adReadLine)
|
||||
{
|
||||
FIXME( "adReadLine not supported\n" );
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
if (stream->charset && wcscmp( stream->charset, L"Unicode" ))
|
||||
{
|
||||
FIXME( "charset %s not supported\n", debugstr_w(stream->charset) );
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
if (stream->type != adTypeText) return MAKE_ADO_HRESULT( adErrIllegalOperation );
|
||||
if (len < adReadLine) return MAKE_ADO_HRESULT( adErrInvalidArgument );
|
||||
|
||||
if (len == adReadAll) len = (stream->size - stream->pos) / sizeof(WCHAR);
|
||||
else len = min( len, stream->size - stream->pos / sizeof(WCHAR) );
|
||||
|
||||
if (!(str = SysAllocStringLen( NULL, len ))) return E_OUTOFMEMORY;
|
||||
memcpy( str, stream->buf + stream->pos, len * sizeof(WCHAR) );
|
||||
str[len] = 0;
|
||||
|
||||
stream->pos += len * sizeof(WCHAR);
|
||||
|
||||
*ret = str;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI stream_WriteText( _Stream *iface, BSTR data, StreamWriteEnum options )
|
||||
{
|
||||
FIXME( "%p, %s, %u\n", iface, debugstr_w(data), options );
|
||||
struct stream *stream = impl_from_Stream( iface );
|
||||
HRESULT hr;
|
||||
LONG size;
|
||||
|
||||
TRACE( "%p, %s, %u\n", stream, debugstr_w(data), options );
|
||||
if (options != adWriteChar)
|
||||
{
|
||||
FIXME( "options %u not supported\n", options );
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
if (stream->charset && wcscmp( stream->charset, L"Unicode" ))
|
||||
{
|
||||
FIXME( "charset %s not supported\n", debugstr_w(stream->charset) );
|
||||
return E_NOTIMPL;
|
||||
}
|
||||
|
||||
if (stream->type != adTypeText) return MAKE_ADO_HRESULT( adErrIllegalOperation );
|
||||
|
||||
size = (lstrlenW( data ) + 1) * sizeof(WCHAR);
|
||||
if ((hr = resize_buffer( stream, stream->size + size )) != S_OK) return hr;
|
||||
|
||||
memcpy( stream->buf + stream->pos, data, size );
|
||||
stream->pos += size;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
static HRESULT WINAPI stream_Cancel( _Stream *iface )
|
||||
{
|
||||
|
|
|
@ -162,11 +162,54 @@ static void test_Stream(void)
|
|||
hr = _Stream_Read( stream, 2, &val );
|
||||
ok( hr == MAKE_ADO_HRESULT( adErrIllegalOperation ), "got %08x\n", hr );
|
||||
|
||||
hr = _Stream_ReadText( stream, 2, &str );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
ok( !str[0], "got %s\n", wine_dbgstr_w(str) );
|
||||
SysFreeString( str );
|
||||
|
||||
pos = -1;
|
||||
hr = _Stream_get_Position( stream, &pos );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
ok( !pos, "got %d\n", pos );
|
||||
|
||||
str = SysAllocString( L"test" );
|
||||
hr = _Stream_WriteText( stream, str, adWriteChar );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
SysFreeString( str );
|
||||
|
||||
hr = _Stream_ReadText( stream, adReadAll, &str );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
ok( !str[0], "got %s\n", wine_dbgstr_w(str) );
|
||||
SysFreeString( str );
|
||||
|
||||
hr = _Stream_put_Position( stream, 0 );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
hr = _Stream_ReadText( stream, adReadAll, &str );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
ok( !lstrcmpW( str, L"test" ), "got %s\n", wine_dbgstr_w(str) );
|
||||
SysFreeString( str );
|
||||
|
||||
pos = -1;
|
||||
hr = _Stream_get_Position( stream, &pos );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
ok( pos == 10, "got %d\n", pos );
|
||||
|
||||
eos = VARIANT_FALSE;
|
||||
hr = _Stream_get_EOS( stream, &eos );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
ok( eos == VARIANT_TRUE, "got %04x\n", eos );
|
||||
|
||||
hr = _Stream_put_Position( stream, 6 );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
size = -1;
|
||||
hr = _Stream_get_Size( stream, &size );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
ok( size == 10, "got %d\n", size );
|
||||
|
||||
hr = _Stream_put_Position( stream, 2 );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
hr = _Stream_Close( stream );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
|
@ -191,6 +234,14 @@ static void test_Stream(void)
|
|||
hr = _Stream_Open( stream, missing, adModeUnknown, adOpenStreamUnspecified, NULL, NULL );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
||||
hr = _Stream_ReadText( stream, adReadAll, &str );
|
||||
ok( hr == MAKE_ADO_HRESULT( adErrIllegalOperation ), "got %08x\n", hr );
|
||||
|
||||
str = SysAllocString( L"test" );
|
||||
hr = _Stream_WriteText( stream, str, adWriteChar );
|
||||
ok( hr == MAKE_ADO_HRESULT( adErrIllegalOperation ), "got %08x\n", hr );
|
||||
SysFreeString( str );
|
||||
|
||||
VariantInit( &val );
|
||||
hr = _Stream_Read( stream, 1, &val );
|
||||
ok( hr == S_OK, "got %08x\n", hr );
|
||||
|
|
Loading…
Reference in New Issue