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_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes) | 16 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes) |
86 { | 17 { |
87 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create(); | 18 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create(); |
88 if (!pFA) { | 19 if (!pFA) { |
89 return NULL; | 20 return NULL; |
90 } | 21 } |
91 if (!pFA->Open(filename, dwModes)) { | 22 if (!pFA->Open(filename, dwModes)) { |
92 pFA->Release(); | 23 pFA->Release(); |
93 return NULL; | 24 return NULL; |
94 } | 25 } |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 { | 306 { |
376 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 307 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
377 FX_GenerateCryptoRandom(pBuffer, iCount); | 308 FX_GenerateCryptoRandom(pBuffer, iCount); |
378 #else | 309 #else |
379 FX_Random_GenerateBase(pBuffer, iCount); | 310 FX_Random_GenerateBase(pBuffer, iCount); |
380 #endif | 311 #endif |
381 } | 312 } |
382 #ifdef __cplusplus | 313 #ifdef __cplusplus |
383 } | 314 } |
384 #endif | 315 #endif |
OLD | NEW |