#!/bin/bash

if [ $# -ne 3 ]; then
    echo >&2 "silentdd by bcov - a tool rapidly slice out a contiguous region of a silent file."
    echo >&2 "                   Allows you to avoid creating physical slices of silent files."
    echo >&2 "Usage:"
    echo >&2 "        -in:file:silent <( silentdd myfile.silent START_SEEK LENGTH )"
    echo >&2 ""
    echo >&2 "Note: See silentsplitdd for more info. You can't generate these inputs yourself."
    exit 1
fi

if [[ ! -f $1 ]]; then
    echo >&2 "silentdd: File not found: $1"
    exit 1
fi

echo "SEQUENCE: A"
echo "SCORE: score description"

if [[ $3 -eq -1 ]]; then
    dd if="$1" bs=8192 iflag=skip_bytes,count_bytes skip=$2
else
    dd if="$1" bs=8192 iflag=skip_bytes,count_bytes skip=$2 count=$3
fi


