| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 } | 45 } |
| 46 FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_ByteStringC& fileName, | 46 FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_ByteStringC& fileName, |
| 47 uint32_t dwMode) { | 47 uint32_t dwMode) { |
| 48 if (m_hFile) { | 48 if (m_hFile) { |
| 49 return FALSE; | 49 return FALSE; |
| 50 } | 50 } |
| 51 uint32_t dwAccess, dwShare, dwCreation; | 51 uint32_t dwAccess, dwShare, dwCreation; |
| 52 FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation); | 52 FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation); |
| 53 m_hFile = ::CreateFileA(fileName.c_str(), dwAccess, dwShare, NULL, dwCreation, | 53 m_hFile = ::CreateFileA(fileName.c_str(), dwAccess, dwShare, NULL, dwCreation, |
| 54 FILE_ATTRIBUTE_NORMAL, NULL); | 54 FILE_ATTRIBUTE_NORMAL, NULL); |
| 55 if (m_hFile == INVALID_HANDLE_VALUE) { | 55 if (m_hFile == INVALID_HANDLE_VALUE) |
| 56 m_hFile = NULL; | 56 m_hFile = NULL; |
| 57 } | 57 return !!m_hFile; |
| 58 return m_hFile != NULL; | |
| 59 } | 58 } |
| 60 FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_WideStringC& fileName, | 59 FX_BOOL CFXCRT_FileAccess_Win64::Open(const CFX_WideStringC& fileName, |
| 61 uint32_t dwMode) { | 60 uint32_t dwMode) { |
| 62 if (m_hFile) { | 61 if (m_hFile) { |
| 63 return FALSE; | 62 return FALSE; |
| 64 } | 63 } |
| 65 uint32_t dwAccess, dwShare, dwCreation; | 64 uint32_t dwAccess, dwShare, dwCreation; |
| 66 FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation); | 65 FXCRT_Windows_GetFileMode(dwMode, dwAccess, dwShare, dwCreation); |
| 67 m_hFile = ::CreateFileW((LPCWSTR)fileName.c_str(), dwAccess, dwShare, NULL, | 66 m_hFile = ::CreateFileW((LPCWSTR)fileName.c_str(), dwAccess, dwShare, NULL, |
| 68 dwCreation, FILE_ATTRIBUTE_NORMAL, NULL); | 67 dwCreation, FILE_ATTRIBUTE_NORMAL, NULL); |
| 69 if (m_hFile == INVALID_HANDLE_VALUE) { | 68 if (m_hFile == INVALID_HANDLE_VALUE) |
| 70 m_hFile = NULL; | 69 m_hFile = NULL; |
| 71 } | 70 return !!m_hFile; |
| 72 return m_hFile != NULL; | |
| 73 } | 71 } |
| 74 void CFXCRT_FileAccess_Win64::Close() { | 72 void CFXCRT_FileAccess_Win64::Close() { |
| 75 if (!m_hFile) { | 73 if (!m_hFile) { |
| 76 return; | 74 return; |
| 77 } | 75 } |
| 78 ::CloseHandle(m_hFile); | 76 ::CloseHandle(m_hFile); |
| 79 m_hFile = NULL; | 77 m_hFile = NULL; |
| 80 } | 78 } |
| 81 FX_FILESIZE CFXCRT_FileAccess_Win64::GetSize() const { | 79 FX_FILESIZE CFXCRT_FileAccess_Win64::GetSize() const { |
| 82 if (!m_hFile) { | 80 if (!m_hFile) { |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 } | 161 } |
| 164 return ::FlushFileBuffers(m_hFile); | 162 return ::FlushFileBuffers(m_hFile); |
| 165 } | 163 } |
| 166 FX_BOOL CFXCRT_FileAccess_Win64::Truncate(FX_FILESIZE szFile) { | 164 FX_BOOL CFXCRT_FileAccess_Win64::Truncate(FX_FILESIZE szFile) { |
| 167 if (SetPosition(szFile) == (FX_FILESIZE)-1) { | 165 if (SetPosition(szFile) == (FX_FILESIZE)-1) { |
| 168 return FALSE; | 166 return FALSE; |
| 169 } | 167 } |
| 170 return ::SetEndOfFile(m_hFile); | 168 return ::SetEndOfFile(m_hFile); |
| 171 } | 169 } |
| 172 #endif | 170 #endif |
| OLD | NEW |