| 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 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 CFXCRT_FileAccess_Win64::~CFXCRT_FileAccess_Win64() { | 40 CFXCRT_FileAccess_Win64::~CFXCRT_FileAccess_Win64() { |
| 41 Close(); | 41 Close(); |
| 42 } | 42 } |
| 43 FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_ByteStringC& fileName, | 43 FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_ByteStringC& fileName, |
| 44 uint32_t dwMode) { | 44 uint32_t dwMode) { |
| 45 if (m_hFile) { | 45 if (m_hFile) { |
| 46 return FALSE; | 46 return FALSE; |
| 47 } | 47 } |
| 48 uint32_t dwAccess, dwShare, dwCreation; | 48 uint32_t dwAccess, dwShare, dwCreation; |
| 49 FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation); | 49 FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation); |
| 50 m_hFile = ::CreateFileA(fileName.GetCStr(), dwAccess, dwShare, NULL, | 50 m_hFile = ::CreateFileA(fileName.c_str(), dwAccess, dwShare, NULL, dwCreation, |
| 51 dwCreation, FILE_ATTRIBUTE_NORMAL, NULL); | 51 FILE_ATTRIBUTE_NORMAL, NULL); |
| 52 if (m_hFile == INVALID_HANDLE_VALUE) { | 52 if (m_hFile == INVALID_HANDLE_VALUE) { |
| 53 m_hFile = NULL; | 53 m_hFile = NULL; |
| 54 } | 54 } |
| 55 return m_hFile != NULL; | 55 return m_hFile != NULL; |
| 56 } | 56 } |
| 57 FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_WideStringC& fileName, | 57 FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_WideStringC& fileName, |
| 58 uint32_t dwMode) { | 58 uint32_t dwMode) { |
| 59 if (m_hFile) { | 59 if (m_hFile) { |
| 60 return FALSE; | 60 return FALSE; |
| 61 } | 61 } |
| 62 uint32_t dwAccess, dwShare, dwCreation; | 62 uint32_t dwAccess, dwShare, dwCreation; |
| 63 FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation); | 63 FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation); |
| 64 m_hFile = ::CreateFileW((LPCWSTR)fileName.GetPtr(), dwAccess, dwShare, NULL, | 64 m_hFile = ::CreateFileW((LPCWSTR)fileName.raw_str(), dwAccess, dwShare, NULL, |
| 65 dwCreation, FILE_ATTRIBUTE_NORMAL, NULL); | 65 dwCreation, FILE_ATTRIBUTE_NORMAL, NULL); |
| 66 if (m_hFile == INVALID_HANDLE_VALUE) { | 66 if (m_hFile == INVALID_HANDLE_VALUE) { |
| 67 m_hFile = NULL; | 67 m_hFile = NULL; |
| 68 } | 68 } |
| 69 return m_hFile != NULL; | 69 return m_hFile != NULL; |
| 70 } | 70 } |
| 71 void CFXCRT_FileAccess_Win64::Close() { | 71 void CFXCRT_FileAccess_Win64::Close() { |
| 72 if (!m_hFile) { | 72 if (!m_hFile) { |
| 73 return; | 73 return; |
| 74 } | 74 } |
| (...skipping 88 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 |