src/backup/dynamic_index.rs: add chunk_info method

This commit is contained in:
Dietmar Maurer 2019-05-21 09:52:19 +02:00
parent 015c5f6bfb
commit 40f4e198a8
1 changed files with 17 additions and 0 deletions

View File

@ -130,6 +130,23 @@ impl DynamicIndexReader {
Ok(())
}
pub fn chunk_info(&self, pos: usize) -> Result<(u64, u64, [u8; 32]), Error> {
if pos >= self.index_entries {
bail!("chunk index out of range");
}
let start = if pos == 0 {
0
} else {
unsafe { *(self.index.add((pos-1)*40) as *const u64) }
};
let end = unsafe { *(self.index.add(pos*40) as *const u64) };
let mut digest: [u8; 32] = unsafe { std::mem::uninitialized() };
unsafe { std::ptr::copy_nonoverlapping(self.index.add(pos*40+8), digest.as_mut_ptr(), 32); }
Ok((start, end, digest))
}
#[inline]
fn chunk_end(&self, pos: usize) -> u64 {
if pos >= self.index_entries {