wok-4.x view lzma/stuff/lzma @ rev 11840

perl-html-parser: Sync with wok-tank.
author Christopher Rogers <slaxemulator@gmail.com>
date Mon Feb 27 01:06:36 2012 -0500 (2012-02-27)
parents 885c330a75ba
children
line source
1 #!/bin/sh
3 case "$1" in
4 d|e|b) exec /usr/bin/lzma-alone $@;;
5 --size) size=$(od -t d8 -j5 -N8 < $2 | awk '{ print $2; exit }')
6 if [ $size -eq -1 ]; then
7 size=$(unlzma -c $2 | wc -c)
8 n=$size
9 for i in $(seq 1 8); do
10 printf '\\\\x%02X' $(($n & 255))
11 n=$(($n >> 8))
12 done | xargs echo -en | dd of=$2 conv=notrunc bs=1 seek=5 2> /dev/null
13 fi
14 echo $size
15 exit ;;
16 --version|-V|--help|-h|-\?) exec /usr/bin/lzma-alone;;
17 esac
19 [ -x /usr/bin/lzmap ] && exec /usr/bin/lzmap $@
21 files=""
22 outfilter=''
23 suffix='lzma'
24 opts='-a1 -d23 -fb128 -mfbt4 -lc3 -lp0 -pb2'
25 command='e'
26 keep=''
28 case "$0" in
29 *unlzma) command='d';;
30 *lzcat) command='d'; outfilter='s/.*/-so/'; keep='y';;
31 esac
33 while [ -n "$1" ]; do
34 case "$1" in
35 -c|--stdout|--to-stdout) outfilter='s/.*/-so/'; keep='y';;
36 -S|--suffix) suffix="$2"; shift;;
37 -d|--decompress|--uncompress) command='d';;
38 -k|--keep) keep='y';;
39 -1|--fast) opts='-a0 -d16 -fb64 -mfhc4 -lc3 -lp0 -pb2';;
40 -2) opts='-a1 -d20 -fb64 -mfbt4 -lc3 -lp0 -pb2';;
41 -3) opts='-a1 -d19 -fb64 -mfbt4 -lc3 -lp0 -pb2';;
42 -4) opts='-a1 -d20 -fb128 -mfbt4 -lc3 -lp0 -pb2';;
43 -5) opts='-a1 -d21 -fb128 -mfbt4 -lc3 -lp0 -pb2';;
44 -6) opts='-a1 -d22 -fb128 -mfbt4 -lc3 -lp0 -pb2';;
45 -7) opts='-a1 -d23 -fb128 -mfbt4 -lc3 -lp0 -pb2';;
46 -8) opts='-a1 -d24 -fb255 -mfbt4 -lc3 -lp0 -pb2';;
47 -9|--best) opts='-a1 -d25 -fb255 -mfhc4 -lc3 -lp0 -pb2';;
48 -*);;
49 *) files="$files $1";;
50 esac
51 shift
52 done
53 [ -z "$outfilter" ] && if [ -n "$files" ]; then
54 if [ "$command" == "e" ]; then
55 outfilter="s/\$/.$suffix/"
56 else
57 outfilter="s/.$suffix\$//"
58 fi
59 else
60 files='-si'; outfilter='s/.*/-so/'; keep='y';
61 fi
62 for i in $files ; do
63 /usr/bin/lzma-alone $command $i $(echo $i | sed $outfilter) $opts || exit $?
64 [ -n "$keep" ] || rm -f $i
65 done