Mercurial > ec-dotfiles
annotate bin/cek.pl @ 688:17cacf387f7c
Update vendor
...also update scripts to support syntax subdirectories
author | nanaya <me@nanaya.pro> |
---|---|
date | Fri, 21 Oct 2022 20:17:06 +0900 |
parents | 70355e17653e |
children |
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; |
614 | 5 use Compress::Zlib; |
124
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); | |
614 | 31 my $file_crc = 0; |
32 my $file_part = ''; | |
33 while (read(FILE, $file_part, 4096)) { | |
34 $file_crc = crc32($file_part, $file_crc); | |
35 } | |
613 | 36 close(FILE); |
614 | 37 $real_crc = sprintf("%08X", $file_crc); |
613 | 38 |
39 if ($name_crc) { | |
40 $num_na--; | |
41 if($name_crc eq $real_crc) { | |
42 $num_ok++; | |
43 print("$filename: OK - $real_crc\n"); | |
44 } else { | |
45 $num_err++; | |
46 print("$filename: NOT OK - $real_crc, should be $name_crc\n"); | |
47 } | |
48 } else { | |
49 print("$filename: $real_crc\n"); | |
50 } | |
124
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
51 } |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
52 |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
53 printf("%s\n","-"x40); |
613 | 54 if ($num_ok > 0) { |
55 print("Files OK: $num_ok\n"); | |
56 } | |
57 if ($num_err > 0) { | |
58 print("Files error: $num_err\n"); | |
59 } | |
60 if ($num_nf > 0) { | |
61 print("Files not found: $num_nf\n"); | |
62 } | |
63 if ($num_na > 0) { | |
64 print("Files without crc information: $num_na\n"); | |
65 } | |
124
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
66 |
5bafb912837e
Massive addition of old scripts collection.
Edho Prima Arief <edho@myconan.net>
parents:
diff
changeset
|
67 exit(0); |