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