1

I am working on a small cli in rust and I would like to create a tgz file from a directory. I would like to exclude some files and directories from it though. For example I would like to exclude any .custom files from any directories.

I ended up using tar and workdir crates but somehow code I end up with seems very complicated … Also, seems tar crate doesn’t support excluding files or directories as the cli does.

So what I do is using workdir to loop over all files in the directory, filtering files I want to exclude and add one by one file in the archive.

Is there a magic way of doing it simply?

Thanks a lot !

BenjaminC
  • 169
  • 7
  • This probably isn't the best solution, but if you know how to use the cli tar command, you can spawn it via [`std::process::Command`](https://doc.rust-lang.org/std/process/struct.Command.html) – Misty Jun 06 '21 at 11:07
  • Thanks @Misty, indeed, I would like to avoid doing such things :) – BenjaminC Jun 06 '21 at 11:48

0 Answers0