From bddc60d0977068fbe89a1dad403f2e6ddd7ff1a1 Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Tue, 17 Apr 2018 18:23:49 +0000 Subject: Remove write abilities from CFX_SeekableStreamProxy This CL removes the abliity to write to the seekable stream proxy class. Change-Id: I0eda2619714df190d326c23dfdcd4527d4312779 Reviewed-on: https://pdfium-review.googlesource.com/30853 Reviewed-by: Tom Sepez Commit-Queue: dsinclair --- core/fxcrt/cfx_seekablestreamproxy.cpp | 37 +++------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) (limited to 'core/fxcrt/cfx_seekablestreamproxy.cpp') diff --git a/core/fxcrt/cfx_seekablestreamproxy.cpp b/core/fxcrt/cfx_seekablestreamproxy.cpp index 989c440db1..44a212d867 100644 --- a/core/fxcrt/cfx_seekablestreamproxy.cpp +++ b/core/fxcrt/cfx_seekablestreamproxy.cpp @@ -134,20 +134,13 @@ void SwapByteOrder(wchar_t* pStr, size_t iLength) { #define BOM_UTF16_LE 0x0000FEFF CFX_SeekableStreamProxy::CFX_SeekableStreamProxy( - const RetainPtr& stream, - bool isWriteStream) - : m_IsWriteStream(isWriteStream), - m_wCodePage(FX_CODEPAGE_DefANSI), + const RetainPtr& stream) + : m_wCodePage(FX_CODEPAGE_DefANSI), m_wBOMLength(0), m_iPosition(0), m_pStream(stream) { ASSERT(m_pStream); - if (isWriteStream) { - m_iPosition = m_pStream->GetSize(); - return; - } - Seek(From::Begin, 0); uint32_t bom = 0; @@ -176,8 +169,7 @@ CFX_SeekableStreamProxy::CFX_SeekableStreamProxy( CFX_SeekableStreamProxy::CFX_SeekableStreamProxy(uint8_t* data, size_t size) : CFX_SeekableStreamProxy( - pdfium::MakeRetain(data, size, false), - false) {} + pdfium::MakeRetain(data, size, false)) {} CFX_SeekableStreamProxy::~CFX_SeekableStreamProxy() {} @@ -206,9 +198,6 @@ void CFX_SeekableStreamProxy::SetCodePage(uint16_t wCodePage) { size_t CFX_SeekableStreamProxy::ReadData(uint8_t* pBuffer, size_t iBufferSize) { ASSERT(pBuffer && iBufferSize > 0); - if (m_IsWriteStream) - return 0; - iBufferSize = std::min(iBufferSize, static_cast(GetLength() - m_iPosition)); if (iBufferSize <= 0) @@ -229,9 +218,6 @@ size_t CFX_SeekableStreamProxy::ReadString(wchar_t* pStr, if (!pStr || iMaxLength == 0) return 0; - if (m_IsWriteStream) - return 0; - if (m_wCodePage == FX_CODEPAGE_UTF16LE || m_wCodePage == FX_CODEPAGE_UTF16BE) { size_t iBytes = iMaxLength * 2; @@ -267,20 +253,3 @@ size_t CFX_SeekableStreamProxy::ReadString(wchar_t* pStr, *bEOS = IsEOF(); return iMaxLength; } - -void CFX_SeekableStreamProxy::WriteString(const WideStringView& str) { - if (!m_IsWriteStream || str.GetLength() == 0 || - m_wCodePage != FX_CODEPAGE_UTF8) { - return; - } - if (!m_pStream->WriteBlock(str.unterminated_c_str(), m_iPosition, - str.GetLength() * sizeof(wchar_t))) { - return; - } - - pdfium::base::CheckedNumeric new_pos = m_iPosition; - new_pos += str.GetLength() * sizeof(wchar_t); - m_iPosition = new_pos.ValueOrDefault(std::numeric_limits::max()); - m_iPosition = - pdfium::clamp(m_iPosition, static_cast(0), GetLength()); -} -- cgit v1.2.3