Commit | Line | Data |
c7a4d1c0 |
1 | #!/usr/bin/perl -w |
2 | |
3 | use strict; |
4 | |
5 | die "$0: EPOCROOT unset\n" unless exists $ENV{EPOCROOT}; |
6 | die "$0: EPOCROOT directory does exists\n" unless -d $ENV{EPOCROOT}; |
7 | |
8 | my $EPOC32 = "$ENV{EPOCROOT}epoc32"; |
9 | my $EXE = "$EPOC32\\release\\thumb\\urel\\perlapp.app"; |
10 | my $RSC = "$EPOC32\\data\\z\\system\\apps\\perlapp\\perlapp.rsc"; |
11 | |
12 | use Fcntl qw(O_RDONLY); |
13 | |
14 | my %new = ($EXE => 'perlappmin.hex', |
15 | $RSC => 'perlrscmin.hex'); |
16 | |
17 | for my $fn ($EXE, $RSC) { |
18 | if (sysopen(my $fh, $fn, O_RDONLY)) { |
19 | my $buffer; |
20 | my $size = -s $fn; |
21 | my $read; |
22 | my $newfn = $new{$fn}; |
23 | unlink($newfn); |
24 | if (($read = sysread($fh, $buffer, $size)) == $size) { |
25 | if (open(my $newfh, ">$newfn")) { |
26 | binmode($newfh); |
27 | print $newfh unpack("H*", $buffer); |
28 | close($newfh); |
29 | print "Created $newfn\n"; |
30 | } else { |
31 | die qq[$0: open ">$newfn" failed: $!\n]; |
32 | } |
33 | } else { |
34 | die qq[$0: sysread $size returned $read\n]; |
35 | } |
36 | close($fh); |
37 | } else { |
38 | die qq[$0: sysopen "$fn": $!\n]; |
39 | } |
40 | } |
41 | |