summaryrefslogtreecommitdiff
path: root/core/fxcrt/ifx_fileaccess.h
blob: 9bfe2b4e63bede6b9db1068aa5864dfeeaecca21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Copyright 2014 PDFium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com

#ifndef CORE_FXCRT_IFX_FILEACCESS_H_
#define CORE_FXCRT_IFX_FILEACCESS_H_

#include <algorithm>
#include <memory>

#include "core/fxcrt/fx_safe_types.h"
#include "core/fxcrt/fx_stream.h"
#include "core/fxcrt/fx_string.h"

class IFX_FileAccess {
 public:
  static std::unique_ptr<IFX_FileAccess> Create();
  virtual ~IFX_FileAccess() {}

  virtual bool Open(const ByteStringView& fileName, uint32_t dwMode) = 0;
  virtual bool Open(const WideStringView& fileName, uint32_t dwMode) = 0;
  virtual void Close() = 0;
  virtual FX_FILESIZE GetSize() const = 0;
  virtual FX_FILESIZE GetPosition() const = 0;
  virtual FX_FILESIZE SetPosition(FX_FILESIZE pos) = 0;
  virtual size_t Read(void* pBuffer, size_t szBuffer) = 0;
  virtual size_t Write(const void* pBuffer, size_t szBuffer) = 0;
  virtual size_t ReadPos(void* pBuffer, size_t szBuffer, FX_FILESIZE pos) = 0;
  virtual size_t WritePos(const void* pBuffer,
                          size_t szBuffer,
                          FX_FILESIZE pos) = 0;
  virtual bool Flush() = 0;
  virtual bool Truncate(FX_FILESIZE szFile) = 0;
};

#endif  // CORE_FXCRT_IFX_FILEACCESS_H_