25 while (size < 0 || done < size)
27 const size_t asked = size < 0
29 : size_t(std::min(int64_t(buffer.size()), size - done));
30 const size_t received = pread(buffer.data(), asked, start + done);
37 reading_past_end_of_file();
40 destination.pwrite(buffer.data(), received, start + done);
41 done += int64_t(received);
57 for (int64_t current = from; current < until;)
59 const size_t n0 = pread
62 size_t(std::min(int64_t(buffer.size()), until - current)),
70 const size_t n = destination.pread
72 destination_buffer.data() + n1,
87 reading_past_end_of_file();
89 const int diff = std::memcmp
92 destination_buffer.data(),
99 current += int64_t(n0);
109 throw Exception(
"Trying to read past the end of file");
117 const int64_t file_size = get_size();
121 blob.get_position() < 0 ||
122 blob.get_size() < 0 ||
123 (file_size >= 0 && blob.get_size() >= file_size)
126 reading_past_end_of_file();
130 Async_Reader reader(*
this, blob.get_position(), blob.get_end());
131 std::string result(
size_t(blob.get_size()), 0);
132 reader.
read(result.data(), result.size());
134 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