
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:
- Extract the contents of the tarball into a folder
- Add the extra files to said folder and move some items around
- 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
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










Other popular topics










Latest in Backend
Latest (all)
Categories:
Popular Portals
- /elixir
- /opensuse
- /rust
- /kotlin
- /ruby
- /erlang
- /python
- /clojure
- /react
- /quarkus
- /go
- /vapor
- /v
- /react-native
- /wasm
- /django
- /security
- /nodejs
- /centos
- /rails
- /haskell
- /fable
- /gleam
- /js
- /swift
- /deno
- /tailwind
- /assemblyscript
- /laravel
- /symfony
- /phoenix
- /crystal
- /typescript
- /debian
- /adonisjs
- /julia
- /arch-linux
- /svelte
- /spring
- /preact
- /flutter
- /c-plus-plus
- /actix
- /java
- /angular
- /ocaml
- /zig
- /kubuntu
- /scala
- /zotonic
- /vim
- /rocky
- /lisp
- /keyboards
- /html
- /vuejs
- /nim
- /emacs
- /elm
- /nerves