summaryrefslogtreecommitdiff
path: root/fpdfsdk
diff options
context:
space:
mode:
Diffstat (limited to 'fpdfsdk')
-rw-r--r--fpdfsdk/fpdf_dataavail.cpp6
-rw-r--r--fpdfsdk/fpdfsave.cpp16
-rw-r--r--fpdfsdk/fpdfview.cpp56
-rw-r--r--fpdfsdk/fsdk_define.h12
4 files changed, 44 insertions, 46 deletions
diff --git a/fpdfsdk/fpdf_dataavail.cpp b/fpdfsdk/fpdf_dataavail.cpp
index 0bf67e9826..45d3b2aa5d 100644
--- a/fpdfsdk/fpdf_dataavail.cpp
+++ b/fpdfsdk/fpdf_dataavail.cpp
@@ -67,9 +67,9 @@ class CFPDF_FileAccessWrap : public IFX_SeekableReadStream {
// IFX_SeekableReadStream
FX_FILESIZE GetSize() override { return m_pFileAccess->m_FileLen; }
- FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override {
- return m_pFileAccess->m_GetBlock(m_pFileAccess->m_Param, offset,
- (uint8_t*)buffer, size);
+ bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override {
+ return !!m_pFileAccess->m_GetBlock(m_pFileAccess->m_Param, offset,
+ (uint8_t*)buffer, size);
}
void Release() override {}
diff --git a/fpdfsdk/fpdfsave.cpp b/fpdfsdk/fpdfsave.cpp
index 9cdc714f3f..03a9db1168 100644
--- a/fpdfsdk/fpdfsave.cpp
+++ b/fpdfsdk/fpdfsave.cpp
@@ -39,8 +39,8 @@
class CFX_IFileWrite final : public IFX_WriteStream {
public:
CFX_IFileWrite();
- FX_BOOL Init(FPDF_FILEWRITE* pFileWriteStruct);
- FX_BOOL WriteBlock(const void* pData, size_t size) override;
+ bool Init(FPDF_FILEWRITE* pFileWriteStruct);
+ bool WriteBlock(const void* pData, size_t size) override;
void Release() override;
protected:
@@ -53,20 +53,20 @@ CFX_IFileWrite::CFX_IFileWrite() {
m_pFileWriteStruct = nullptr;
}
-FX_BOOL CFX_IFileWrite::Init(FPDF_FILEWRITE* pFileWriteStruct) {
+bool CFX_IFileWrite::Init(FPDF_FILEWRITE* pFileWriteStruct) {
if (!pFileWriteStruct)
- return FALSE;
+ return false;
m_pFileWriteStruct = pFileWriteStruct;
- return TRUE;
+ return true;
}
-FX_BOOL CFX_IFileWrite::WriteBlock(const void* pData, size_t size) {
+bool CFX_IFileWrite::WriteBlock(const void* pData, size_t size) {
if (!m_pFileWriteStruct)
- return FALSE;
+ return false;
m_pFileWriteStruct->WriteBlock(m_pFileWriteStruct, pData, size);
- return TRUE;
+ return true;
}
void CFX_IFileWrite::Release() {
diff --git a/fpdfsdk/fpdfview.cpp b/fpdfsdk/fpdfview.cpp
index be56c531d2..03aedf6874 100644
--- a/fpdfsdk/fpdfview.cpp
+++ b/fpdfsdk/fpdfview.cpp
@@ -112,7 +112,7 @@ FX_FILESIZE CFPDF_FileStream::GetSize() {
return 0;
}
-FX_BOOL CFPDF_FileStream::IsEOF() {
+bool CFPDF_FileStream::IsEOF() {
return m_nCurPos >= GetSize();
}
@@ -120,18 +120,18 @@ FX_FILESIZE CFPDF_FileStream::GetPosition() {
return m_nCurPos;
}
-FX_BOOL CFPDF_FileStream::ReadBlock(void* buffer,
- FX_FILESIZE offset,
- size_t size) {
+bool CFPDF_FileStream::ReadBlock(void* buffer,
+ FX_FILESIZE offset,
+ size_t size) {
if (!buffer || !size || !m_pFS->ReadBlock)
- return FALSE;
+ return false;
if (m_pFS->ReadBlock(m_pFS->clientData, (FPDF_DWORD)offset, buffer,
(FPDF_DWORD)size) == 0) {
m_nCurPos = offset + size;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
size_t CFPDF_FileStream::ReadBlock(void* buffer, size_t size) {
@@ -153,23 +153,23 @@ size_t CFPDF_FileStream::ReadBlock(void* buffer, size_t size) {
return 0;
}
-FX_BOOL CFPDF_FileStream::WriteBlock(const void* buffer,
- FX_FILESIZE offset,
- size_t size) {
+bool CFPDF_FileStream::WriteBlock(const void* buffer,
+ FX_FILESIZE offset,
+ size_t size) {
if (!m_pFS || !m_pFS->WriteBlock)
- return FALSE;
+ return false;
if (m_pFS->WriteBlock(m_pFS->clientData, (FPDF_DWORD)offset, buffer,
(FPDF_DWORD)size) == 0) {
m_nCurPos = offset + size;
- return TRUE;
+ return true;
}
- return FALSE;
+ return false;
}
-FX_BOOL CFPDF_FileStream::Flush() {
+bool CFPDF_FileStream::Flush() {
if (!m_pFS || !m_pFS->Flush)
- return TRUE;
+ return true;
return m_pFS->Flush(m_pFS->clientData) == 0;
}
@@ -186,21 +186,21 @@ void CPDF_CustomAccess::Release() {
delete this;
}
-FX_BOOL CPDF_CustomAccess::ReadBlock(void* buffer,
- FX_FILESIZE offset,
- size_t size) {
- if (offset < 0) {
- return FALSE;
- }
+bool CPDF_CustomAccess::ReadBlock(void* buffer,
+ FX_FILESIZE offset,
+ size_t size) {
+ if (offset < 0)
+ return false;
+
FX_SAFE_FILESIZE newPos =
pdfium::base::checked_cast<FX_FILESIZE, size_t>(size);
newPos += offset;
if (!newPos.IsValid() ||
newPos.ValueOrDie() > static_cast<FX_FILESIZE>(m_FileAccess.m_FileLen)) {
- return FALSE;
+ return false;
}
- return m_FileAccess.m_GetBlock(m_FileAccess.m_Param, offset, (uint8_t*)buffer,
- size);
+ return !!m_FileAccess.m_GetBlock(m_FileAccess.m_Param, offset,
+ reinterpret_cast<uint8_t*>(buffer), size);
}
// 0 bit: FPDF_POLICY_MACHINETIME_ACCESS
@@ -388,18 +388,18 @@ class CMemFile final : public IFX_SeekableReadStream {
void Release() override { delete this; }
FX_FILESIZE GetSize() override { return m_size; }
- FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override {
+ bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override {
if (offset < 0) {
- return FALSE;
+ return false;
}
FX_SAFE_FILESIZE newPos =
pdfium::base::checked_cast<FX_FILESIZE, size_t>(size);
newPos += offset;
if (!newPos.IsValid() || newPos.ValueOrDie() > m_size) {
- return FALSE;
+ return false;
}
FXSYS_memcpy(buffer, m_pBuf + offset, size);
- return TRUE;
+ return true;
}
private:
diff --git a/fpdfsdk/fsdk_define.h b/fpdfsdk/fsdk_define.h
index 4fea138779..aeb42d2d11 100644
--- a/fpdfsdk/fsdk_define.h
+++ b/fpdfsdk/fsdk_define.h
@@ -33,7 +33,7 @@ class CPDF_CustomAccess final : public IFX_SeekableReadStream {
// IFX_SeekableReadStream
FX_FILESIZE GetSize() override;
void Release() override;
- FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
+ bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
private:
FPDF_FILEACCESS m_FileAccess;
@@ -49,14 +49,12 @@ class CFPDF_FileStream : public IFX_SeekableStream {
IFX_SeekableStream* Retain() override;
void Release() override;
FX_FILESIZE GetSize() override;
- FX_BOOL IsEOF() override;
+ bool IsEOF() override;
FX_FILESIZE GetPosition() override;
- FX_BOOL ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
+ bool ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) override;
size_t ReadBlock(void* buffer, size_t size) override;
- FX_BOOL WriteBlock(const void* buffer,
- FX_FILESIZE offset,
- size_t size) override;
- FX_BOOL Flush() override;
+ bool WriteBlock(const void* buffer, FX_FILESIZE offset, size_t size) override;
+ bool Flush() override;
void SetPosition(FX_FILESIZE pos) { m_nCurPos = pos; }