From 0a19048795f8084c448bab6d87c2d8170b8b0ba3 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Tue, 16 Jun 2015 15:38:08 +1000 Subject: [PATCH] scrrun: Implement ITextStream Close. --- dlls/scrrun/filesystem.c | 12 ++++++++++-- dlls/scrrun/tests/filesystem.c | 12 ++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c index d490d9381c3..3de38d2c36e 100644 --- a/dlls/scrrun/filesystem.c +++ b/dlls/scrrun/filesystem.c @@ -633,8 +633,16 @@ static HRESULT WINAPI textstream_SkipLine(ITextStream *iface) static HRESULT WINAPI textstream_Close(ITextStream *iface) { struct textstream *This = impl_from_ITextStream(iface); - FIXME("(%p): stub\n", This); - return E_NOTIMPL; + HRESULT hr = S_OK; + + TRACE("(%p)\n", This); + + if(!CloseHandle(This->file)) + hr = S_FALSE; + + This->file = NULL; + + return hr; } static const ITextStreamVtbl textstreamvtbl = { diff --git a/dlls/scrrun/tests/filesystem.c b/dlls/scrrun/tests/filesystem.c index b22e0066655..28242ce46bf 100644 --- a/dlls/scrrun/tests/filesystem.c +++ b/dlls/scrrun/tests/filesystem.c @@ -35,6 +35,9 @@ static IFileSystem3 *fs3; +/* w2k and 2k3 error code. */ +#define E_VAR_NOT_SET 0x800a005b + static inline ULONG get_refcount(IUnknown *iface) { IUnknown_AddRef(iface); @@ -1378,6 +1381,15 @@ static void test_CreateTextFile(void) hr = ITextStream_Read(stream, 1, &str); ok(hr == CTL_E_BADFILEMODE, "got 0x%08x\n", hr); + hr = ITextStream_Close(stream); + ok(hr == S_OK, "got 0x%08x\n", hr); + + hr = ITextStream_Read(stream, 1, &str); + ok(hr == CTL_E_BADFILEMODE || hr == E_VAR_NOT_SET, "got 0x%08x\n", hr); + + hr = ITextStream_Close(stream); + ok(hr == S_FALSE || hr == E_VAR_NOT_SET, "got 0x%08x\n", hr); + ITextStream_Release(stream); /* check it's created */