Merge branch '3906_zstd'

* 3906_zstd:
  Ticket #3906: ZSTD support.
This commit is contained in:
Andrew Borodin 2018-03-27 08:07:27 +03:00
commit b7ead57e0b
14 changed files with 74 additions and 5 deletions

View File

@ -893,6 +893,9 @@ get_compression_type (int fd, const char *name)
&& magic[2] == 0x7A && magic[3] == 0x58 && magic[4] == 0x5A && magic[5] == 0x00)
return COMPRESSION_XZ;
if (magic[0] == 0x28 && magic[1] == 0xB5 && magic[2] == 0x2F && magic[3] == 0xFD)
return COMPRESSION_ZSTD;
str_len = strlen (name);
/* HACK: we must belive to extension of LZMA file :) ... */
if ((str_len > 5 && strcmp (&name[str_len - 5], ".lzma") == 0) ||
@ -923,6 +926,8 @@ decompress_extension (int type)
return "/ulzma" VFS_PATH_URL_DELIMITER;
case COMPRESSION_XZ:
return "/uxz" VFS_PATH_URL_DELIMITER;
case COMPRESSION_ZSTD:
return "/uzst" VFS_PATH_URL_DELIMITER;
default:
break;
}

View File

@ -60,7 +60,8 @@ enum compression_type
COMPRESSION_LZIP,
COMPRESSION_LZ4,
COMPRESSION_LZMA,
COMPRESSION_XZ
COMPRESSION_XZ,
COMPRESSION_ZSTD,
};
/* stdout or stderr stream of child process */

View File

@ -35,6 +35,9 @@ do_view_action() {
xz)
xz -dc "${MC_EXT_FILENAME}" 2>/dev/null
;;
zst)
zstd -dc "${MC_EXT_FILENAME}" 2>/dev/null
;;
tar)
tar tvvf - < "${MC_EXT_FILENAME}"
;;
@ -66,6 +69,10 @@ do_view_action() {
xz -dc "${MC_EXT_FILENAME}" 2>/dev/null | \
tar tvvf -
;;
tar.zst|tzst)
zstd -dc "${MC_EXT_FILENAME}" 2>/dev/null | \
tar tvvf -
;;
tar.F)
freeze -dc "${MC_EXT_FILENAME}" 2>/dev/null | \
tar tvvf -
@ -107,6 +114,10 @@ do_view_action() {
xz -dc "${MC_EXT_FILENAME}" | \
cpio -itv 2>/dev/null
;;
cpio.zst)
zstd -dc "${MC_EXT_FILENAME}" | \
cpio -itv 2>/dev/null
;;
cpio)
cpio -itv < "${MC_EXT_FILENAME}" 2>/dev/null
;;
@ -158,6 +169,9 @@ do_open_action() {
xz)
xz -dc "${MC_EXT_FILENAME}" | ${pager}
;;
zst)
zstd -dc "${MC_EXT_FILENAME}" | ${pager}
;;
par2)
par2 r "${MC_EXT_FILENAME}"
;;

View File

