7#include "core/fxcrt/cfx_fileaccess_windows.h"
11#include "core/fxcrt/fx_stream.h"
12#include "core/fxcrt/fx_string.h"
16 return std::make_unique<CFX_FileAccess_Windows>();
30 m_hFile = ::CreateFileW(wname.c_str(), GENERIC_READ,
31 FILE_SHARE_READ | FILE_SHARE_WRITE,
nullptr,
32 OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL,
nullptr);
33 if (m_hFile == INVALID_HANDLE_VALUE)
39void CFX_FileAccess_Windows::
Close() {
43 ::CloseHandle(m_hFile);
51 LARGE_INTEGER size = {};
52 if (!::GetFileSizeEx(m_hFile, &size))
62 LARGE_INTEGER dist = {};
63 LARGE_INTEGER newPos = {};
64 if (!::SetFilePointerEx(m_hFile, dist, &newPos, FILE_CURRENT))
76 LARGE_INTEGER newPos = {};
77 if (!::SetFilePointerEx(m_hFile, dist, &newPos, FILE_BEGIN))
83size_t CFX_FileAccess_Windows::
Read(pdfium::span<uint8_t> buffer) {
88 if (!::ReadFile(m_hFile, buffer.data(), (DWORD)buffer.size(),
89 (LPDWORD)&szRead,
nullptr)) {
95size_t CFX_FileAccess_Windows::
Write(pdfium::span<
const uint8_t> buffer) {
100 if (!::WriteFile(m_hFile, buffer.data(), (DWORD)buffer.size(),
101 (LPDWORD)&szWrite,
nullptr)) {
121bool CFX_FileAccess_Windows::
Flush() {
125 return !!::FlushFileBuffers(m_hFile);
132 return !!::SetEndOfFile(m_hFile);
size_t ReadPos(pdfium::span< uint8_t > buffer, FX_FILESIZE pos) override
bool Open(ByteStringView fileName) override
size_t Write(pdfium::span< const uint8_t > buffer) override
size_t Read(pdfium::span< uint8_t > buffer) override
FX_FILESIZE GetSize() const override
FX_FILESIZE SetPosition(FX_FILESIZE pos) override
FX_FILESIZE GetPosition() const override
bool Truncate(FX_FILESIZE szFile) override
~CFX_FileAccess_Windows() override
static WideString FromUTF8(ByteStringView str)
fxcrt::ByteStringView ByteStringView
fxcrt::WideString WideString