*** empty log message ***
[midnight-commander.git] / vfs / extfs / ucpio.in
blob69f4b4315a93a95f80b4ca4e468d6204e7409bd9
1 #!/bin/sh
3 # Written by Stas Maximov 1998 SVR4 (UnixWare)
4 # stmax@u213.srcc.msu.su
5 # (C) 1996 The Free Software Foundation.
9 uni_cat ()
10 # $1 is the archive name
12 case "$1" in
13 *.cpio.Z) compress -dc "$1"
15 *.cpio.gz) gzip -dc "$1"
17 *.cpio) cat "$1"
19 *) echo "unknown extension"
20 esac
23 mccpiofs_list ()
24 # $1 is the archive name
26 uni_cat "$1" | cpio -itv | @AWK@ '
28 if (substr($9,length($9),1) == ",")
30 tmp = substr($9, 1, length($9)-1);
31 $9 = $8;
32 $8 = tmp
34 else if (substr($10,length($10),1) == ",")
36 tmp = substr($10, 1, length($10)-1);
37 $10 = $9
38 $9 = tmp
41 print $0
45 mccpiofs_copyout ()
46 # $1 is the archive name
47 # $2 is a name of a file within the archive
48 # $3 is a name of a file within the system (to add from or extract to)
50 TMPDIR=/tmp/mctmpdir.$$
51 # FIXME: Try harder to generate a unique directory if this fails
52 mkdir -m 0700 $TMPDIR || exit 1
53 cd $TMPDIR
54 uni_cat "$1" | cpio -icumd "$2" 2>/dev/null
55 mv "$2" "$3"
56 cd /
57 rm -rf $TMPDIR
61 # main
63 umask 077
65 case "$1" in
66 list) mccpiofs_list $2
67 exit 0
69 copyout) mccpiofs_copyout $2 $3 $4
70 exit 0
72 esac
74 exit 1