b.liu | e958203 | 2025-04-17 19:18:16 +0800 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | if [ -z "$1" -o -z "$2" ]; then |
| 3 | echo "Usage: $0 [-d] file_name block_size [dict_size] [preset] [filter] [lc] [lp] [pb] [nice]" |
| 4 | echo "The output is file_name.mxz if -d is not specified, or filename.dec if -d is specified" |
| 5 | echo "Compression algorithm: LZMA2; Check algorithm: CRC32; Filter: empty string or arm" |
| 6 | else |
| 7 | set -e |
| 8 | if [ "$1" != "-d" ]; then |
| 9 | FNAME="$1" |
| 10 | split -b "$2" "$FNAME" "$FNAME.part" |
| 11 | FILTER= |
| 12 | OPT= |
| 13 | if [ -n "$4" ]; then |
| 14 | OPT="$OPT,preset=$4" |
| 15 | fi |
| 16 | if [ -n "$3" ]; then |
| 17 | OPT="$OPT,dict=$3" |
| 18 | fi |
| 19 | if [ -n "$5" ]; then |
| 20 | FILTER=--$5 |
| 21 | fi |
| 22 | if [ -n "$6" ]; then |
| 23 | OPT="$OPT,lc=$6" |
| 24 | fi |
| 25 | if [ -n "$7" ]; then |
| 26 | OPT="$OPT,lp=$7" |
| 27 | fi |
| 28 | if [ -n "$8" ]; then |
| 29 | OPT="$OPT,pb=$8" |
| 30 | fi |
| 31 | if [ -n "$9" ]; then |
| 32 | OPT="$OPT,nice=$9" |
| 33 | fi |
| 34 | (set -x; xz --check=crc32 $FILTER --lzma2=$OPT -vfk "$FNAME.part"?? || \ |
| 35 | xz.exe --check=crc32 $FILTER --lzma2=$OPT -vfk "$FNAME.part"??) |
| 36 | cat "$FNAME.part"??.xz > "$FNAME.mxz" |
| 37 | rm -f "$FNAME.part"* |
| 38 | du -sh "$FNAME" "$FNAME.mxz" |
| 39 | else |
| 40 | FNAME="$2" |
| 41 | (xz -dc "$FNAME" || xz.exe -dc "$FNAME") > "$FNAME.dec" |
| 42 | du -sh "$FNAME" "$FNAME.dec" |
| 43 | fi |
| 44 | fi |