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/fxcrt_windows.h" | 7 #include "core/fxcrt/fxcrt_windows.h" |
8 | 8 |
9 #include "core/fxcrt/include/fx_string.h" | 9 #include "core/fxcrt/include/fx_string.h" |
10 | 10 |
11 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 11 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
12 IFXCRT_FileAccess* FXCRT_FileAccess_Create() { | 12 |
| 13 // static |
| 14 IFXCRT_FileAccess* IFXCRT_FileAccess::Create() { |
13 return new CFXCRT_FileAccess_Win64; | 15 return new CFXCRT_FileAccess_Win64; |
14 } | 16 } |
| 17 |
15 void FXCRT_Windows_GetFileMode(uint32_t dwMode, | 18 void FXCRT_Windows_GetFileMode(uint32_t dwMode, |
16 uint32_t& dwAccess, | 19 uint32_t& dwAccess, |
17 uint32_t& dwShare, | 20 uint32_t& dwShare, |
18 uint32_t& dwCreation) { | 21 uint32_t& dwCreation) { |
19 dwAccess = GENERIC_READ; | 22 dwAccess = GENERIC_READ; |
20 dwShare = FILE_SHARE_READ | FILE_SHARE_WRITE; | 23 dwShare = FILE_SHARE_READ | FILE_SHARE_WRITE; |
21 if (!(dwMode & FX_FILEMODE_ReadOnly)) { | 24 if (!(dwMode & FX_FILEMODE_ReadOnly)) { |
22 dwAccess |= GENERIC_WRITE; | 25 dwAccess |= GENERIC_WRITE; |
23 dwCreation = (dwMode & FX_FILEMODE_Truncate) ? CREATE_ALWAYS : OPEN_ALWAYS; | 26 dwCreation = (dwMode & FX_FILEMODE_Truncate) ? CREATE_ALWAYS : OPEN_ALWAYS; |
24 } else { | 27 } else { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 } | 71 } |
69 return m_hFile != NULL; | 72 return m_hFile != NULL; |
70 } | 73 } |
71 void CFXCRT_FileAccess_Win64::Close() { | 74 void CFXCRT_FileAccess_Win64::Close() { |
72 if (!m_hFile) { | 75 if (!m_hFile) { |
73 return; | 76 return; |
74 } | 77 } |
75 ::CloseHandle(m_hFile); | 78 ::CloseHandle(m_hFile); |
76 m_hFile = NULL; | 79 m_hFile = NULL; |
77 } | 80 } |
78 void CFXCRT_FileAccess_Win64::Release() { | |
79 delete this; | |
80 } | |
81 FX_FILESIZE CFXCRT_FileAccess_Win64::GetSize() const { | 81 FX_FILESIZE CFXCRT_FileAccess_Win64::GetSize() const { |
82 if (!m_hFile) { | 82 if (!m_hFile) { |
83 return 0; | 83 return 0; |
84 } | 84 } |
85 LARGE_INTEGER size = {}; | 85 LARGE_INTEGER size = {}; |
86 if (!::GetFileSizeEx(m_hFile, &size)) { | 86 if (!::GetFileSizeEx(m_hFile, &size)) { |
87 return 0; | 87 return 0; |
88 } | 88 } |
89 return (FX_FILESIZE)size.QuadPart; | 89 return (FX_FILESIZE)size.QuadPart; |
90 } | 90 } |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 } | 163 } |
164 return ::FlushFileBuffers(m_hFile); | 164 return ::FlushFileBuffers(m_hFile); |
165 } | 165 } |
166 FX_BOOL CFXCRT_FileAccess_Win64::Truncate(FX_FILESIZE szFile) { | 166 FX_BOOL CFXCRT_FileAccess_Win64::Truncate(FX_FILESIZE szFile) { |
167 if (SetPosition(szFile) == (FX_FILESIZE)-1) { | 167 if (SetPosition(szFile) == (FX_FILESIZE)-1) { |
168 return FALSE; | 168 return FALSE; |
169 } | 169 } |
170 return ::SetEndOfFile(m_hFile); | 170 return ::SetEndOfFile(m_hFile); |
171 } | 171 } |
172 #endif | 172 #endif |
OLD | NEW |