#!/bin/sh

FILE=$1
SIZE=$2

if [ -z "$FILE" ]; then
	echo "Usage: "pad FILE SIZE""
	exit 1
fi

fsize=$(wc -c $FILE | cut -d " " -f 1)
pad=$(expr $SIZE - $fsize)
if [ $pad -lt 0 ]; then
	echo "File size $fsize is larger than total, padded size $SIZE."
	exit 1
fi
echo "Padding $FILE from $fsize to $SIZE... padding with $pad bytes"
if [ $pad -gt 0 ]; then
	dd if=/dev/zero bs=$pad count=1 2>/dev/null >> $FILE
fi

