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 "core/fxcrt/extension.h" | 7 #include "core/fxcrt/extension.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 22 matching lines...) Expand all Loading... | |
33 IFX_FileAccess* CFX_CRTFileAccess::Retain() { | 33 IFX_FileAccess* CFX_CRTFileAccess::Retain() { |
34 m_RefCount++; | 34 m_RefCount++; |
35 return (IFX_FileAccess*)this; | 35 return (IFX_FileAccess*)this; |
36 } | 36 } |
37 | 37 |
38 void CFX_CRTFileAccess::GetPath(CFX_WideString& wsPath) { | 38 void CFX_CRTFileAccess::GetPath(CFX_WideString& wsPath) { |
39 wsPath = m_path; | 39 wsPath = m_path; |
40 } | 40 } |
41 | 41 |
42 IFX_SeekableStream* CFX_CRTFileAccess::CreateFileStream(uint32_t dwModes) { | 42 IFX_SeekableStream* CFX_CRTFileAccess::CreateFileStream(uint32_t dwModes) { |
43 return FX_CreateFileStream(m_path.c_str(), dwModes); | 43 return IFX_SeekableStream::CreateFromFilename(m_path.c_str(), dwModes); |
44 } | 44 } |
45 | 45 |
46 bool CFX_CRTFileAccess::Init(const CFX_WideStringC& wsPath) { | 46 bool CFX_CRTFileAccess::Init(const CFX_WideStringC& wsPath) { |
47 m_path = wsPath; | 47 m_path = wsPath; |
48 m_RefCount = 1; | 48 m_RefCount = 1; |
49 return true; | 49 return true; |
50 } | 50 } |
51 | 51 |
52 #endif // PDF_ENABLE_XFA | 52 #endif // PDF_ENABLE_XFA |
53 | 53 |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
331 IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath) { | 331 IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath) { |
332 if (wsPath.GetLength() == 0) | 332 if (wsPath.GetLength() == 0) |
333 return nullptr; | 333 return nullptr; |
334 | 334 |
335 CFX_CRTFileAccess* pFA = new CFX_CRTFileAccess; | 335 CFX_CRTFileAccess* pFA = new CFX_CRTFileAccess; |
336 pFA->Init(wsPath); | 336 pFA->Init(wsPath); |
337 return pFA; | 337 return pFA; |
338 } | 338 } |
339 #endif // PDF_ENABLE_XFA | 339 #endif // PDF_ENABLE_XFA |
340 | 340 |
341 IFX_SeekableStream* FX_CreateFileStream(const FX_CHAR* filename, | 341 // static |
342 uint32_t dwModes) { | 342 IFX_SeekableStream* IFX_SeekableStream::CreateFromFilename( |
npm
2016/11/30 22:58:00
Are there creates that are not from filename, or w
Tom Sepez
2016/11/30 23:09:44
In theory, you could make a seekable stream out of
| |
343 const FX_CHAR* filename, | |
344 uint32_t dwModes) { | |
343 std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create()); | 345 std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create()); |
344 if (!pFA->Open(filename, dwModes)) | 346 if (!pFA->Open(filename, dwModes)) |
345 return nullptr; | 347 return nullptr; |
346 return new CFX_CRTFileStream(std::move(pFA)); | 348 return new CFX_CRTFileStream(std::move(pFA)); |
347 } | 349 } |
348 | 350 |
349 IFX_SeekableStream* FX_CreateFileStream(const FX_WCHAR* filename, | 351 // static |
350 uint32_t dwModes) { | 352 IFX_SeekableStream* IFX_SeekableStream::CreateFromFilename( |
353 const FX_WCHAR* filename, | |
354 uint32_t dwModes) { | |
351 std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create()); | 355 std::unique_ptr<IFXCRT_FileAccess> pFA(IFXCRT_FileAccess::Create()); |
352 if (!pFA->Open(filename, dwModes)) | 356 if (!pFA->Open(filename, dwModes)) |
353 return nullptr; | 357 return nullptr; |
354 return new CFX_CRTFileStream(std::move(pFA)); | 358 return new CFX_CRTFileStream(std::move(pFA)); |
355 } | 359 } |
356 IFX_SeekableReadStream* FX_CreateFileRead(const FX_CHAR* filename) { | 360 |
357 return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly); | 361 // static |
362 IFX_SeekableReadStream* IFX_SeekableReadStream::CreateFromFilename( | |
363 const FX_CHAR* filename) { | |
364 return IFX_SeekableStream::CreateFromFilename(filename, FX_FILEMODE_ReadOnly); | |
358 } | 365 } |
359 IFX_SeekableReadStream* FX_CreateFileRead(const FX_WCHAR* filename) { | 366 |
360 return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly); | 367 // static |
361 } | 368 IFX_MemoryStream* IFX_MemoryStream::Create(uint8_t* pBuffer, |
362 IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, | 369 size_t dwSize, |
363 size_t dwSize, | 370 bool bTakeOver) { |
364 bool bTakeOver) { | |
365 return new CFX_MemoryStream(pBuffer, dwSize, bTakeOver); | 371 return new CFX_MemoryStream(pBuffer, dwSize, bTakeOver); |
366 } | 372 } |
367 IFX_MemoryStream* FX_CreateMemoryStream(bool bConsecutive) { | 373 |
374 // static | |
375 IFX_MemoryStream* IFX_MemoryStream::Create(bool bConsecutive) { | |
368 return new CFX_MemoryStream(bConsecutive); | 376 return new CFX_MemoryStream(bConsecutive); |
369 } | 377 } |
370 | 378 |
371 FX_FLOAT FXSYS_tan(FX_FLOAT a) { | 379 FX_FLOAT FXSYS_tan(FX_FLOAT a) { |
372 return (FX_FLOAT)tan(a); | 380 return (FX_FLOAT)tan(a); |
373 } | 381 } |
374 FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x) { | 382 FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x) { |
375 return FXSYS_log(x) / FXSYS_log(b); | 383 return FXSYS_log(x) / FXSYS_log(b); |
376 } | 384 } |
377 FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr, | 385 FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr, |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
612 b = ((const uint8_t*)pGUID)[i]; | 620 b = ((const uint8_t*)pGUID)[i]; |
613 *pBuf++ = gs_FX_pHexChars[b >> 4]; | 621 *pBuf++ = gs_FX_pHexChars[b >> 4]; |
614 *pBuf++ = gs_FX_pHexChars[b & 0x0F]; | 622 *pBuf++ = gs_FX_pHexChars[b & 0x0F]; |
615 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { | 623 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { |
616 *pBuf++ = L'-'; | 624 *pBuf++ = L'-'; |
617 } | 625 } |
618 } | 626 } |
619 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); | 627 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); |
620 } | 628 } |
621 #endif // PDF_ENABLE_XFA | 629 #endif // PDF_ENABLE_XFA |
OLD | NEW |