Fl4m3Ph03n1x

Fl4m3Ph03n1x

How to extract a tarball?

Background

I have a release file inside a tarball. However I want the final release to have some additional files and to move things around, for the convenience of the user.

This means I need to do 3 things:

  1. Extract the contents of the tarball into a folder
  2. Add the extra files to said folder and move some items around
  3. compress everything again and call it a day

Problem

While I have it clear on how to execute step 2, using File and friends, I have tried several ways to do steps 1 and 3 and I failed.

I have tried using :zip, but it returns a bad encoding error, probably because the file is not a zip but tar instead.

I am also aware of File.open("path", :read, :compressed), but I don’t want to read anything, I want to extract it into a new folder.

I also checked Unzip but it does not fit my use case.

Question

How can I extract a tar file into a folder and compress a folder into a tar file?

Marked As Solved

Fl4m3Ph03n1x

Fl4m3Ph03n1x

I was able to extract the file using:

:ok = :erl_tar.extract("tar_path", [{:cwd, "tmp"}, :compressed])

This will extract the tar file into the tmp folder. Once there I can do the rest !

Where Next?

Popular Backend topics Top

wolf4earth
At work we plan to replace a totally overkill Kafka instance with a combination of SNS and SQS. I don’t want to get into a discussion on ...
New
dimitarvp
Hey everyone, I resumed work on my Elixir <=> SQLite library (which uses a Rust NIF underneath) and I am in a need of small and we...
New
New
sampu
I have a use case where a client is invoking a Rest endpoint via a load balancer, which in turn invokes a third party endpoint which is r...
New
jeya
Dear Geeks I am new to pytest. I am following a youtube channel. I am writing the same code. learning to test login functionality of an...
New
sona11
In Java, if I try to do.equals() on a null string, a null pointer error is issued. I’m wondering whether I can perform the following if I...
New
harwind
I’m presently working on a backend development project to build a RESTful API using Python and Flask. The Scaler backend developer site h...
New
Fl4m3Ph03n1x
Background When trying to execute mix release on a Windows 11 machine for a Phoenix project I get the following error: * assembling mark...
New
harwind
I have a large SQL database with millions of records, and I’ve identified duplicate entries. What’s the most efficient way to find and re...
New
Shiny
Hey community, this is my first post here so I will try to be as concise as possible and I appreciate any feedback. I’ve been writing Ro...
New

Other popular topics Top

Exadra37
Please tell us what is your preferred monitor setup for programming(not gaming) and why you have chosen it. Does your monitor have eye p...
New
New
AstonJ
I’ve been hearing quite a lot of comments relating to the sound of a keyboard, with one of the most desirable of these called ‘thock’, he...
New
PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
New
AstonJ
I ended up cancelling my Moonlander order as I think it’s just going to be a bit too bulky for me. I think the Planck and the Preonic (o...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
AstonJ
Was just curious to see if any were around, found this one: I got 51/100: Not sure if it was meant to buy I am sure at times the b...
New
PragmaticBookshelf
Author Spotlight Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
New
PragmaticBookshelf
Author Spotlight: Tammy Coron @Paradox927 Gaming, and writing games in particular, is about passion, vision, experience, and immersio...
New
New