File: uxdms.in

package info (click to toggle)
avfs 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,864 kB
  • sloc: ansic: 31,321; sh: 6,482; perl: 1,916; makefile: 351
file content (62 lines) | stat: -rw-r--r-- 1,318 bytes parent folder | download | duplicates (7)
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
#! /bin/sh
#
# Written by Ralf Hoffmann <ralf@boomerangsworld.de>
# uxdms 0.9.0
#
# (C) 2007 Ralf Hoffmann <ralf@boomerangsworld.de>
# May be distributed under the terms of the GNU General
# Public License V2 or higher
#
# requires xdms (http://zakalwe.fi/~shd/foss/xdms/)
#

XDMS=xdms
AWK=@AWK@

extfs_xdms_list ()
{
  if test -f "$1"; then
    t=$(ls -l "$1" | $AWK '{print $6, $7, $8}')
    name=$(basename "$1" | sed 's/\(.*\)\.dms/\1/')
    adfname="$name.adf"

    adfsize=$($XDMS f "$1" 2>/dev/null | $AWK 'BEGIN { sum = 0 } /^[ ]*[0-9]+/ { sum += $3 } END { print sum }')
    statsize=$($XDMS f "$1" 2>/dev/null | wc -c)

    echo "-rw-r--r-- 1 $(id -nu) $(id -ng) $adfsize $t $adfname"
    echo "-rw-r--r-- 1 $(id -nu) $(id -ng) $statsize $t STAT"
  fi
}

extfs_xdms_copyout ()
{
    name=$(basename "$1" | sed 's/\(.*\)\.dms/\1/')
    adfname="$name.adf"
    if test "$2" = "$adfname"; then
        $XDMS -q u "$1" +"$3"
    elif test "$2" = "STAT"; then
        $XDMS f "$1" > "$3" 2>/dev/null
    fi
}

# override any locale for dates
LC_ALL=C
export LC_ALL

umask 077

case "$1" in
    list)
        extfs_xdms_list "$2"
        ;;
    copyout)
        shift
        extfs_xdms_copyout "$@"
        ;;
    *)
        echo "extfs_xdms: unknown command: \"$1\"." 1>&2
        exit 1
        ;;
esac

exit 0