mirror of
https://github.com/MidnightCommander/mc
synced 2024-12-23 12:56:51 +03:00
65 lines
1.3 KiB
Bash
65 lines
1.3 KiB
Bash
#!/bin/sh
|
|
#
|
|
# Written by Alex Kuchma <ask@bcs.zp.ua>
|
|
# Alex Tkachenko <alex@bcs.zp.ua>
|
|
# Updated by Vitezslav Samel <xsamel00@dcse.fee.vutbr.cz>
|
|
#
|
|
# (C) 1997, 1998 The Free Software Foundation.
|
|
#
|
|
#
|
|
XAR=ar
|
|
XARINFO="ar tv"
|
|
AWK=awk
|
|
|
|
mcarfs_list ()
|
|
{
|
|
YEAR=`date '+%Y'`
|
|
$XARINFO $1 | @AWK@ -v year=$YEAR '
|
|
{
|
|
date = $(NF-1)
|
|
if(date == year) {
|
|
date = $(NF-2);
|
|
}
|
|
perms = substr($1, 1, 9);
|
|
split($2, id, "/");
|
|
if(NF > 8) {
|
|
id[2] = $3;
|
|
}
|
|
printf("-%9s 1 %8d %8d %8d %s %s %s %s\n", perms, id[1], id[2], $(NF-5), $(NF-4), $(NF-3), date, $(NF));
|
|
}' 2>/dev/null
|
|
}
|
|
|
|
mcarfs_copyout ()
|
|
{
|
|
$XAR p $1 $2 > $3
|
|
}
|
|
|
|
mcarfs_copyin ()
|
|
{
|
|
TMPDIR=/tmp/mctmpdir-uar.$$
|
|
mkdir $TMPDIR || exit 1
|
|
name=`basename $2`
|
|
(cd $TMPDIR && cp -f $3 $name && $XAR r $1 $name)
|
|
rm -rf $TMPDIR
|
|
}
|
|
|
|
mcarfs_rm ()
|
|
{
|
|
$XAR d $1 $2
|
|
}
|
|
|
|
# override any locale for dates
|
|
LC_ALL=C
|
|
export LC_ALL
|
|
|
|
umask 077
|
|
case "$1" in
|
|
list) mcarfs_list $2 ;;
|
|
copyout) shift; mcarfs_copyout "$@" ;;
|
|
copyin) shift; mcarfs_copyin "$@" ;;
|
|
rm) shift; mcarfs_rm "$@" ;;
|
|
*) exit 1;
|
|
esac
|
|
|
|
exit 0
|