Skip to content

Commit 33b88b3

Browse files
committed
Added support for brotli compression
Signed-off-by: Vadim Kalinnikov <[email protected]>
1 parent be8f04b commit 33b88b3

File tree

6 files changed

+69
-0
lines changed

6 files changed

+69
-0
lines changed

configure.ac

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ src/vfs/extfs/helpers/Makefile
595595
src/vfs/extfs/helpers/a+
596596
src/vfs/extfs/helpers/apt+
597597
src/vfs/extfs/helpers/audio
598+
src/vfs/extfs/helpers/brotli
598599
src/vfs/extfs/helpers/deb
599600
src/vfs/extfs/helpers/deba
600601
src/vfs/extfs/helpers/debd

misc/ext.d/archive.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ do_view_action() {
1414
filetype=$1
1515

1616
case "${filetype}" in
17+
br)
18+
brotli -dck "${MC_EXT_FILENAME}" 2>/dev/null
19+
;;
1720
gz)
1821
gzip -dc "${MC_EXT_FILENAME}" 2>/dev/null
1922
;;

misc/mc.ext.ini.in

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,12 @@ ShellIgnoreCase=true
917917
Open=%cd %p/uwim://
918918
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view wim
919919

920+
[brotli]
921+
Shell=.br
922+
ShellIgnoreCase=true
923+
Open=Open=%cd %p/brotli://
924+
View=%view{ascii} @EXTHELPERSDIR@/archive.sh view br
925+
920926

921927
######### Files by Type #########
922928

src/vfs/extfs/helpers/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Makefile.in
33
a+
44
apt+
55
audio
6+
brotli
67
deb
78
deba
89
debd

src/vfs/extfs/helpers/Makefile.am

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ EXTFS_IN = \
1111
a+.in \
1212
apt+.in \
1313
audio.in \
14+
brotli.in \
1415
deb.in \
1516
deba.in \
1617
debd.in \
@@ -45,6 +46,7 @@ EXTFS_OUT = \
4546
a+ \
4647
apt+ \
4748
audio \
49+
brotli \
4850
deb \
4951
deba \
5052
debd \

src/vfs/extfs/helpers/brotli.in

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#! /bin/sh
2+
# Midnight Commander - Brotli support
3+
#
4+
# Written by:
5+
# Vadim Kalinnikov <[email protected]>,
6+
#
7+
# This file is part of the Midnight Commander.
8+
#
9+
# It required brotli: https://github.com/google/brotli
10+
# On Debian/Ubuntu brotli can be installed via:
11+
# apt install brotli
12+
13+
command -v brotli >/dev/null 2>&1 || exit 1
14+
BROTLI=$(command -v brotli 2>/dev/null)
15+
AWK=@AWK@
16+
17+
[ -n "$2" ] || exit 1
18+
19+
ACTION=$1
20+
BRFILENAME=$2
21+
22+
23+
br_list() {
24+
BROUTFILENAME=$(basename "${BRFILENAME}" | sed -e 's/\.br$//')
25+
ls -l --time-style="+%d/%m/%Y %H:%M:%S" "${BRFILENAME}" | \
26+
${AWK} -v f_name="${BROUTFILENAME}" '{
27+
attr=$1;
28+
uid=$2;
29+
gid=$4;
30+
f_size=$5;
31+
t_date=$6;
32+
t_time=$7;
33+
printf("%s 1 %s %s %s %s %s %s\n", attr, uid, gid, f_size, t_date, t_time, f_name);
34+
}'
35+
}
36+
37+
br_copyout() {
38+
${BROTLI} -dck "${BRFILENAME}" > "${FILENAMEDST}"
39+
}
40+
41+
case "$ACTION" in
42+
list)
43+
br_list
44+
;;
45+
46+
copyout)
47+
[ -n "$4" ] || exit 1
48+
FILENAMEDST="$4"
49+
br_copyout
50+
;;
51+
52+
*)
53+
exit 1
54+
;;
55+
esac
56+

0 commit comments

Comments
 (0)