hole-punch

Crates.iohole-punch
lib.rshole-punch
version0.0.3
sourcesrc
created_at2020-03-04 03:01:55.295988
updated_at2020-03-12 01:13:33.617654
descriptionA WIP cross platform library for extracting information about holes in sparse files.
homepage
repositoryhttps://gitlab.com/asuran-rs/hole-punch
max_upload_size
id215199
size57,136
Nathan McCarty (nmccarty)

documentation

https://docs.rs/hole-punch/0.0.0/hole_punch/

README

Hole-Punch

Crates.io License Unsafe Maintenance

A (wip) dead simple, cross platform crate for finding the locations of holes in sparse files.

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:

  1. Linux
  2. Android
  3. FreeBSD
  4. Windows

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 hole_punch::*;

let mut file = File::open("a big sparse file");
let segments = file.scan_chunks().expect("Unable to scan chunks");
for segment in segment {
    if let SegmentType::Data = segment.segment_type {
        let start = segment.start;
        let end = segment.end;

        let length = end - start;
        do_something_with_data(&mut file, start, length);
    }
}

License

Hole-Punch is distributed under your choice of the MIT license, or Apache 2.0.

TO-DOs

The following features are on my "to implement" list, in order of importance:

  1. Windows support
  2. Fallback mode (reading the entire file manually looking for chunks of 0s)
Commit count: 59

cargo fmt