blob: e3fb84e853f0872d464618c33588e714633d6e28 [file] [log] [blame]
rjw1f884582022-01-06 17:20:42 +08001#!/bin/bash
2
3FILE_PATH=$1
4ALIGNMENT=$2
5PADDING_SIZE=0
6
7FILE_SIZE=$(($(wc -c < "${FILE_PATH}")))
8REMAINDER=$((${FILE_SIZE} % ${ALIGNMENT}))
9FILE_DIR=$(dirname "${FILE_PATH}")
10if [ ${REMAINDER} -ne 0 ]; then
11 PADDING_SIZE=$((${ALIGNMENT} - ${REMAINDER}))
12 dd if=/dev/zero of=${FILE_DIR}/padding.txt bs=$PADDING_SIZE count=1
13 cat ${FILE_DIR}/padding.txt>>${FILE_PATH}
14 rm ${FILE_DIR}/padding.txt
15fi