-
Notifications
You must be signed in to change notification settings - Fork 2
/
2tape.pl
executable file
·37 lines (31 loc) · 1.17 KB
/
2tape.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/perl
use strict;
# Written by Will Senn. Create a bootable SimH tap file to install the system.
# Inspired by various Perl scripts and based on Hellwig Geisse's mktape.c
#
# modified 20171012 binmode required for windows use
# This is just a hack to mount tapes for the 2.11 project
my @files = ("src.tar");
my @blkszs = (10240);
my $outfile = "src.tap";
my $EOF = "\x00\x00\x00\x00";
my $EOT = "\xFF\xFF\xFF\xFF";
open(OUTFILE, ">$outfile") || die("Unable to open $outfile: $!\n");
binmode(OUTFILE);
for(my $i = 0; $i <= $#files; $i++) {
my ($bytes, $blocksize, $buffer, $packedlen, $blockswritten, $file) = 0;
$file = $files[$i];
$blocksize = $blkszs[$i];
$packedlen = pack("V", $blocksize);
open(INFILE, $file) || die("Unable to open $file: $!\n");
binmode(INFILE);
while($bytes = read(INFILE, $buffer, $blocksize)) {
$buffer .= $bytes < $blocksize ? "\x00" x ($blocksize - $bytes) : "";
print OUTFILE $packedlen, $buffer, $packedlen;
$blockswritten++;
}
close(INFILE);
print OUTFILE $EOF;
printf "%s: %d bytes = %d records (blocksize %d bytes)\n", $file, $blockswritten * $blocksize, $blockswritten, $blocksize;
}
print OUTFILE $EOT