#!/bin/sh

mcstarfs_list() {
       star -tv -f="$1" 2>/dev/null |awk '{
               size = $1
               perms = substr($2,1,10)
               split($3,own,"/")
               month = $4 ; day = $5 ; time = $6 ; year = $7
               filename = substr($0, index($0,$8) )
               printf "%s 1 %s %s %i %s %2i %i %s %s\n",
                       perms, own[1], own[2], size, month, day, year, time, filename
       }'
}

mcstarfs_copyout() {
       #star -no-statistics -f="$1" -x -to-stdout "$2" >"$3"
       # grumble mumble...can't have stderr because we need
       # leading / and turning it off with -/ doesn't work
       star -f="$1" -x -to-stdout "$2" >"$3" 2>/dev/null
}

cmd="$1"
shift
case "$cmd" in
       list)           mcstarfs_list "$@" ;;
       copyout)        mcstarfs_copyout "$@" ;;
       *)              exit 1 ;;
esac
exit 0
