comparison bin/cek.pl @ 613:1a996b35eaab

Style updates
author nanaya <me@nanaya.pro>
date Mon, 02 Apr 2018 17:44:25 +0900
parents 5bafb912837e
children 70355e17653e
comparison
equal deleted inserted replaced
612:b305f2ce5f88 613:1a996b35eaab
4 use warnings; 4 use warnings;
5 use String::CRC32; 5 use String::CRC32;
6 use File::Basename; 6 use File::Basename;
7 7
8 my @files = @ARGV or print("Usage: ",basename($0)," file1 file2 ... fileN\n") && exit(1); 8 my @files = @ARGV or print("Usage: ",basename($0)," file1 file2 ... fileN\n") && exit(1);
9 my $num_ok=0; 9 my $num_ok = 0;
10 my $num_err=0; 10 my $num_err = 0;
11 my $num_nf=0; 11 my $num_nf = 0;
12 my $num_na=@files; 12 my $num_na = @files;
13 13
14 foreach(@files) { 14 foreach (@files) {
15 my $filename = $_; 15 my $filename = $_;
16 my ($name_crc,$real_crc); 16 my ($name_crc,$real_crc);
17 unless (-f $filename) { 17
18 $num_nf++;$num_na--; 18 unless (-f $filename) {
19 print(qq(Could not find "$filename", skipping\n)); 19 $num_nf++;
20 next(); 20 $num_na--;
21 } 21 print(qq(Could not find "$filename", skipping\n));
22 if(/(\[|\()([0-9A-F]{8})(\]|\))/i){ 22 next();
23 $name_crc=uc($2); 23 }
24 } 24
25 open(FILE,"<",$filename); 25 if (/(\[|\()([0-9A-F]{8})(\]|\))/i){
26 binmode(FILE); 26 $name_crc = uc($2);
27 $real_crc=sprintf("%08X",crc32(*FILE)); 27 }
28 close(FILE); 28
29 if($name_crc) { 29 open(FILE,"<",$filename);
30 $num_na--; 30 binmode(FILE);
31 if($name_crc eq $real_crc) { 31 $real_crc = sprintf("%08X",crc32(*FILE));
32 $num_ok++; 32 close(FILE);
33 print("$filename: OK - $real_crc\n"); 33
34 } else { 34 if ($name_crc) {
35 $num_err++; 35 $num_na--;
36 print("$filename: NOT OK - $real_crc, should be $name_crc\n"); 36 if($name_crc eq $real_crc) {
37 } 37 $num_ok++;
38 } else { 38 print("$filename: OK - $real_crc\n");
39 print("$filename: $real_crc\n"); 39 } else {
40 } 40 $num_err++;
41 print("$filename: NOT OK - $real_crc, should be $name_crc\n");
42 }
43 } else {
44 print("$filename: $real_crc\n");
45 }
41 } 46 }
42 47
43 printf("%s\n","-"x40); 48 printf("%s\n","-"x40);
44 if($num_ok > 0) { print("Files OK: $num_ok\n"); } 49 if ($num_ok > 0) {
45 if($num_err > 0) { print("Files error: $num_err\n"); } 50 print("Files OK: $num_ok\n");
46 if($num_nf > 0) { print("Files not found: $num_nf\n"); } 51 }
47 if($num_na > 0) { print("Files without crc information: $num_na\n"); } 52 if ($num_err > 0) {
53 print("Files error: $num_err\n");
54 }
55 if ($num_nf > 0) {
56 print("Files not found: $num_nf\n");
57 }
58 if ($num_na > 0) {
59 print("Files without crc information: $num_na\n");
60 }
48 61
49 exit(0); 62 exit(0);