@ -34,6 +34,9 @@ get_unpacker() {
man.xz)
unpacker="xz -dc"
;;
man.zst)
unpacker="zstd -dc"
;;
esac
echo ${unpacker}
}
@ -64,7 +67,7 @@ do_view_action() {
nroff.ms)
nroff @MAN_FLAGS@ -ms "${MC_EXT_FILENAME}"
;;
man.gz|man.bz|man.bz2|man.lz|man.lz4|man.lzma|man.xz)
man.gz|man.bz|man.bz2|man.lz|man.lz4|man.lzma|man.xz|man.zst)
case "${MC_EXT_FILENAME}" in
*/log/*|*/logs/*)
${unpacker} "${MC_EXT_FILENAME}"
@ -111,7 +114,7 @@ do_open_action() {
nroff.ms)
nroff @MAN_FLAGS@ -ms "${MC_EXT_FILENAME}" | ${pager}
;;
man.gz|man.bz|man.bz2|man.lz|man.lz4|man.lzma|man.xz)
man.gz|man.bz|man.bz2|man.lz|man.lz4|man.lzma|man.xz|man.zst)
case "${MC_EXT_FILENAME}" in
*/log/*|*/logs/*)
${unpacker} "${MC_EXT_FILENAME}"

View File

@ -28,7 +28,7 @@
regexp=(^#.*|.*~$)
[archive]
extensions=7z;Z;ace;arc;arj;ark;bz2;cab;gz;lha;lz;lz4;lzh;lzma;rar;rpm;tar;tbz;tbz2;tgz;tlz;txz;xz;zip;zoo
extensions=7z;Z;ace;arc;arj;ark;bz2;cab;gz;lha;lz;lz4;lzh;lzma;rar;rpm;tar;tbz;tbz2;tgz;tlz;txz;tzst;xz;zip;zoo;zst
[doc]
extensions=chm;css;ctl;diz;doc;docm;docx;dtd;htm;html;letter;lsm;mail;man;me;msg;nroff;odp;ods;odt;pdf;po;ppt;pptm;pptx;ps;rtf;sgml;shtml;tex;text;txt;xls;xlsm;xlsx;xml;xsd;xslt

View File

@ -150,6 +150,11 @@ regex/\.t(ar\.xz|xz)$
Open=%cd %p/utar://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view tar.xz
# .tar.zst, .tzst
regex/\.t(ar\.zst|zst)$
Open=%cd %p/utar://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view tar.zst
# .tar.F - used in QNX
shell/.tar.F
# Open=%cd %p/utar://
@ -212,6 +217,10 @@ shell/.cpio.xz
Open=%cd %p/ucpio://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view cpio.xz
shell/.cpio.zst
Open=%cd %p/ucpio://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view cpio.zst
shell/.cpio.gz
Open=%cd %p/ucpio://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view cpio.gz
@ -243,6 +252,10 @@ regex/\.(diff|patch)(\.xz)$
Open=%cd %p/patchfs://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view xz
regex/\.(diff|patch)(\.zst)$
Open=%cd %p/patchfs://
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zst
# ls-lR
regex/(^|\.)ls-?lR(\.gz|Z|bz2)$
Open=%cd %p/lslR://
@ -403,6 +416,10 @@ regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.xz$
Open=@EXTHELPERSDIR@/text.sh open man.xz %var{PAGER:more}
View=%view{ascii,nroff} @EXTHELPERSDIR@/text.sh view man.xz %var{PAGER:more}
regex/([^0-9]|^[^\.]*)\.([1-9][A-Za-z]*|[ln])\.zst$
Open=@EXTHELPERSDIR@/text.sh open man.zst %var{PAGER:more}
View=%view{ascii,nroff} @EXTHELPERSDIR@/text.sh view man.zst %var{PAGER:more}
# CHM
shell/i/.chm
Open=@EXTHELPERSDIR@/text.sh open chm
@ -790,6 +807,11 @@ regex/\.xz$
Open=@EXTHELPERSDIR@/archive.sh view xz %var{PAGER:more}
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view xz
# zstd
regex/\.zst$
Open=@EXTHELPERSDIR@/archive.sh view zst %var{PAGER:more}
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view zst
# Parity Archive
type/^Parity\ Archive\ Volume\ Set
Open=@EXTHELPERSDIR@/archive.sh open par2

View File

@ -84,6 +84,15 @@ shell_patterns=0
tar cf - "$Pwd" | xz -f > "$tar.tar.xz" && \
echo "../$tar.tar.xz created."
7 Compress the current subdirectory (tar.zst)
Pwd=`basename %d /`
echo -n "Name of the compressed file (without extension) [$Pwd]: "
read tar
[ "$tar"x = x ] && tar="$Pwd"
cd .. && \
tar cf - "$Pwd" | zstd -f > "$tar.tar.zst" && \
echo "../$tar.tar.zst created."
= f \.c$ & t r
+ f \.c$ & t r & ! t t
c Compile and link current .c file
@ -219,7 +228,7 @@ U Uudecode marked news articles (needs work)
fi
echo "Please test the output file before deleting anything."
=+ f \.tar\.gz$ | f \.tar\.z$ | f \.tgz$ | f \.tpz$ | f \.tar\.lz$ | f \.tar\.lz4$ | f \.tar\.lzma$ | f \.tar\.7z$ | f \.tar\.xz$ | f \.tar\.Z$ | f \.tar\.bz2$ & t r
=+ f \.tar\.gz$ | f \.tar\.z$ | f \.tgz$ | f \.tpz$ | f \.tar\.lz$ | f \.tar\.lz4$ | f \.tar\.lzma$ | f \.tar\.7z$ | f \.tar\.xz$ | f \.tar\.zst | f \.tar\.Z$ | f \.tar\.bz2$ & t r
x Extract the contents of a compressed tar file
unset PRG
case %f in
@ -230,6 +239,7 @@ x Extract the contents of a compressed tar file
*.tar.lz4) PRG="lz4 -dc";;
*.tar.lzma) PRG="lzma -dc";;
*.tar.xz) PRG="xz -dc";;
*.tar.zst) PRG="zstd -dc";;
*) exit 1;;
esac
$PRG %f | tar xvf -

View File

@ -1995,6 +1995,7 @@ wholechars abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._
keyword whole zoo cyan
keyword whole zsh cyan
keyword whole zsoelim cyan
keyword whole zstd cyan
keyword whole zxpdf cyan
keyword whole pamcut cyan

View File

@ -126,6 +126,7 @@ static const struct edit_filters
{
/* *INDENT-OFF* */
{ "xz -cd %s 2>&1", "xz > %s", ".xz"},
{ "zstd -cd %s 2>&1", "zstd > %s", ".zst"},
{ "lz4 -cd %s 2>&1", "lz4 > %s", ".lz4" },
{ "lzip -cd %s 2>&1", "lzip > %s", ".lz"},
{ "lzma -cd %s 2>&1", "lzma > %s", ".lzma" },

