From 5cd398545141226f082b2f757f23c73303058a83 Mon Sep 17 00:00:00 2001 From: Tom Sepez Date: Wed, 5 Aug 2015 10:00:59 -0700 Subject: FPDF_Creator can only create file through embedder-supplied callback. Hence, some of the routines taking filename strings are unused. This, in turn allows us to get rid of some other fopen-ishy looking things inside the library. R=thestig@chromium.org Review URL: https://codereview.chromium.org/1264423003 . --- core/include/fpdfapi/fpdf_serial.h | 9 +------- core/include/fxcrt/fx_basic.h | 6 ------ core/include/fxcrt/fx_stream.h | 2 -- core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp | 20 ------------------ core/src/fxcrt/fx_basic_buffer.cpp | 28 ------------------------- core/src/fxcrt/fx_extension.cpp | 6 ------ 6 files changed, 1 insertion(+), 70 deletions(-) diff --git a/core/include/fpdfapi/fpdf_serial.h b/core/include/fpdfapi/fpdf_serial.h index 7197e0d7b0..4a325341cb 100644 --- a/core/include/fpdfapi/fpdf_serial.h +++ b/core/include/fpdfapi/fpdf_serial.h @@ -17,22 +17,15 @@ CFX_ByteTextBuf& operator<<(CFX_ByteTextBuf& buf, const CPDF_Object* pObj); #define FPDFCREATE_NO_ORIGINAL 2 #define FPDFCREATE_PROGRESSIVE 4 #define FPDFCREATE_OBJECTSTREAM 8 + class CPDF_Creator { public: CPDF_Creator(CPDF_Document* pDoc); - ~CPDF_Creator(); void RemoveSecurity(); - - FX_BOOL Create(const FX_WCHAR* filename, FX_DWORD flags = 0); - - FX_BOOL Create(const FX_CHAR* filename, FX_DWORD flags = 0); - FX_BOOL Create(IFX_StreamWrite* pFile, FX_DWORD flags = 0); - int32_t Continue(IFX_Pause* pPause = NULL); - FX_BOOL SetFileVersion(int32_t fileVersion = 17); protected: diff --git a/core/include/fxcrt/fx_basic.h b/core/include/fxcrt/fx_basic.h index 7181b19942..73b99be549 100644 --- a/core/include/fxcrt/fx_basic.h +++ b/core/include/fxcrt/fx_basic.h @@ -164,18 +164,12 @@ class CFX_FileBufferArchive : public IFX_BufferArchive { ~CFX_FileBufferArchive() override; void Clear() override; - FX_BOOL AttachFile(IFX_StreamWrite* pFile, FX_BOOL bTakeover = FALSE); - FX_BOOL AttachFile(const FX_WCHAR* filename); - - FX_BOOL AttachFile(const FX_CHAR* filename); - private: FX_BOOL DoWork(const void* pBuf, size_t size) override; IFX_StreamWrite* m_pFile; - FX_BOOL m_bTakeover; }; diff --git a/core/include/fxcrt/fx_stream.h b/core/include/fxcrt/fx_stream.h index 2f3ebdcfce..73ec7e05b2 100644 --- a/core/include/fxcrt/fx_stream.h +++ b/core/include/fxcrt/fx_stream.h @@ -78,8 +78,6 @@ class IFX_FileWrite : public IFX_StreamWrite { return WriteBlock(pData, GetSize(), size); } }; -IFX_FileWrite* FX_CreateFileWrite(const FX_CHAR* filename); -IFX_FileWrite* FX_CreateFileWrite(const FX_WCHAR* filename); class IFX_StreamRead { public: virtual ~IFX_StreamRead() {} diff --git a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp index 6f193071de..ff0539c61f 100644 --- a/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp +++ b/core/src/fpdfapi/fpdf_edit/fpdf_edit_create.cpp @@ -2016,26 +2016,6 @@ void CPDF_Creator::Clear() { m_pIDArray = NULL; } } -FX_BOOL CPDF_Creator::Create(const FX_CHAR* filename, FX_DWORD flags) { - if (!m_File.AttachFile(filename)) { - return FALSE; - } - FX_BOOL bRet = Create(flags); - if (!bRet || !(flags & FPDFCREATE_PROGRESSIVE)) { - Clear(); - } - return bRet; -} -FX_BOOL CPDF_Creator::Create(const FX_WCHAR* filename, FX_DWORD flags) { - if (!m_File.AttachFile(filename)) { - return FALSE; - } - FX_BOOL bRet = Create(flags); - if (!bRet || !(flags & FPDFCREATE_PROGRESSIVE)) { - Clear(); - } - return bRet; -} FX_BOOL CPDF_Creator::Create(IFX_StreamWrite* pFile, FX_DWORD flags) { if (!pFile) { return FALSE; diff --git a/core/src/fxcrt/fx_basic_buffer.cpp b/core/src/fxcrt/fx_basic_buffer.cpp index 77884c63c0..deb8133489 100644 --- a/core/src/fxcrt/fx_basic_buffer.cpp +++ b/core/src/fxcrt/fx_basic_buffer.cpp @@ -327,34 +327,6 @@ FX_BOOL CFX_FileBufferArchive::AttachFile(IFX_StreamWrite* pFile, m_bTakeover = bTakeover; return TRUE; } -FX_BOOL CFX_FileBufferArchive::AttachFile(const FX_WCHAR* filename) { - if (!filename) { - return FALSE; - } - if (m_pFile && m_bTakeover) { - m_pFile->Release(); - } - m_pFile = FX_CreateFileWrite(filename); - if (!m_pFile) { - return FALSE; - } - m_bTakeover = TRUE; - return TRUE; -} -FX_BOOL CFX_FileBufferArchive::AttachFile(const FX_CHAR* filename) { - if (!filename) { - return FALSE; - } - if (m_pFile && m_bTakeover) { - m_pFile->Release(); - } - m_pFile = FX_CreateFileWrite(filename); - if (!m_pFile) { - return FALSE; - } - m_bTakeover = TRUE; - return TRUE; -} FX_BOOL CFX_FileBufferArchive::DoWork(const void* pBuf, size_t size) { if (!m_pFile) { return FALSE; diff --git a/core/src/fxcrt/fx_extension.cpp b/core/src/fxcrt/fx_extension.cpp index 0f610d2717..d64a06d08b 100644 --- a/core/src/fxcrt/fx_extension.cpp +++ b/core/src/fxcrt/fx_extension.cpp @@ -36,12 +36,6 @@ IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename, } return new CFX_CRTFileStream(pFA); } -IFX_FileWrite* FX_CreateFileWrite(const FX_CHAR* filename) { - return FX_CreateFileStream(filename, FX_FILEMODE_Truncate); -} -IFX_FileWrite* FX_CreateFileWrite(const FX_WCHAR* filename) { - return FX_CreateFileStream(filename, FX_FILEMODE_Truncate); -} IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename) { return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly); } -- cgit v1.2.3