Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/scrrun/filesystem.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-)
diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c index 4794437a71d..0e51929ea54 100644 --- a/dlls/scrrun/filesystem.c +++ b/dlls/scrrun/filesystem.c @@ -609,11 +609,14 @@ static HRESULT WINAPI textstream_ReadAll(ITextStream *iface, BSTR *text) return read_from_buffer(This, This->read_buf_size, text, 0) ? S_FALSE : E_OUTOFMEMORY; }
-static HRESULT textstream_writestr(struct textstream *stream, BSTR text) +static HRESULT textstream_write(struct textstream *stream, BSTR text) { DWORD written = 0; BOOL ret;
+ if (textstream_check_iomode(stream, IOWrite)) + return CTL_E_BADFILEMODE; + if (stream->unicode) { ret = WriteFile(stream->file, text, SysStringByteLen(text), &written, NULL); return (ret && written == SysStringByteLen(text)) ? S_OK : create_error(GetLastError()); @@ -636,14 +639,11 @@ static HRESULT textstream_writestr(struct textstream *stream, BSTR text)
static HRESULT WINAPI textstream_Write(ITextStream *iface, BSTR text) { - struct textstream *This = impl_from_ITextStream(iface); - - TRACE("(%p)->(%s)\n", This, debugstr_w(text)); + struct textstream *stream = impl_from_ITextStream(iface);
- if (textstream_check_iomode(This, IOWrite)) - return CTL_E_BADFILEMODE; + TRACE("%p, %s.\n", iface, debugstr_w(text));
- return textstream_writestr(This, text); + return textstream_write(stream, text); }
static HRESULT textstream_writecrlf(struct textstream *stream) @@ -669,17 +669,14 @@ static HRESULT textstream_writecrlf(struct textstream *stream)
static HRESULT WINAPI textstream_WriteLine(ITextStream *iface, BSTR text) { - struct textstream *This = impl_from_ITextStream(iface); + struct textstream *stream = impl_from_ITextStream(iface); HRESULT hr;
- TRACE("(%p)->(%s)\n", This, debugstr_w(text)); - - if (textstream_check_iomode(This, IOWrite)) - return CTL_E_BADFILEMODE; + TRACE("%p, %s.\n", iface, debugstr_w(text));
- hr = textstream_writestr(This, text); + hr = textstream_write(stream, text); if (SUCCEEDED(hr)) - hr = textstream_writecrlf(This); + hr = textstream_writecrlf(stream); return hr; }