1 ## -----------------------------------------------------------------------
3 ## Copyright 2007-2009 H. Peter Anvin - All Rights Reserved
5 ## This program is free software; you can redistribute it and/or modify
6 ## it under the terms of the GNU General Public License as published by
7 ## the Free Software Foundation, Inc., 53 Temple Place Ste 330,
8 ## Boston MA 02111-1307, USA; either version 2 of the License, or
9 ## (at your option) any later version; incorporated herein by reference.
11 ## -----------------------------------------------------------------------
16 ## Check the size of a binary file and pad it with zeroes to that size
21 ($file, $maxsize, $padsize) = @ARGV;
23 $padsize = $maxsize unless(defined($padsize));
25 open(FILE, '+<', $file) or die;
27 if (!defined($size = $st[7])) {
28 die "$0: $file: $!\n";
30 if ($size > $maxsize) {
31 print STDERR "$file: too big ($size > $maxsize)\n";
33 } elsif ($size < $padsize) {
35 print FILE "\0" x ($padsize-$size);