• 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_FILEACCESS_IFACE_H_
8 #define CORE_FXCRT_FILEACCESS_IFACE_H_
9 
10 #include <memory>
11 
12 #include "core/fxcrt/fx_safe_types.h"
13 #include "core/fxcrt/fx_string.h"
14 
15 class FileAccessIface {
16  public:
17   static std::unique_ptr<FileAccessIface> Create();
18   virtual ~FileAccessIface() = default;
19 
20   virtual bool Open(ByteStringView fileName, uint32_t dwMode) = 0;
21   virtual bool Open(WideStringView fileName, uint32_t dwMode) = 0;
22   virtual void Close() = 0;
23   virtual FX_FILESIZE GetSize() const = 0;
24   virtual FX_FILESIZE GetPosition() const = 0;
25   virtual FX_FILESIZE SetPosition(FX_FILESIZE pos) = 0;
26   virtual size_t Read(void* pBuffer, size_t szBuffer) = 0;
27   virtual size_t Write(const void* pBuffer, size_t szBuffer) = 0;
28   virtual size_t ReadPos(void* pBuffer, size_t szBuffer, FX_FILESIZE pos) = 0;
29   virtual size_t WritePos(const void* pBuffer,
30                           size_t szBuffer,
31                           FX_FILESIZE pos) = 0;
32   virtual bool Flush() = 0;
33   virtual bool Truncate(FX_FILESIZE szFile) = 0;
34 };
35 
36 #endif  // CORE_FXCRT_FILEACCESS_IFACE_H_
37