diff options
author | dan sinclair <dsinclair@chromium.org> | 2018-04-17 18:23:49 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-04-17 18:23:49 +0000 |
commit | bddc60d0977068fbe89a1dad403f2e6ddd7ff1a1 (patch) | |
tree | 1769780973bd083f4598baed4d54a200737805fa /core/fxcrt/cfx_seekablestreamproxy.cpp | |
parent | ffdae5fceb4e0b37bc649d99d12c15ccd6ae1b9e (diff) | |
download | pdfium-bddc60d0977068fbe89a1dad403f2e6ddd7ff1a1.tar.xz |
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 <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/cfx_seekablestreamproxy.cpp')
-rw-r--r-- | core/fxcrt/cfx_seekablestreamproxy.cpp | 37 |
1 files changed, 3 insertions, 34 deletions
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<IFX_SeekableStream>& stream, - bool isWriteStream) - : m_IsWriteStream(isWriteStream), - m_wCodePage(FX_CODEPAGE_DefANSI), + const RetainPtr<IFX_SeekableStream>& 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<CFX_MemoryStream>(data, size, false), - false) {} + pdfium::MakeRetain<CFX_MemoryStream>(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<size_t>(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<FX_FILESIZE> new_pos = m_iPosition; - new_pos += str.GetLength() * sizeof(wchar_t); - m_iPosition = new_pos.ValueOrDefault(std::numeric_limits<FX_FILESIZE>::max()); - m_iPosition = - pdfium::clamp(m_iPosition, static_cast<FX_FILESIZE>(0), GetLength()); -} |