-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdkill.pl
executable file
·40 lines (31 loc) · 1.07 KB
/
dkill.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
38
39
40
#!/usr/bin/perl -w
use strict;
# Beeb Utilities to manipulate MMB and SSD files
# Copyright (C) 2012 Stephen Harris
#
# See file "COPYING" for GPLv2 licensing
use FindBin;
use lib "$FindBin::Bin";
use BeebUtils;
@ARGV=BeebUtils::init(@ARGV);
my $force=0;
if (@ARGV && $ARGV[0] eq '-y') { $force=1; shift @ARGV; }
my $dr=$ARGV[0];
die "Syntax: $BeebUtils::PROG [-f MMB_file] [-y] image_number [R]\n" unless defined($dr);
die "Not a number\n" unless $dr=~/^[0-9]+$/;
my $restore=0; $restore=1 if $ARGV[1];
my $disktable=BeebUtils::LoadDiskTable();
my %disk=BeebUtils::load_dcat();
die "Disk $dr not valid\n" if !$disk{$dr}{Formatted} && !$restore;
die "Disk $dr not deleted\n" if $disk{$dr}{Formatted} && $restore;
die "Disk $dr ($disk{$dr}{DiskTitle}) is locked\n" if $disk{$dr}{ReadOnly} && !$force;
print "Deleting disk $dr: $disk{$dr}{DiskTitle}\n";
if (!$restore && !$force)
{
print "Are you sure (Y/N)? ";
my $x=<STDIN>;
if ($x!~/^[Yy]/) { exit; }
}
BeebUtils::DeleteSlot($dr,$restore,\$disktable);
BeebUtils::SaveDiskTable(\$disktable);
print $restore?"Restored\n":"Removed\n";