File: p7zipForFilemanager

package info (click to toggle)
p7zip 9.20.1~dfsg.1-4.1%2Bdeb8u3
  • links: PTS
  • area: main
  • in suites: jessie
  • size: 13,368 kB
  • sloc: cpp: 104,670; ansic: 12,930; makefile: 1,899; sh: 1,031; asm: 159
file content (108 lines) | stat: -rwxr-xr-x 1,667 bytes parent folder | download | duplicates (12)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#! /bin/sh

# program t archive1.7z ... archiveN.7z
# program x directory_out archive1.7z ... archiveN.7z
# program xd directory_out archive1.7z ... archiveN.7z
# program a -t7z current_directory file1 ... fileN
# program ad -tzip current_directory file1 ... fileN

P7ZIP="7zG"

list=/tmp/p7zip.list.$$
rm -f ${list}

trace=/tmp/7zG1.txt
rm -f ${trace}

for file in "$@"
do
	echo "arg=${file}" >> ${trace}
done

cmd="$1"
shift

flag_ad=""
flag_type=""

case "${cmd}" in
b|t)
	;;
x|xs)
	;;
xd)
	flag_ad="-ad"
	;;
a)
	flag_type="$1"
	shift
	;;
ad)
	flag_type="$1"
	shift
	flag_ad="-ad"
	;;
*)
	echo "Unknown command \"${cmd}\""
	exit 1
	;;
esac

#ext=".7z"
#if [ "${flag_type}" = "-tzip" ]
#then
#	ext=".zip"
#fi

argn="$#"
file1="$1"
dir1=`dirname "${file1}"`
file2="$2"
echo "argn=${argn}" >> ${trace}
echo "flag_type=${flag_type}" >> ${trace}
echo "file1=${file1}" >> ${trace}
echo "dir1=${dir1}" >> ${trace}
echo "file2=${file2}" >> ${trace}

if [ "a${dir1}" != "a" ]
then
	cd "${dir1}"
fi

for file in "$@"
do
	file=`basename "${file}"`
	echo ${file} >> ${list}
	echo "list=${file}" >> ${trace}
done

case "${cmd}" in
b)
	${P7ZIP} b
	;;
t)
	${P7ZIP} t -an -ai@${list}
	;;
x|xd)
	${P7ZIP} x ${flag_ad} -an -ai@${list}
	;;
xs)
	dir_out=`dirname "${file1}"`
	${P7ZIP} x ${flag_ad} -o"*" -an -ai@${list}
	;;
a|ad)
	if [ ${argn} -eq "1" ]
	then
		file=`basename "${file1}"`${ext}
		echo "archive_out=${file}" >> ${trace}
		${P7ZIP} a ${flag_ad} ${flag_type} -i@${list} ${flag} -- "${file}"
	else
		file=`basename "${dir1}"`${ext}
		echo "archive_out=${file}" >> ${trace}
		${P7ZIP} a ${flag_ad} ${flag_type} -i@${list} ${flag} -- "${file}"
	fi
	;;
esac

rm -f ${list}