Skip to content

Commit

Permalink
Update AutoDecompress.rakumod
Browse files Browse the repository at this point in the history
Better implementation if other archive without using regex.
  • Loading branch information
Zer0-Tolerance authored Oct 30, 2022
1 parent 2015f5a commit b98839d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions lib/IO/Path/AutoDecompress.rakumod
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@ class IO::Path::AutoDecompress is IO::Path {
my $proc := run <bunzip2 --stdout>, self, :out;
$proc.out.lines(:$chomp, :$enc, :$nl-in)
}
elsif $extension eq '7z' {
my $proc := run <7z e -so>, self, :out;
$proc.out.lines(:$chomp, :$enc, :$nl-in)
}
elsif $extension eq 'rar' {
my $proc := run <unrar p>, self, :out;
$proc.out.lines(:$chomp, :$enc, :$nl-in)
}
elsif $extension eq 'zip' {
my $proc := run <7z e -so>, self, :out;
$proc.out.lines(:$chomp, :$enc, :$nl-in)
}
else {
self.IO::Path::lines(:$chomp, :$enc, :$nl-in)
}
Expand All @@ -28,6 +40,18 @@ class IO::Path::AutoDecompress is IO::Path {
my $proc := run <bunzip2 --stdout>, self, :out;
$proc.out.slurp(:$enc)
}
elsif $extension eq '7z' {
my $proc := run <7z e -so>, self, :out;
$proc.out.slurp(:$enc)
}
elsif $extension eq 'rar' {
my $proc := run <unrar p>, self, :out;
$proc.out.slurp(:$enc)
}
elsif $extension eq 'zip' {
my $proc := run <7z e -so>, self, :out;
$proc.out.slurp(:$enc)
}
else {
self.IO::Path::slurp(:$enc)
}
Expand Down

0 comments on commit b98839d

Please sign in to comment.