| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "core/fxcrt/extension.h" | 9 #include "core/fxcrt/extension.h" |
| 10 #include "core/fxcrt/fx_basic.h" | 10 #include "core/fxcrt/fx_basic.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 | 29 |
| 30 IFX_FileAccess* CFX_CRTFileAccess::Retain() { | 30 IFX_FileAccess* CFX_CRTFileAccess::Retain() { |
| 31 m_RefCount++; | 31 m_RefCount++; |
| 32 return (IFX_FileAccess*)this; | 32 return (IFX_FileAccess*)this; |
| 33 } | 33 } |
| 34 | 34 |
| 35 void CFX_CRTFileAccess::GetPath(CFX_WideString& wsPath) { | 35 void CFX_CRTFileAccess::GetPath(CFX_WideString& wsPath) { |
| 36 wsPath = m_path; | 36 wsPath = m_path; |
| 37 } | 37 } |
| 38 | 38 |
| 39 IFX_FileStream* CFX_CRTFileAccess::CreateFileStream(uint32_t dwModes) { | 39 IFX_SeekableStream* CFX_CRTFileAccess::CreateFileStream(uint32_t dwModes) { |
| 40 return FX_CreateFileStream(m_path.c_str(), dwModes); | 40 return FX_CreateFileStream(m_path.c_str(), dwModes); |
| 41 } | 41 } |
| 42 | 42 |
| 43 FX_BOOL CFX_CRTFileAccess::Init(const CFX_WideStringC& wsPath) { | 43 FX_BOOL CFX_CRTFileAccess::Init(const CFX_WideStringC& wsPath) { |
| 44 m_path = wsPath; | 44 m_path = wsPath; |
| 45 m_RefCount = 1; | 45 m_RefCount = 1; |
| 46 return TRUE; | 46 return TRUE; |
| 47 } | 47 } |
| 48 | 48 |
| 49 #endif // PDF_ENABLE_XFA | 49 #endif // PDF_ENABLE_XFA |
| (...skipping 28 matching lines...) Expand all Loading... |
| 78 | 78 |
| 79 CFX_MemoryStream::~CFX_MemoryStream() { | 79 CFX_MemoryStream::~CFX_MemoryStream() { |
| 80 if (m_dwFlags & FX_MEMSTREAM_TakeOver) { | 80 if (m_dwFlags & FX_MEMSTREAM_TakeOver) { |
| 81 for (int32_t i = 0; i < m_Blocks.GetSize(); i++) { | 81 for (int32_t i = 0; i < m_Blocks.GetSize(); i++) { |
| 82 FX_Free(m_Blocks[i]); | 82 FX_Free(m_Blocks[i]); |
| 83 } | 83 } |
| 84 } | 84 } |
| 85 m_Blocks.RemoveAll(); | 85 m_Blocks.RemoveAll(); |
| 86 } | 86 } |
| 87 | 87 |
| 88 IFX_FileStream* CFX_MemoryStream::Retain() { | 88 IFX_SeekableStream* CFX_MemoryStream::Retain() { |
| 89 m_dwCount++; | 89 m_dwCount++; |
| 90 return this; | 90 return this; |
| 91 } | 91 } |
| 92 | 92 |
| 93 void CFX_MemoryStream::Release() { | 93 void CFX_MemoryStream::Release() { |
| 94 uint32_t nCount = --m_dwCount; | 94 uint32_t nCount = --m_dwCount; |
| 95 if (nCount) { | 95 if (nCount) { |
| 96 return; | 96 return; |
| 97 } | 97 } |
| 98 delete this; | 98 delete this; |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 size = (size - m_nTotalSize + m_nGrowSize - 1) / m_nGrowSize; | 274 size = (size - m_nTotalSize + m_nGrowSize - 1) / m_nGrowSize; |
| 275 m_Blocks.SetSize(m_Blocks.GetSize() + (int32_t)size); | 275 m_Blocks.SetSize(m_Blocks.GetSize() + (int32_t)size); |
| 276 while (size--) { | 276 while (size--) { |
| 277 uint8_t* pBlock = FX_Alloc(uint8_t, m_nGrowSize); | 277 uint8_t* pBlock = FX_Alloc(uint8_t, m_nGrowSize); |
| 278 m_Blocks.SetAt(iCount++, pBlock); | 278 m_Blocks.SetAt(iCount++, pBlock); |
| 279 m_nTotalSize += m_nGrowSize; | 279 m_nTotalSize += m_nGrowSize; |
| 280 } | 280 } |
| 281 return TRUE; | 281 return TRUE; |
| 282 } | 282 } |
| 283 | 283 |
| 284 IFX_FileStream* CFX_CRTFileStream::Retain() { | 284 IFX_SeekableStream* CFX_CRTFileStream::Retain() { |
| 285 m_dwCount++; | 285 m_dwCount++; |
| 286 return this; | 286 return this; |
| 287 } | 287 } |
| 288 | 288 |
| 289 void CFX_CRTFileStream::Release() { | 289 void CFX_CRTFileStream::Release() { |
| 290 uint32_t nCount = --m_dwCount; | 290 uint32_t nCount = --m_dwCount; |
| 291 if (!nCount) { | 291 if (!nCount) { |
| 292 delete this; | 292 delete this; |
| 293 } | 293 } |
| 294 } | 294 } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath) { | 329 IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath) { |
| 330 if (wsPath.GetLength() == 0) | 330 if (wsPath.GetLength() == 0) |
| 331 return nullptr; | 331 return nullptr; |
| 332 | 332 |
| 333 CFX_CRTFileAccess* pFA = new CFX_CRTFileAccess; | 333 CFX_CRTFileAccess* pFA = new CFX_CRTFileAccess; |
| 334 pFA->Init(wsPath); | 334 pFA->Init(wsPath); |
| 335 return pFA; | 335 return pFA; |
| 336 } | 336 } |
| 337 #endif // PDF_ENABLE_XFA | 337 #endif // PDF_ENABLE_XFA |
| 338 | 338 |
| 339 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, uint32_t dwModes) { | 339 IFX_SeekableStream* FX_CreateFileStream(const FX_CHAR* filename, |
| 340 uint32_t dwModes) { |
| 340 std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create()); | 341 std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create()); |
| 341 if (!pFA->Open(filename, dwModes)) | 342 if (!pFA->Open(filename, dwModes)) |
| 342 return nullptr; | 343 return nullptr; |
| 343 return new CFX_CRTFileStream(std::move(pFA)); | 344 return new CFX_CRTFileStream(std::move(pFA)); |
| 344 } | 345 } |
| 345 | 346 |
| 346 IFX_FileStream* FX_CreateFileStream(const FX_WCHAR* filename, | 347 IFX_SeekableStream* FX_CreateFileStream(const FX_WCHAR* filename, |
| 347 uint32_t dwModes) { | 348 uint32_t dwModes) { |
| 348 std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create()); | 349 std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create()); |
| 349 if (!pFA->Open(filename, dwModes)) | 350 if (!pFA->Open(filename, dwModes)) |
| 350 return nullptr; | 351 return nullptr; |
| 351 return new CFX_CRTFileStream(std::move(pFA)); | 352 return new CFX_CRTFileStream(std::move(pFA)); |
| 352 } | 353 } |
| 353 IFX_FileRead* FX_CreateFileRead(const FX_CHAR* filename) { | 354 IFX_SeekableReadStream* FX_CreateFileRead(const FX_CHAR* filename) { |
| 354 return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly); | 355 return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly); |
| 355 } | 356 } |
| 356 IFX_FileRead* FX_CreateFileRead(const FX_WCHAR* filename) { | 357 IFX_SeekableReadStream* FX_CreateFileRead(const FX_WCHAR* filename) { |
| 357 return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly); | 358 return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly); |
| 358 } | 359 } |
| 359 IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, | 360 IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, |
| 360 size_t dwSize, | 361 size_t dwSize, |
| 361 FX_BOOL bTakeOver) { | 362 FX_BOOL bTakeOver) { |
| 362 return new CFX_MemoryStream(pBuffer, dwSize, bTakeOver); | 363 return new CFX_MemoryStream(pBuffer, dwSize, bTakeOver); |
| 363 } | 364 } |
| 364 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive) { | 365 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive) { |
| 365 return new CFX_MemoryStream(bConsecutive); | 366 return new CFX_MemoryStream(bConsecutive); |
| 366 } | 367 } |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 609 b = ((const uint8_t*)pGUID)[i]; | 610 b = ((const uint8_t*)pGUID)[i]; |
| 610 *pBuf++ = gs_FX_pHexChars[b >> 4]; | 611 *pBuf++ = gs_FX_pHexChars[b >> 4]; |
| 611 *pBuf++ = gs_FX_pHexChars[b & 0x0F]; | 612 *pBuf++ = gs_FX_pHexChars[b & 0x0F]; |
| 612 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { | 613 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { |
| 613 *pBuf++ = L'-'; | 614 *pBuf++ = L'-'; |
| 614 } | 615 } |
| 615 } | 616 } |
| 616 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); | 617 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); |
| 617 } | 618 } |
| 618 #endif // PDF_ENABLE_XFA | 619 #endif // PDF_ENABLE_XFA |
| OLD | NEW |