Skip to content

Commit

Permalink
Improved error reporting.
Browse files Browse the repository at this point in the history
  • Loading branch information
stuerp committed Nov 20, 2024
1 parent 46c7b17 commit f799bcf
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions HostObjectImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,9 @@ STDMETHODIMP HostObject::ReadAllText(BSTR filePath, __int32 codePage, BSTR * tex

LARGE_INTEGER FileSize;

if (GetFileSizeEx(hFile, &FileSize))
HRESULT hr = S_OK;

if (::GetFileSizeEx(hFile, &FileSize))
{
std::string Text;

Expand All @@ -659,11 +661,15 @@ STDMETHODIMP HostObject::ReadAllText(BSTR filePath, __int32 codePage, BSTR * tex

if (::ReadFile(hFile, (void *) Text.c_str(), FileSize.LowPart, &BytesRead, nullptr) && (BytesRead == FileSize.LowPart))
*text = ::SysAllocString(::CodePageToWide((uint32_t) codePage, Text).c_str());
else
hr = HRESULT_FROM_WIN32(::GetLastError());
}
else
hr = HRESULT_FROM_WIN32(::GetLastError());

::CloseHandle(hFile);

return S_OK;
return hr;
}

#pragma region IDispatch
Expand Down

0 comments on commit f799bcf

Please sign in to comment.