diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-05-10 13:59:14 -0400 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-05-10 19:41:00 +0000 |
commit | 5b590337e0778b49dd7092af4a283ed0f9c5a2e9 (patch) | |
tree | 4aae9dd27685bf2cca6954d5a1a7ef197466b808 /core/fxcrt/fx_basic_buffer.cpp | |
parent | aa7022833db1a6e21b81fcca30b45ba652298f32 (diff) | |
download | pdfium-5b590337e0778b49dd7092af4a283ed0f9c5a2e9.tar.xz |
Store the offset in the archive buffer
This Cl moves the implementation of the archive buffer behind an
IFX_ArchiveStream interface. The buffer holds the current offset and the
offset parameter is removed from the CPDF_Creator and various other
methods.
Change-Id: Ia54e803b58bbfb6ef03fec4a940d2c056d541356
Reviewed-on: https://pdfium-review.googlesource.com/5255
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'core/fxcrt/fx_basic_buffer.cpp')
-rw-r--r-- | core/fxcrt/fx_basic_buffer.cpp | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/core/fxcrt/fx_basic_buffer.cpp b/core/fxcrt/fx_basic_buffer.cpp index 13057f1670..36da3f4053 100644 --- a/core/fxcrt/fx_basic_buffer.cpp +++ b/core/fxcrt/fx_basic_buffer.cpp @@ -220,66 +220,3 @@ uint32_t CFX_BitStream::GetBits(uint32_t nBits) { m_BitPos += nBits; return result; } - -CFX_FileBufferArchive::CFX_FileBufferArchive() - : m_Length(0), m_pFile(nullptr) {} - -CFX_FileBufferArchive::~CFX_FileBufferArchive() {} - -void CFX_FileBufferArchive::Clear() { - m_Length = 0; - m_pBuffer.reset(); - m_pFile.Reset(); -} - -bool CFX_FileBufferArchive::Flush() { - size_t nRemaining = m_Length; - m_Length = 0; - if (!m_pFile) - return false; - if (!m_pBuffer || !nRemaining) - return true; - return m_pFile->WriteBlock(m_pBuffer.get(), nRemaining); -} - -int32_t CFX_FileBufferArchive::AppendBlock(const void* pBuf, size_t size) { - if (!pBuf || size < 1) - return 0; - - if (!m_pBuffer) - m_pBuffer.reset(FX_Alloc(uint8_t, kBufSize)); - - const uint8_t* buffer = reinterpret_cast<const uint8_t*>(pBuf); - size_t temp_size = size; - while (temp_size) { - size_t buf_size = std::min(kBufSize - m_Length, temp_size); - memcpy(m_pBuffer.get() + m_Length, buffer, buf_size); - m_Length += buf_size; - if (m_Length == kBufSize && !Flush()) - return -1; - - temp_size -= buf_size; - buffer += buf_size; - } - return pdfium::base::checked_cast<int32_t>(size); -} - -int32_t CFX_FileBufferArchive::AppendByte(uint8_t byte) { - return AppendBlock(&byte, 1); -} - -int32_t CFX_FileBufferArchive::AppendDWord(uint32_t i) { - char buf[32]; - FXSYS_itoa(i, buf, 10); - return AppendBlock(buf, (size_t)FXSYS_strlen(buf)); -} - -int32_t CFX_FileBufferArchive::AppendString(const CFX_ByteStringC& lpsz) { - return AppendBlock(lpsz.raw_str(), lpsz.GetLength()); -} - -void CFX_FileBufferArchive::AttachFile( - const CFX_RetainPtr<IFX_WriteStream>& pFile) { - ASSERT(pFile); - m_pFile = pFile; -} |