p7zip icon indicating copy to clipboard operation
p7zip copied to clipboard

Feature request: Pipeline (stdin, stdout, stderr)

Open sarether opened this issue 4 years ago • 7 comments

It's not implemented.

7z a BackupDir -so | zenity --progress 
System ERROR:
E_NOTIMPL

sarether avatar May 27 '21 01:05 sarether

7-zip does not allow streamed write of 7z format, it requires free seeking access as it writes, amongst the other stuff, header at the end of operation. It does allow to pipe standard *nix formats like bz2, gz, xz, though. It also allows to pipe single input without restrictions (-si switch).

tansy avatar May 27 '21 23:05 tansy

Yes. This is the request.

sarether avatar May 28 '21 00:05 sarether

It will not work. 7-zip must seek back to the beginning of the file to modify header where it saves position of footer (for some unknown reason called by dev end header). It is not possible in streamed output. Even zip cannot do that.

tansy avatar May 28 '21 06:05 tansy

Only archive format that is able to be send to standard output is tar:

$ 7z a -ttar -so -an <list of files> > archive.tar

Also "standard" *nix compressors, namely bzip2, gzip, xz:

$ cat archive.tar | 7z a -tgzip -si -so -an > archive.tar.gz

tansy avatar May 28 '21 13:05 tansy

Add dir to dir.tar.7z: 7z a dir -ttar -so -an | 7z a dir.tar.7z -si

Extract dir.tar.7z to dir: 7z x dir.tar.7z -so | tar -xvf -

But in dir.tar.7z at the top level is dir.tar, not files of the dir.

This works, but unevenly, because top level is dir.tar. 7z x dir.tar.7z -so | tar -xvf - | pv -n 2>&1 | zenity --progress

Probably without tar it will not work.

sarether avatar May 28 '21 14:05 sarether

Just to be clear - tar archive doesn't need backward seeking therefore can be written to stdout. Zip, 7z, rar formats need it so they can only be written into regular files.

Yes you can compress single file into .7z, whether it's tar or anything else, therefore you can put it into stdin of 7-zip but you cannot write .7z (or .zip or .rar) into stdout because you cannot seek backward in stdout stream.

Check How to recover corrupted 7z archive to see what it means. There is a description of format that explains why it is so.

tansy avatar May 29 '21 11:05 tansy

OK. Thanks.

sarether avatar May 29 '21 13:05 sarether