Expand description
§Drill-Press
A simple, cross platform crate for finding the locations of holes in sparse files.
Forked from Nathan McCarty’s hole_punch (git)
Currently supports Unix-like platforms that support the SEEK_HOLE and SEEK_DATA commands on lseek, as well as windows.
The operating systems that currently support filesystem-level sparsity information are:
- Linux
- Android
- FreeBSD
- Windows
- MacOS
These are currently implemented with a compile time switch, and SparseFile::scan_chunks will always immediately return with a ScanError::UnsupportedPlatform error on platforms not on this list.
§Usage
use std::fs::File;
use std::io::{Read, Seek, SeekFrom};
use drill_press::*;
if let Ok(mut file) = File::open("README.md") {
let segments = file.scan_chunks().expect("Unable to scan chunks");
for segment in segments.data() {
let start = segment.start;
let length = segment.end - segment.start;
file.seek(SeekFrom::Start(start));
let chunk = (&mut file).take(length);
}
}§License
Drill-Press is distributed under your choice of the MIT license, or Apache 2.0.
Structs§
- Segment
- Describes the location of a chunk in the file, as well as indicating if it contains data or is a hole
- Segment
Iter - An iterator over the ranges of a file of a specific
SegmentType
Enums§
- Scan
Error - Errors returned by
scan_chunks - Segment
Type - Flag for determining if a segment is a hole, or if it contains data
Traits§
- Segments
- An extention trait to filter segments by Hole or Data segments
- Sparse
File - An extention trait for
Filefor sparse files