Skip to content

Commit

Permalink
(#145) Decode in finddepth before re-encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
Difegue committed Aug 1, 2019
1 parent 6d3de41 commit bb9d2f0
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/LANraragi/Utils/Archive.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use File::Path qw(remove_tree);
use File::Find qw(finddepth);
use File::Copy qw(move);
use Encode;
use Encode::Guess qw/euc-jp shiftjis 7bit-jis/;
use Redis;
use Cwd;
use Data::Dumper;
Expand Down Expand Up @@ -52,8 +53,9 @@ sub extract_archive {
unless ($_ eq '.') {
# Use Encode's coderef feature to map non-ascii characters to their Unicode codepoint equivalent.
# This makes it so that only pure ascii ends up put in the filesystem by LRR.
move($_, encode("ascii", $_,
sub{ sprintf "U+%04X", shift })) || die "Failed to move file: $!";
# Decoding from the filesystem's original name is done using Encode::Guess
move($_, encode("ascii", decode ("Guess", $_),
sub{ sprintf "U+%04X", shift }));
}
}, $ae->extract_path);

Expand Down

0 comments on commit bb9d2f0

Please sign in to comment.