19 int64_t old_position = file.get_position();
20 file.set_position(start);
22 constexpr uint32_t chunks = 2048;
25 int64_t current_size = 0;
30 if (current_size + int64_t(block_size) > size)
31 block_size = size_t(size - current_size);
33 const size_t read_count = file.read_data(&hashing_buffer[0], block_size);
34 current_size += int64_t(read_count);
36 for (uint32_t i = 0; i < full_chunks; i++)
40 if (remainder || current_size >= size || read_count == 0)
45 uint64_t(current_size)
51 file.set_position(old_position);
80 constexpr int buffer_count = 256;
82 if (size < 4 * file.buffer.ssize * buffer_count)
83 return get_hash(file, start, size);
86 const int64_t old_position = file.get_position();
89 for (
int i = 0; i < buffer_count; i++)
91 int64_t buffer_position;
94 buffer_position = start;
95 else if (i == buffer_count - 1)
96 buffer_position = start + size - file.buffer.ssize;
99 buffer_position = file.buffer.ssize *
101 (start + i * size) / (file.buffer.ssize * (buffer_count - 1))
105 file.pread(file.buffer.data, file.buffer.size, buffer_position);
111 file.set_position(old_position);