summaryrefslogtreecommitdiff
path: root/xfa/fgas/crt
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-04-11 09:03:14 -0400
committerChromium commit bot <commit-bot@chromium.org>2017-04-11 14:24:24 +0000
commitd7120eead6f6e0b05c1197e55e899081deae1289 (patch)
tree824819037adf17bc2b291f5f0dbc922510a8ffe2 /xfa/fgas/crt
parent96e65ae3a3a328022f025805e9db02cbed1b5607 (diff)
downloadpdfium-d7120eead6f6e0b05c1197e55e899081deae1289.tar.xz
Disabiguate CreateStream calls
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 <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fgas/crt')
-rw-r--r--xfa/fgas/crt/ifgas_stream.cpp38
-rw-r--r--xfa/fgas/crt/ifgas_stream.h14
2 files changed, 17 insertions, 35 deletions
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> IFGAS_Stream::CreateStream(
- const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead,
- uint32_t dwAccess) {
+CFX_RetainPtr<IFGAS_Stream> IFGAS_Stream::CreateReadStream(
+ const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead) {
auto pSR = pdfium::MakeRetain<CFGAS_Stream>();
- if (!pSR->LoadFileRead(pFileRead, dwAccess))
+ if (!pSR->LoadFileRead(pFileRead, FX_STREAMACCESS_Read))
return nullptr;
-
- if (dwAccess & FX_STREAMACCESS_Text)
- return pdfium::MakeRetain<CFGAS_TextStream>(pSR);
-
- return pSR;
+ return pdfium::MakeRetain<CFGAS_TextStream>(pSR);
}
// static
-CFX_RetainPtr<IFGAS_Stream> IFGAS_Stream::CreateStream(
- const CFX_RetainPtr<IFX_SeekableWriteStream>& pFileWrite,
- uint32_t dwAccess) {
+CFX_RetainPtr<IFGAS_Stream> IFGAS_Stream::CreateWriteStream(
+ const CFX_RetainPtr<IFX_SeekableWriteStream>& pFileWrite) {
auto pSR = pdfium::MakeRetain<CFGAS_Stream>();
- 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<CFGAS_TextStream>(pSR);
-
- return pSR;
+ return pdfium::MakeRetain<CFGAS_TextStream>(pSR);
}
// static
CFX_RetainPtr<IFGAS_Stream> IFGAS_Stream::CreateStream(uint8_t* pData,
- int32_t length,
- uint32_t dwAccess) {
+ int32_t length) {
auto pSR = pdfium::MakeRetain<CFGAS_Stream>();
- if (!pSR->LoadBuffer(pData, length, dwAccess))
+ if (!pSR->LoadBuffer(pData, length, 0))
return nullptr;
-
- if (dwAccess & FX_STREAMACCESS_Text)
- return pdfium::MakeRetain<CFGAS_TextStream>(pSR);
-
return pSR;
}
diff --git a/xfa/fgas/crt/ifgas_stream.h b/xfa/fgas/crt/ifgas_stream.h
index 01a148019f..31d1e67589 100644
--- a/xfa/fgas/crt/ifgas_stream.h
+++ b/xfa/fgas/crt/ifgas_stream.h
@@ -13,7 +13,6 @@
enum FX_STREAMACCESS {
FX_STREAMACCESS_Binary = 0x00,
- FX_STREAMACCESS_Text = 0x01,
FX_STREAMACCESS_Read = 0x02,
FX_STREAMACCESS_Write = 0x04,
FX_STREAMACCESS_Truncate = 0x10,
@@ -29,15 +28,12 @@ enum FX_STREAMSEEK {
class IFGAS_Stream : public CFX_Retainable {
public:
- static CFX_RetainPtr<IFGAS_Stream> CreateStream(
- const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead,
- uint32_t dwAccess);
- static CFX_RetainPtr<IFGAS_Stream> CreateStream(
- const CFX_RetainPtr<IFX_SeekableWriteStream>& pFileWrite,
- uint32_t dwAccess);
+ static CFX_RetainPtr<IFGAS_Stream> CreateReadStream(
+ const CFX_RetainPtr<IFX_SeekableReadStream>& pFileRead);
+ static CFX_RetainPtr<IFGAS_Stream> CreateWriteStream(
+ const CFX_RetainPtr<IFX_SeekableWriteStream>& pFileWrite);
static CFX_RetainPtr<IFGAS_Stream> CreateStream(uint8_t* pData,
- int32_t length,
- uint32_t dwAccess);
+ int32_t length);
virtual uint32_t GetAccessModes() const = 0;
virtual int32_t GetLength() const = 0;