| 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 "../../include/fxcrt/fx_basic.h" | 7 #include "../../include/fxcrt/fx_basic.h" |
| 8 #include "../../include/fxcrt/fx_ext.h" | 8 #include "../../include/fxcrt/fx_ext.h" |
| 9 #include "extension.h" | 9 #include "extension.h" |
| 10 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 10 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
| 11 #include <wincrypt.h> | 11 #include <wincrypt.h> |
| 12 #else | 12 #else |
| 13 #include <ctime> | 13 #include <ctime> |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 FX_HFILE FX_File_Open(const CFX_ByteStringC& fileName, FX_DWORD dwMode) | |
| 17 { | |
| 18 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create(); | |
| 19 if (pFA && !pFA->Open(fileName, dwMode)) { | |
| 20 pFA->Release(); | |
| 21 return NULL; | |
| 22 } | |
| 23 return (FX_HFILE)pFA; | |
| 24 } | |
| 25 FX_HFILE FX_File_Open(const CFX_WideStringC& fileName, FX_DWORD dwMode) | |
| 26 { | |
| 27 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create(); | |
| 28 if (pFA && !pFA->Open(fileName, dwMode)) { | |
| 29 pFA->Release(); | |
| 30 return NULL; | |
| 31 } | |
| 32 return (FX_HFILE)pFA; | |
| 33 } | |
| 34 void FX_File_Close(FX_HFILE hFile) | |
| 35 { | |
| 36 FXSYS_assert(hFile != NULL); | |
| 37 ((IFXCRT_FileAccess*)hFile)->Close(); | |
| 38 ((IFXCRT_FileAccess*)hFile)->Release(); | |
| 39 } | |
| 40 FX_FILESIZE FX_File_GetSize(FX_HFILE hFile) | |
| 41 { | |
| 42 FXSYS_assert(hFile != NULL); | |
| 43 return ((IFXCRT_FileAccess*)hFile)->GetSize(); | |
| 44 } | |
| 45 FX_FILESIZE FX_File_GetPosition(FX_HFILE hFile) | |
| 46 { | |
| 47 FXSYS_assert(hFile != NULL); | |
| 48 return ((IFXCRT_FileAccess*)hFile)->GetPosition(); | |
| 49 } | |
| 50 FX_FILESIZE FX_File_SetPosition(FX_HFILE hFile, FX_FILESIZE pos) | |
| 51 { | |
| 52 FXSYS_assert(hFile != NULL); | |
| 53 return ((IFXCRT_FileAccess*)hFile)->SetPosition(pos); | |
| 54 } | |
| 55 size_t FX_File_Read(FX_HFILE hFile, void* pBuffer, size_t szBuffer) | |
| 56 { | |
| 57 FXSYS_assert(hFile != NULL); | |
| 58 return ((IFXCRT_FileAccess*)hFile)->Read(pBuffer, szBuffer); | |
| 59 } | |
| 60 size_t FX_File_ReadPos(FX_HFILE hFile, void* pBuffer, size_t szBuffer, FX_FILESI
ZE pos) | |
| 61 { | |
| 62 FXSYS_assert(hFile != NULL); | |
| 63 return ((IFXCRT_FileAccess*)hFile)->ReadPos(pBuffer, szBuffer, pos); | |
| 64 } | |
| 65 size_t FX_File_Write(FX_HFILE hFile, const void* pBuffer, size_t szBuffer) | |
| 66 { | |
| 67 FXSYS_assert(hFile != NULL); | |
| 68 return ((IFXCRT_FileAccess*)hFile)->Write(pBuffer, szBuffer); | |
| 69 } | |
| 70 size_t FX_File_WritePos(FX_HFILE hFile, const void* pBuffer, size_t szBuffer, FX
_FILESIZE pos) | |
| 71 { | |
| 72 FXSYS_assert(hFile != NULL); | |
| 73 return ((IFXCRT_FileAccess*)hFile)->WritePos(pBuffer, szBuffer, pos); | |
| 74 } | |
| 75 FX_BOOL FX_File_Flush(FX_HFILE hFile) | |
| 76 { | |
| 77 FXSYS_assert(hFile != NULL); | |
| 78 return ((IFXCRT_FileAccess*)hFile)->Flush(); | |
| 79 } | |
| 80 FX_BOOL FX_File_Truncate(FX_HFILE hFile, FX_FILESIZE szFile) | |
| 81 { | |
| 82 FXSYS_assert(hFile != NULL); | |
| 83 return ((IFXCRT_FileAccess*)hFile)->Truncate(szFile); | |
| 84 } | |
| 85 IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath) | 16 IFX_FileAccess* FX_CreateDefaultFileAccess(const CFX_WideStringC& wsPath) |
| 86 { | 17 { |
| 87 if (wsPath.GetLength() == 0) | 18 if (wsPath.GetLength() == 0) |
| 88 return NULL; | 19 return NULL; |
| 89 | 20 |
| 90 CFX_CRTFileAccess* pFA = NULL; | 21 CFX_CRTFileAccess* pFA = NULL; |
| 91 pFA = FX_NEW CFX_CRTFileAccess; | 22 pFA = FX_NEW CFX_CRTFileAccess; |
| 92 if (NULL == pFA) return NULL; | 23 if (NULL == pFA) return NULL; |
| 93 | 24 |
| 94 pFA->Init(wsPath); | 25 pFA->Init(wsPath); |
| (...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 *pBuf ++ = gs_FX_pHexChars[b & 0x0F]; | 355 *pBuf ++ = gs_FX_pHexChars[b & 0x0F]; |
| 425 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { | 356 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { |
| 426 *pBuf ++ = L'-'; | 357 *pBuf ++ = L'-'; |
| 427 } | 358 } |
| 428 } | 359 } |
| 429 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); | 360 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); |
| 430 } | 361 } |
| 431 #ifdef __cplusplus | 362 #ifdef __cplusplus |
| 432 } | 363 } |
| 433 #endif | 364 #endif |
| OLD | NEW |