-
Notifications
You must be signed in to change notification settings - Fork 35
/
Copy pathreplacelocal.pl
49 lines (37 loc) · 931 Bytes
/
replacelocal.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
41
42
43
44
45
46
47
48
49
# perl
# livedl.exe内のローカルパスの文字列を隠す
use strict;
use v5.20;
for my $file("livedl.exe", "livedl.x86.exe", "livedl-logger.exe") {
open my $f, "<:raw", $file or die;
undef $/;
my $s = <$f>;
close $f;
say "$0: $file";
my %h = ();
while($s =~ m{(?<=\0)[^\0]{5,512}\.go(?=\0)|(?<=[[:cntrl:]])_/[A-Z]_/[^\0]{5,512}}g) {
my $s = $&;
if($s =~ m{\A(.*(?:/Users/.+?/go/src|/Go/src))(/.*)\z}s or
$s =~ m{\A(.*(?=/livedl/src/))(/.*)\z}s) {
my($all, $p, $f) = ($s, $1, $2);
my $p2 = $p;
$p2 =~ s{.}{*}gs;
#$h{$all} = $p2 . $f;
#say $p;
$h{$p} = $p2;
}
}
for my $k (sort{$a cmp $b} keys %h) {
my $k2 = $k;
$k2 =~ s{/}{\\}g;
my $r = quotemeta $k;
my $r2 = quotemeta $k2;
say "$k => $h{$k}";
$s =~ s{$r}{$h{$k}}g;
$s =~ s{$r2}{$h{$k}}g;
}
open $f, ">:raw", $file or die;
print $f $s;
close $f;
sleep 1;
}