• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #ifndef CORE_FXCRT_CFX_FILEACCESS_POSIX_H_
8 #define CORE_FXCRT_CFX_FILEACCESS_POSIX_H_
9 
10 #include "build/build_config.h"
11 #include "core/fxcrt/fileaccess_iface.h"
12 #include "core/fxcrt/fx_system.h"
13 
14 #if _FX_PLATFORM_ != _FX_PLATFORM_LINUX_ && !defined(OS_MACOSX) && \
15     !defined(OS_ANDROID)
16 #error "Included on the wrong platform"
17 #endif
18 
19 class CFX_FileAccess_Posix final : public FileAccessIface {
20  public:
21   CFX_FileAccess_Posix();
22   ~CFX_FileAccess_Posix() override;
23 
24   // FileAccessIface:
25   bool Open(ByteStringView fileName, uint32_t dwMode) override;
26   bool Open(WideStringView fileName, uint32_t dwMode) override;
27   void Close() override;
28   FX_FILESIZE GetSize() const override;
29   FX_FILESIZE GetPosition() const override;
30   FX_FILESIZE SetPosition(FX_FILESIZE pos) override;
31   size_t Read(void* pBuffer, size_t szBuffer) override;
32   size_t Write(const void* pBuffer, size_t szBuffer) override;
33   size_t ReadPos(void* pBuffer, size_t szBuffer, FX_FILESIZE pos) override;
34   size_t WritePos(const void* pBuffer,
35                   size_t szBuffer,
36                   FX_FILESIZE pos) override;
37   bool Flush() override;
38   bool Truncate(FX_FILESIZE szFile) override;
39 
40  private:
41   int32_t m_nFD;
42 };
43 
44 #endif  // CORE_FXCRT_CFX_FILEACCESS_POSIX_H_
45