How do I add an empty directory to a tarfile in python, without creating it on disk first?
Creating an empty directory in my local filesystem, and adding this to the tar-file is easy enough, but creates unnecessary overhead.
Creating one directly in the tar-file, however seems non-trivial.
My attempts looks like:
import tarfile
with tarfile.open("test.tbz2",mode='w:bz2') as t:
t.add("conf_dir") # does not work
t.add(tarfile.TarInfo("conf_dir")) # does not work
Use addfile() and change the TarInfo.type to tarfile.DIRTYPE