• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 The PDFium Authors
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 <stddef.h>
11 #include <stdint.h>
12 
13 #include "build/build_config.h"
14 #include "core/fxcrt/fileaccess_iface.h"
15 #include "core/fxcrt/fx_types.h"
16 
17 #if !BUILDFLAG(IS_POSIX)
18 #error "Included on the wrong platform"
19 #endif
20 
21 class CFX_FileAccess_Posix final : public FileAccessIface {
22  public:
23   CFX_FileAccess_Posix();
24   ~CFX_FileAccess_Posix() override;
25 
26   // FileAccessIface:
27   bool Open(ByteStringView fileName) override;
28   void Close() override;
29   FX_FILESIZE GetSize() const override;
30   FX_FILESIZE GetPosition() const override;
31   FX_FILESIZE SetPosition(FX_FILESIZE pos) override;
32   size_t Read(pdfium::span<uint8_t> buffer) override;
33   size_t Write(pdfium::span<const uint8_t> buffer) override;
34   size_t ReadPos(pdfium::span<uint8_t> buffer, FX_FILESIZE pos) override;
35   bool Flush() override;
36   bool Truncate(FX_FILESIZE szFile) override;
37 
38  private:
39   int32_t m_nFD = -1;
40 };
41 
42 #endif  // CORE_FXCRT_CFX_FILEACCESS_POSIX_H_
43