forked from BASLQC/kc-vita-translation
-
Notifications
You must be signed in to change notification settings - Fork 3
/
unpack_original_files.pl
44 lines (40 loc) · 1.53 KB
/
unpack_original_files.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
use 5.010;
use strictures 2;
use IO::All -binary;
use Capture::Tiny 'capture';
use Time::HiRes 'time';
use lib '.';
use countdown;
run();
# this whole thing works a bit oddly. since asset files are interlinked, we need
# the resources.resource file despite never unpacking it, and we also can only
# delete things after unpacking.
sub run {
my $target = "../kc_original_unpack/repatch/PCSG00684/Media";
io($target)->mkpath;
chdir "../kc_original_unpack/repatch/PCSG00684/Media";
my @files = io("../../../../kc_original/repatch/PCSG00684/Media/")->all_files;
$_->copy( "./" . $_->filename ) for @files;
my $unity_ex = io("../../../../unity_tools/UnityEX.exe")->absolute->pathname;
for my $file ( grep !/resources\.resource/, io(".")->all_files ) {
say "unpacking file $file'";
my ( $out, $err, $res ) = capture { system qq["$unity_ex" export $file] };
warn "\n$out" if $out;
warn "\n$err" if $err;
}
io($_)->unlink for @files;
my $has_find = -e "c:/cygwin/bin/find.exe";
say "has find: $has_find";
my @list = $has_find ? split /\n/, `c:/cygwin/bin/find "." -type f` #
: io(".")->All_Files;
@list = grep /\.(gobj|4|dds|fsb|snd|[\d]+|script|txt|shader|ani|obj|cbm|mesh|xml|smd)$/, @list;
say "deleting";
my $ctd = countdown->new( total => scalar @list );
$|++;
while (@list) {
my @sublist = splice @list, 0, ( @list >= 100 ) ? 100 : @list;
unlink $_ for @sublist;
$ctd->update( scalar @sublist );
}
return;
}