View File

@ -125,6 +125,7 @@ mcisofs_list () {
*.lz4) MYCAT="lz4 -dc";;
*.lzma) MYCAT="lzma -dc";;
*.xz) MYCAT="xz -dc";;
*.zst) MYCAT="zstd -dc";;
*.bz2) MYCAT="bzip2 -dc";;
*.gz) MYCAT="gzip -dc";;
*.z) MYCAT="gzip -dc";;

View File

@ -16,6 +16,7 @@ case "$1" in
*.lz4) MYCAT="lz4 -dc";;
*.lzma) MYCAT="lzma -dc";;
*.xz) MYCAT="xz -dc";;
*.zst) MYCAT="zstd -dc";;
*.bz2) MYCAT="bzip2 -dc";;
*.gz) MYCAT="gzip -dc";;
*.z) MYCAT="gzip -dc";;

View File

@ -11,6 +11,7 @@ $lzipcat="lzip -dc"; # unlzip to stdout
$lz4cat="lz4 -dc"; # unlz4 to stdout
$lzcat="lzma -dc"; # unlzma to stdout
$xzcat="xz -dc"; # unxz to stdout
$zstdcat="zstd -dc"; # unzstd to stdout
$file="file"; # "file" command
$TZ='GMT'; # default timezone (for Date module)
@ -194,6 +195,8 @@ if (/gzip/) {
exit 1 unless (open IN, "$lzcat $mbox_qname|");
} elsif (/xz/) {
exit 1 unless (open IN, "$xzcat $mbox_qname|");
} elsif (/zst/) {
exit 1 unless (open IN, "$zstdcat $mbox_qname|");
} else {
exit 1 unless (open IN, "<$mbox_name");
}

View File

@ -17,6 +17,7 @@ my $lzip = 'lzip';
my $lz4 = 'lz4';
my $lzma = 'lzma';
my $xz = 'xz';
my $zstd = 'zstd';
my $bzip = 'bzip2';
my $gzip = 'gzip';
my $fileutil = 'file -b';
@ -88,6 +89,8 @@ sub myin
return "$lzma -dc $qfname";
} elsif (/^'*xz/) {
return "$xz -dc $qfname";
} elsif (/^'*zst/) {
return "$zstd -dc $qfname";
} elsif (/^'*bzip/) {
return "$bzip -dc $qfname";
} elsif (/^'*gzip/) {
@ -112,6 +115,8 @@ sub myout
return "$lzma -c $sep $qfname";
} elsif (/^'*xz/) {
return "$xz -c $sep $qfname";
} elsif (/^'*zst/) {
return "$zstd -c $sep $qfname";
} elsif (/^'*bzip/) {
return "$bzip -c $sep $qfname";
} elsif (/^'*gzip/) {

View File

@ -18,6 +18,8 @@ lzma/1 lzma < %1 > %3
ulzma/1 lzma -d < %1 > %3
xz/1 xz < %1 > %3
uxz/1 xz -d < %1 > %3
zst/1 zstd < %1 > %3
uzst/1 zstd -d < %1 > %3
tar/1 tar cf %3 %1
tgz/1 tar czf %3 %1
uhtml/1 lynx -force_html -dump %1 > %3