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

unzip return value #35

Open
cstepper opened this issue May 17, 2019 · 5 comments
Open

unzip return value #35

cstepper opened this issue May 17, 2019 · 5 comments
Labels
feature a feature request or enhancement

Comments

@cstepper
Copy link

Hi Gabor,
I really like the zip package.

We'd like to use the unzip command and need the path to the unzipped file.

The utils::unzip function returns:
Otherwise for the "internal" method, a character vector of the filepaths extracted to, invisibly.

In the zip::unzip the return is invisible().

I'm not familiar with the calling of C code in the unzip function

.Call(c_R_zip_unzip, zipfile, files, overwrite, junkpaths, exdir)

and what it does return.

If it would be possible to implement a return as a character vector of the filepaths extracted to, it would be great.

Thanks, Christoph

@gaborcsardi
Copy link
Member

Right, that would indeed make sense. It is not too hard to work around it, though, just call zip_list() before extracting and use the filename column:

zip::zip("/tmp/x.zip", "works/zip/R")
❯ exdir <- tempfile()
❯ zip::unzip("/tmp/x.zip", exdir= exdir)
❯ files <- file.path(exdir, zip::zip_list("/tmp/x.zip")$filename)
❯ file.exists(files)
[1] TRUE TRUE TRUE TRUE TRUE

It should not be too slow, because AFAIR zip_list() does not go through the whole file, it only checks the index.

@cstepper
Copy link
Author

Hi Gabar,
thanks for that hint. Used the work around for now.
Would be nice to see the feature in future :)
Cheers, Christoph

@gaborcsardi
Copy link
Member

Yes, will add that at some point, it will probably return a data frame, though, to be able to add more data to it.

@cstepper
Copy link
Author

perfect!

@gaborcsardi
Copy link
Member

Wait, don't close this, because then I'll forget. :)

@gaborcsardi gaborcsardi reopened this May 17, 2019
@gaborcsardi gaborcsardi added the feature a feature request or enhancement label May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature a feature request or enhancement
Projects
None yet
Development

No branches or pull requests

2 participants