|
@@ -23,8 +23,8 @@ GetOptions ( { map { /^(\w+)/; $1 => $opts->{$_} } keys %$opts }, keys %$opts )
|
23
|
23
|
while ( my $filename = shift ) {
|
24
|
24
|
die "$filename is not a file\n" unless -f $filename;
|
25
|
25
|
my $oldsize = -s $filename;
|
26
|
|
- my $newsize = ( ( $oldsize + $blksize - 1 ) & ~( $blksize - 1 ) );
|
27
|
|
- my $padsize = ( $newsize - $oldsize );
|
|
26
|
+ my $padsize = ( ( -$oldsize ) % $blksize );
|
|
27
|
+ my $newsize = ( $oldsize + $padsize );
|
28
|
28
|
next unless $padsize;
|
29
|
29
|
if ( $verbosity >= 1 ) {
|
30
|
30
|
printf "Padding %s from %d to %d bytes with %d x 0x%02x\n",
|
|
@@ -40,5 +40,6 @@ while ( my $filename = shift ) {
|
40
|
40
|
truncate $filename, $newsize
|
41
|
41
|
or die "Could not resize $filename: $!\n";
|
42
|
42
|
}
|
43
|
|
- die "Failed to pad $filename\n" unless -s $filename == $newsize;
|
|
43
|
+ die "Failed to pad $filename\n"
|
|
44
|
+ unless ( ( ( -s $filename ) % $blksize ) == 0 );
|
44
|
45
|
}
|