OLD | NEW |
---|---|
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fgas/crt/fgas_stream.h" | 7 #include "xfa/fgas/crt/fgas_stream.h" |
8 | 8 |
9 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ | 9 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ |
10 _FX_OS_ == _FX_WIN64_ | 10 _FX_OS_ == _FX_WIN64_ |
(...skipping 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1445 pShared->m_iTotalSize = iLength; | 1445 pShared->m_iTotalSize = iLength; |
1446 pShared->m_iPosition = iStart; | 1446 pShared->m_iPosition = iStart; |
1447 pShared->m_iStart = iStart; | 1447 pShared->m_iStart = iStart; |
1448 pShared->m_iLength = (dwAccess & FX_STREAMACCESS_Write) != 0 ? 0 : iLength; | 1448 pShared->m_iLength = (dwAccess & FX_STREAMACCESS_Write) != 0 ? 0 : iLength; |
1449 if (dwAccess & FX_STREAMACCESS_Text) { | 1449 if (dwAccess & FX_STREAMACCESS_Text) { |
1450 return IFX_Stream::CreateTextStream(pShared, true); | 1450 return IFX_Stream::CreateTextStream(pShared, true); |
1451 } | 1451 } |
1452 return pShared; | 1452 return pShared; |
1453 } | 1453 } |
1454 | 1454 |
1455 IFX_SeekableReadStream* FX_CreateFileRead(IFX_Stream* pBaseStream, | 1455 IFX_SeekableReadStream* IFX_Stream::MakeSeekableReadStream() { |
npm
2016/11/30 22:58:00
Why make here instead of Create?
Tom Sepez
2016/11/30 23:09:44
Layering. IFX_SeekableReadStream is in core/ and
| |
1456 bool bReleaseStream) { | 1456 return new CFGAS_FileRead(this, false); |
1457 ASSERT(pBaseStream); | |
1458 return new CFGAS_FileRead(pBaseStream, bReleaseStream); | |
1459 } | 1457 } |
1460 | 1458 |
1461 CFGAS_FileRead::CFGAS_FileRead(IFX_Stream* pStream, bool bReleaseStream) | 1459 CFGAS_FileRead::CFGAS_FileRead(IFX_Stream* pStream, bool bReleaseStream) |
1462 : m_bReleaseStream(bReleaseStream), m_pStream(pStream) { | 1460 : m_bReleaseStream(bReleaseStream), m_pStream(pStream) { |
1463 ASSERT(m_pStream); | 1461 ASSERT(m_pStream); |
1464 } | 1462 } |
1465 CFGAS_FileRead::~CFGAS_FileRead() { | 1463 CFGAS_FileRead::~CFGAS_FileRead() { |
1466 if (m_bReleaseStream) { | 1464 if (m_bReleaseStream) { |
1467 m_pStream->Release(); | 1465 m_pStream->Release(); |
1468 } | 1466 } |
1469 } | 1467 } |
1470 FX_FILESIZE CFGAS_FileRead::GetSize() { | 1468 FX_FILESIZE CFGAS_FileRead::GetSize() { |
1471 return (FX_FILESIZE)m_pStream->GetLength(); | 1469 return (FX_FILESIZE)m_pStream->GetLength(); |
1472 } | 1470 } |
1473 | 1471 |
1474 bool CFGAS_FileRead::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) { | 1472 bool CFGAS_FileRead::ReadBlock(void* buffer, FX_FILESIZE offset, size_t size) { |
1475 m_pStream->Seek(FX_STREAMSEEK_Begin, (int32_t)offset); | 1473 m_pStream->Seek(FX_STREAMSEEK_Begin, (int32_t)offset); |
1476 int32_t iLen = m_pStream->ReadData((uint8_t*)buffer, (int32_t)size); | 1474 int32_t iLen = m_pStream->ReadData((uint8_t*)buffer, (int32_t)size); |
1477 return iLen == (int32_t)size; | 1475 return iLen == (int32_t)size; |
1478 } | 1476 } |
1479 | 1477 |
1480 void CFGAS_FileRead::Release() { | 1478 void CFGAS_FileRead::Release() { |
1481 delete this; | 1479 delete this; |
1482 } | 1480 } |
OLD | NEW |