summaryrefslogtreecommitdiff
path: root/core/fxcrt/fx_extension.cpp
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-05-19 17:31:01 -0700
committerCommit bot <commit-bot@chromium.org>2016-05-19 17:31:01 -0700
commit411f1185f44b7862a9b1c16e588407ae197752dd (patch)
treec02ce8943cd41b857c198ef5e5bc7ef847368199 /core/fxcrt/fx_extension.cpp
parent1f36fa860a170081f66809d634ec7ab83d7cb25e (diff)
downloadpdfium-411f1185f44b7862a9b1c16e588407ae197752dd.tar.xz
Remove Release() from IFXCRT_FileAccess.
Remove some unused impls. Review-Url: https://codereview.chromium.org/1994323002
Diffstat (limited to 'core/fxcrt/fx_extension.cpp')
-rw-r--r--core/fxcrt/fx_extension.cpp39
1 files changed, 14 insertions, 25 deletions
diff --git a/core/fxcrt/fx_extension.cpp b/core/fxcrt/fx_extension.cpp
index 1dddf09fd6..197022362f 100644
--- a/core/fxcrt/fx_extension.cpp
+++ b/core/fxcrt/fx_extension.cpp
@@ -4,6 +4,8 @@
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
+#include <utility>
+
#include "core/fxcrt/extension.h"
#include "core/fxcrt/include/fx_basic.h"
#include "core/fxcrt/include/fx_ext.h"
@@ -14,14 +16,10 @@
#include <ctime>
#endif
-CFX_CRTFileStream::CFX_CRTFileStream(IFXCRT_FileAccess* pFA)
- : m_pFile(pFA), m_dwCount(1) {}
+CFX_CRTFileStream::CFX_CRTFileStream(std::unique_ptr<IFXCRT_FileAccess> pFA)
+ : m_pFile(std::move(pFA)), m_dwCount(1) {}
-CFX_CRTFileStream::~CFX_CRTFileStream() {
- if (m_pFile) {
- m_pFile->Release();
- }
-}
+CFX_CRTFileStream::~CFX_CRTFileStream() {}
IFX_FileStream* CFX_CRTFileStream::Retain() {
m_dwCount++;
@@ -83,27 +81,18 @@ IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath) {
#endif // PDF_ENABLE_XFA
IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, uint32_t dwModes) {
- IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create();
- if (!pFA) {
- return NULL;
- }
- if (!pFA->Open(filename, dwModes)) {
- pFA->Release();
- return NULL;
- }
- return new CFX_CRTFileStream(pFA);
+ std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create());
+ if (!pFA->Open(filename, dwModes))
+ return nullptr;
+ return new CFX_CRTFileStream(std::move(pFA));
}
+
IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename,
uint32_t dwModes) {
- IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create();
- if (!pFA) {
- return NULL;
- }
- if (!pFA->Open(filename, dwModes)) {
- pFA->Release();
- return NULL;
- }
- return new CFX_CRTFileStream(pFA);
+ std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create());
+ if (!pFA->Open(filename, dwModes))
+ return nullptr;
+ return new CFX_CRTFileStream(std::move(pFA));
}
IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename) {
return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly);