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 !

Popular Backend topics Top

PragmaticBookshelf
Real-time applications come with real challenges—persistent connections, multi-server deployment, and strict performance requirements are...
New
DevotionGeo
How Dgraph was running out of memory for some users, and how Go’s Garbage collector wasn’t enough, and Dgraph team used jemalloc to manag...
New
First poster: bot
Ruby on Rails v6.1.0 has been released. Link: Release 6.1.0 · rails/rails · GitHub
New
joshi
Hey everybody! I’m working on the project that includes import of Oracle data to PostgreSQL. That data comes as Oracle export (expdp) fi...
New
OvermindDL1
Woooooooo! This is such a huge release for it, and 2 years incoming! In short, the library is now using an updated hyper backend (not j...
New
PragmaticBookshelf
SQL Antipatterns is a short-cut to wisdom, showing you how to avoid "easy" solutions that don't work, and be a better database developer ...
New
mafinar
This is going to be a long an frequently posted thread. While talking to a friend of mine who has taken data structure and algorithm cou...
New
First poster: bot
Node.js v14.19.0 has been released. Link: Release 2022-02-01, Version 14.19.0 'Fermium' (LTS), @richardlau · nodejs/node · GitHub
New
JimmyCarterSon
Hello, I am. very new to Elixir lang I have only been doing it for about 2 weeks. I recently started following this tutorial todo list, ...
New
Fl4m3Ph03n1x
Background I am trying to encode a structure into json format using the Jason library. However, this is not working as expected. Code L...
New

Other popular topics Top

PragmaticBookshelf
A PragProg Hero’s Journey with Brian P. Hogan @bphogan Have you ever worried that your only legacy will be in the form of legacy...
New
AstonJ
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New
PragmaticBookshelf
“A Mystical Experience” Hero’s Journey with Paolo Perrotta @nusco Ever wonder how authoring books compares to writing articles?...
New
gagan7995
API 4 Path: /user/following/ Method: GET Description: Returns the list of all names of people whom the user follows Response [ { ...
New
AstonJ
Saw this on TikTok of all places! :lol: Anyone heard of them before? Lite:
New
mafinar
This is going to be a long an frequently posted thread. While talking to a friend of mine who has taken data structure and algorithm cou...
New
PragmaticBookshelf
Build efficient applications that exploit the unique benefits of a pure functional language, learning from an engineer who uses Haskell t...
New
New
Help
I am trying to crate a game for the Nintendo switch, I wanted to use Java as I am comfortable with that programming language. Can you use...
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New