Nikolay Sivov : scrrun: Move IO mode check to writing helper.
Alexandre Julliard
julliard at winehq.org
Mon Feb 21 16:15:12 CST 2022
Module: wine
Branch: master
Commit: a9c4bda48138627b9f98bda403bea7f7a74e185c
URL: https://source.winehq.org/git/wine.git/?a=commit;h=a9c4bda48138627b9f98bda403bea7f7a74e185c
Author: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sun Feb 20 17:09:14 2022 +0300
scrrun: Move IO mode check to writing helper.
Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
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;
}
More information about the wine-cvs
mailing list