7#include "core/fxcrt/cfx_fileaccess_posix.h"
15#include "core/fxcrt/fx_stream.h"
16#include "third_party/base/numerics/safe_conversions.h"
28 return std::make_unique<CFX_FileAccess_Posix>();
37bool CFX_FileAccess_Posix::
Open(ByteStringView fileName) {
47void CFX_FileAccess_Posix::
Close() {
59 memset(&s, 0,
sizeof(s));
61 return pdfium::base::checked_cast<
FX_FILESIZE>(s.st_size);
67 return lseek(m_nFD, 0, SEEK_CUR);
73 return lseek(m_nFD, pos, SEEK_SET);
75size_t CFX_FileAccess_Posix::
Read(
void* pBuffer, size_t szBuffer) {
79 return read(m_nFD, pBuffer, szBuffer);
81size_t CFX_FileAccess_Posix::
Write(
const void* pBuffer, size_t szBuffer) {
85 return write(m_nFD, pBuffer, szBuffer);
99 return Read(pBuffer, szBuffer);
110 return Write(pBuffer, szBuffer);
117 return fsync(m_nFD) > -1;
124 return !ftruncate(m_nFD, szFile);
~CFX_FileAccess_Posix() override
size_t ReadPos(void *pBuffer, size_t szBuffer, FX_FILESIZE pos) override
size_t Write(const void *pBuffer, size_t szBuffer) override
FX_FILESIZE GetSize() const override
size_t WritePos(const void *pBuffer, size_t szBuffer, FX_FILESIZE pos) override
size_t Read(void *pBuffer, size_t szBuffer) override
FX_FILESIZE SetPosition(FX_FILESIZE pos) override
bool Open(ByteStringView fileName) override
bool Truncate(FX_FILESIZE szFile) override
FX_FILESIZE GetPosition() const override