ftp://ftp.redhat.com/pub/redhat/linux/rawhide/SRPMS/SRPMS/gnome-vfs2-2.3.8-1.src.rpm
[gnome-vfs-httpcaptive.git] / modules / extfs / zoo.in
1 #! /bin/sh
2 #
3 # Zoo file system
4 #
5 # Copyright ? U. N. Known
6 #
7 # This filesystem is _dangerous_. It used to create symlinks in filesystem
8 # with zoo file, it used to happily delete file from your filesystem.
9 # Now it is 'only' very ugly (it creates temporary files in ~/.mc/
10 #
11
12 ZOO=zoo
13
14 mczoofs_list ()
15 {
16     $ZOO l $1 | @AWK@ -v uid=${UID-0} '
17 BEGIN { hyphens=0 }
18 /^---/ { if (hyphens > 0) exit 0; hyphens=1; next }
19 /^[^\ ]/ { next }
20 {
21 if (NF < 8)
22     next
23 if ($8 ~ /^\^/)
24     $8=substr($8, 2)
25 if ($6 > 50)
26     $6=$6 + 1900
27 else
28     $6=$6 + 2000
29 split($7, a, ":")
30 if ($8 ~ /\/$/)
31     printf "drwxr-xr-x   1 %-8d %-8d %8d %s %2d %4d %02d:%02d %s\n", uid, 0, $1, $5, $4, $6, a[1], a[2], $8
32 else
33     printf "-rw-r--r--   1 %-8d %-8d %8d %s %2d %4d %02d:%02d %s\n", uid, 0, $1, $5, $4, $6, a[1], a[2], $8
34 }' 2>/dev/null
35     exit 0
36 }
37
38 mczoofs_copyout ()
39 {
40     $ZOO xp $1 $2 | tail +6l > $3 2>/dev/null
41     exit 0
42 }
43
44 # zoo is stupid and won't be happy when the name has no extension.
45 # We have to do a small trick :) [pretty dirty, broken hack -- pavel]
46 if echo $2 | grep '\.zoo$'; then
47   :
48 else
49   SYMLINK=~/.mc/temporary.$2.zoo
50   if test -f $SYMLINK; then
51     SYMLINK=~/.mc/temporary.$2.
52   fi
53   if test -f $SYMLINK; then
54     echo "Ugh. I did not expect this to happen. Cleanup your ~/.mc."
55     sleep 5
56     exit 1
57   fi
58   ln -s $2 $SYMLINK
59   trap 'rm -f $SYMLINK' 0 1 2 3 5 13 15
60   $2=$SYMLINK
61 fi
62
63 umask 077
64
65 case "$1" in
66   list) mczoofs_list $2; exit $?;;
67   copyout) mczoofs_copyout $2 $3 $4; exit $?;;
68 esac
69 exit 1