24 const size_t read_count =
pread
28 offset + int64_t(result)
51 while (size < 0 || done < size)
53 const size_t asked = size < 0
55 : size_t(std::min(int64_t(buffer.size()), size - done));
56 const size_t received =
pread(buffer.data(), asked, start + done);
66 destination.pwrite(buffer.data(), received, start + done);
67 done += int64_t(received);
83 for (int64_t current = from; current < until;)
85 const size_t n0 =
pread
88 size_t(std::min(int64_t(buffer.size()), until - current)),
96 const size_t n = destination.pread
98 destination_buffer.data() + n1,
100 current + int64_t(n1)
115 const int diff = std::memcmp
118 destination_buffer.data(),
125 current += int64_t(n0);
135 throw Exception(
"Trying to read past the end of file");
144 blob.get_position() < 0 ||
145 blob.get_size() < 0 ||
146 blob.get_size() > max_size
152 std::string result(
size_t(blob.get_size()), 0);
153 full_pread(result.data(), result.size(), blob.get_position());
virtual void copy_to(Abstract_File &destination, int64_t start, int64_t size) const
Abstract_File(Open_Mode mode)
void full_pread(char *data, size_t size, int64_t offset) const
Fill the buffer, or throw if the end of the file is reached.
static void reading_past_end_of_file()
std::string read_blob(Blob blob, int64_t max_size=std::numeric_limits< int64_t >::max()) const
virtual bool equal_to(const Abstract_File &destination, int64_t from, int64_t until) const
virtual size_t pread(char *data, size_t size, int64_t offset) const
Read a range of bytes.
std::array< char, 1<< 12 > Default_Buffer