From d7120eead6f6e0b05c1197e55e899081deae1289 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Tue, 11 Apr 2017 09:03:14 -0400 Subject: Disabiguate CreateStream calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This CL creates a CreateReadStream and CreateWriteStream method instead of having a single overloaded method. This removes the need for the cast at the call sites. The access parameter has been rolled into the method as it was always passed the same way to each Create*Stream method. Change-Id: I845951c3fe386b8051daf4f6b2ee5ba29b5c7d54 Reviewed-on: https://pdfium-review.googlesource.com/4032 Reviewed-by: Nicolás Peña Commit-Queue: dsinclair --- xfa/fgas/crt/ifgas_stream.cpp | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) (limited to 'xfa/fgas/crt/ifgas_stream.cpp') diff --git a/xfa/fgas/crt/ifgas_stream.cpp b/xfa/fgas/crt/ifgas_stream.cpp index 209532476d..a4330dcd67 100644 --- a/xfa/fgas/crt/ifgas_stream.cpp +++ b/xfa/fgas/crt/ifgas_stream.cpp @@ -911,7 +911,7 @@ void CFGAS_TextStream::InitStream() { } uint32_t CFGAS_TextStream::GetAccessModes() const { - return m_pStreamImp->GetAccessModes() | FX_STREAMACCESS_Text; + return m_pStreamImp->GetAccessModes(); } int32_t CFGAS_TextStream::GetLength() const { @@ -1368,44 +1368,30 @@ bool CFGAS_FileRead::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) { } // namespace // static -CFX_RetainPtr IFGAS_Stream::CreateStream( - const CFX_RetainPtr& pFileRead, - uint32_t dwAccess) { +CFX_RetainPtr IFGAS_Stream::CreateReadStream( + const CFX_RetainPtr& pFileRead) { auto pSR = pdfium::MakeRetain(); - if (!pSR->LoadFileRead(pFileRead, dwAccess)) + if (!pSR->LoadFileRead(pFileRead, FX_STREAMACCESS_Read)) return nullptr; - - if (dwAccess & FX_STREAMACCESS_Text) - return pdfium::MakeRetain(pSR); - - return pSR; + return pdfium::MakeRetain(pSR); } // static -CFX_RetainPtr IFGAS_Stream::CreateStream( - const CFX_RetainPtr& pFileWrite, - uint32_t dwAccess) { +CFX_RetainPtr IFGAS_Stream::CreateWriteStream( + const CFX_RetainPtr& pFileWrite) { auto pSR = pdfium::MakeRetain(); - if (!pSR->LoadFileWrite(pFileWrite, dwAccess)) + if (!pSR->LoadFileWrite(pFileWrite, + FX_STREAMACCESS_Write | FX_STREAMACCESS_Append)) return nullptr; - - if (dwAccess & FX_STREAMACCESS_Text) - return pdfium::MakeRetain(pSR); - - return pSR; + return pdfium::MakeRetain(pSR); } // static CFX_RetainPtr IFGAS_Stream::CreateStream(uint8_t* pData, - int32_t length, - uint32_t dwAccess) { + int32_t length) { auto pSR = pdfium::MakeRetain(); - if (!pSR->LoadBuffer(pData, length, dwAccess)) + if (!pSR->LoadBuffer(pData, length, 0)) return nullptr; - - if (dwAccess & FX_STREAMACCESS_Text) - return pdfium::MakeRetain(pSR); - return pSR; } -- cgit v1.2.3