Mercurial > ec-dotfiles
annotate 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 |
rev | line source |
---|---|
124
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
1 #!/usr/bin/env perl |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
2 |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
3 use strict; |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
4 use warnings; |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
5 use String::CRC32; |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
6 use File::Basename; |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
7 |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
8 my @files = @ARGV or print("Usage: ",basename($0)," file1 file2 ... fileN\n") && exit(1); |
613 | 9 my $num_ok = 0; |
10 my $num_err = 0; | |
11 my $num_nf = 0; | |
12 my $num_na = @files; | |
13 | |
14 foreach (@files) { | |
15 my $filename = $_; | |
16 my ($name_crc,$real_crc); | |
17 | |
18 unless (-f $filename) { | |
19 $num_nf++; | |
20 $num_na--; | |
21 print(qq(Could not find "$filename", skipping\n)); | |
22 next(); | |
23 } | |
124
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
24 |
613 | 25 if (/(\[|\()([0-9A-F]{8})(\]|\))/i){ |
26 $name_crc = uc($2); | |
27 } | |
28 | |
29 open(FILE,"<",$filename); | |
30 binmode(FILE); | |
31 $real_crc = sprintf("%08X",crc32(*FILE)); | |
32 close(FILE); | |
33 | |
34 if ($name_crc) { | |
35 $num_na--; | |
36 if($name_crc eq $real_crc) { | |
37 $num_ok++; | |
38 print("$filename: OK - $real_crc\n"); | |
39 } else { | |
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 } | |
124
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
46 } |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
47 |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
48 printf("%s\n","-"x40); |
613 | 49 if ($num_ok > 0) { |
50 print("Files OK: $num_ok\n"); | |
51 } | |
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 } | |
124
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
61 |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
62 exit(0); |