25 while (size < 0 || done < size)
27 const size_t asked = size_t(std::min(int64_t(buffer.size()), size - done));
28 const size_t received = pread(buffer.data(), asked, start + done);
35 reading_past_end_of_file();
38 destination.pwrite(buffer.data(), received, start + done);
39 done += int64_t(received);
55 for (int64_t current = from; current < until;)
57 const size_t n0 = pread
60 size_t(std::min(int64_t(buffer.size()), until - current)),
68 const size_t n = destination.pread
70 destination_buffer.data() + n1,
85 reading_past_end_of_file();
87 const int diff = std::memcmp
90 destination_buffer.data(),
97 current += int64_t(n0);
107 throw Exception(
"Trying to read past the end of file");
114 Async_Reader reader(*
this, blob.get_position(), blob.get_end());
115 std::string result(
size_t(blob.get_size()), 0);
116 reader.
read(result.data(), result.size());
118 reading_past_end_of_file();
virtual void copy_to(Abstract_File &destination, int64_t start, int64_t size) const
static void reading_past_end_of_file()
std::string read_blob(Blob blob) const
virtual bool equal_to(const Abstract_File &destination, int64_t from, int64_t until) const
size_t read(char *buffer, size_t capacity)
bool is_end_of_file() const
std::array< char, 1<< 12 > Default_Buffer