Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for zip , rar, xz and 7z #1

Open
Zer0-Tolerance opened this issue Oct 22, 2022 · 4 comments
Open

Support for zip , rar, xz and 7z #1

Zer0-Tolerance opened this issue Oct 22, 2022 · 4 comments

Comments

@Zer0-Tolerance
Copy link

Hi Liz,
Great module ! It would be nice to have support for the other most common compressed archive.
It should'nt be much work as it seems you rely on the presence of gunzip & bunzip2 ?

@lizmat
Copy link
Owner

lizmat commented Oct 22, 2022

yeah, sure. Just tell me the name of the program to be used to decompress, and the extension(s) it uses. Or make a PR: the code is really pretty straightforward!

@Zer0-Tolerance
Copy link
Author

Zer0-Tolerance commented Oct 23, 2022

Here is the git diff as I can't create the pull request quickly:

diff --git a/lib/IO/Path/AutoDecompress.rakumod b/lib/IO/Path/AutoDecompress.rakumod
index 0bba26f..42da08a 100644
--- a/lib/IO/Path/AutoDecompress.rakumod
+++ b/lib/IO/Path/AutoDecompress.rakumod
@@ -13,6 +13,10 @@ class IO::Path::AutoDecompress is IO::Path {
             my $proc := run <bunzip2 --stdout>, self, :out;
             $proc.out.lines(:$chomp, :$enc, :$nl-in)
         }
+        elsif $extension ~~ /^(zip|rar|7z|xz|tar.gz|tgz)/ {
+            my $proc := run <7z e -so>, self, :out;
+            $proc.out.lines(:$chomp, :$enc, :$nl-in)
+        }
         else {
             self.IO::Path::lines(:$chomp, :$enc, :$nl-in)
         }

@lizmat
Copy link
Owner

lizmat commented Oct 23, 2022

Thanks!

However, this will require a little more to work than the current --auto-decompress, which only works on compresses **non-**archive files.

Getting support for archives is definitely on the list, so please have a little patience :-)

@Zer0-Tolerance
Copy link
Author

it's working with tgz but I agree it's not pretty but it does work:

 ~/p/IO-Path-AutoDecompress (main)> zef install . --force-install
===> Testing: IO::Path::AutoDecompress:ver<0.0.2>:auth<zef:lizmat>
===> Testing [OK] for IO::Path::AutoDecompress:ver<0.0.2>:auth<zef:lizmat>
===> Installing: IO::Path::AutoDecompress:ver<0.0.2>:auth<zef:lizmat>
 ~/p/IO-Path-AutoDecompress (main)> rak 111 --auto-decompress /tmp/*
/tmp/a
1:111

/tmp/a.7z
1:111

/tmp/a.tgz
1:tmp/a000644 000765 000000 00000000004 14324755155 013367 0ustar00wheel000000 000000 111

/tmp/a.zip
1:111

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants