Go to the documentation of this file.
16#ifndef LIEF_FILE_STREAM_H
17#define LIEF_FILE_STREAM_H
32 static result<FileStream>
from_file(
const std::string& file);
34 BinaryStream(STREAM_TYPE::FILE),
45 FileStream&
operator=(FileStream&& other)
noexcept =
default;
47 uint64_t
size()
const override {
54 static bool classof(
const BinaryStream& stream) {
55 return stream.
type() == STREAM_TYPE::FILE;
59 uint64_t = 0)
const override {
60 if (offset > size_ || offset + size > size_) {
63 const auto pos = ifs_.tellg();
65 ifs_.read(
static_cast<char*
>(dst), size);
70 result<const void*>
read_at(uint64_t, uint64_t, uint64_t)
const override {
75 mutable std::ifstream ifs_;
Class that is used to a read stream of data from different sources.
Definition BinaryStream.hpp:33
STREAM_TYPE type() const
Definition BinaryStream.hpp:53
Stream interface over a std::ifstream
Definition FileStream.hpp:30
static result< FileStream > from_file(const std::string &file)
FileStream(FileStream &&other) noexcept=default
FileStream(std::ifstream fs, uint64_t size)
Definition FileStream.hpp:33
ok_error_t peek_in(void *dst, uint64_t offset, uint64_t size, uint64_t=0) const override
Definition FileStream.hpp:58
std::vector< uint8_t > content() const
FileStream & operator=(FileStream &&other) noexcept=default
FileStream(const FileStream &)=delete
~FileStream() override=default
static bool classof(const BinaryStream &stream)
Definition FileStream.hpp:54
result< const void * > read_at(uint64_t, uint64_t, uint64_t) const override
Definition FileStream.hpp:70
uint64_t size() const override
Definition FileStream.hpp:47
FileStream & operator=(const FileStream &)=delete
@ not_supported
Definition errors.hpp:27
@ read_error
Definition errors.hpp:24
tl::unexpected< lief_errors > make_error_code(lief_errors e)
Create an standard error code from lief_errors.
Definition errors.hpp:52
LIEF namespace.
Definition Abstract/Binary.hpp:36
result< ok_t > ok_error_t
Opaque structure that is used by LIEF to avoid writing result<void> f(...). Instead,...
Definition errors.hpp:109
ok_t ok()
Return success for function with return type ok_error_t.
Definition errors.hpp:93
#define LIEF_API
Definition visibility.h:41