Merge branch '1858_segfault_in_search'
[midnight-commander.git] / vfs / extfs / uarc.in
blob3f71277b768098fee4b8bfabacd56a0c0190e91a
1 #! /bin/sh
4 # ARC Virtual filesystem executive
5 # Copyright (C) 2008 Jacques Pelletier
6 # May be distributed under the terms of the GNU Public License
7 # <jpelletier@ieee.org>
10 # Define your awk
11 AWK=gawk
12 # Define which archiver you are using with appropriate options
13 ARC_LIST="arc v"
14 ARC_GET="arc x"
15 ARC_PUT="arc a"
16 ARC_DEL="arc d"
18 # The 'list' command executive
20 mc_arc_fs_list()
22 $ARC_LIST "$1" | gawk -v uid=${UID-0} '
23 BEGIN { }
24 /^Name/ { next }
25 /===/ { next }
26 /^Total/ { next }
28 if ($8 > 50)
29 $8=$8 + 1900
30 else
31 $8=$8 + 2000
33 split($9, a, ":")
35 # convert AM/PM to 00-23
36 if (a[2] ~ /a$|p$/)
38 if (a[2] ~ /p$/)
39 a[1] = a[1]+12
41 a[2]=substr(a[2],1,2)
44 printf "-rw-r--r-- 1 %-8d %-8d %8d %s %2d %4d %02d:%02d %s\n", uid, 0, $2, $7, $6, $8, a[1], a[2], $1
45 }' 2>/dev/null
46 exit 0
49 # Command: copyout archivename storedfilename extractto
50 mc_arc_fs_copyout()
52 $ARC_GET "$1" "$2" 2> /dev/null
53 mv "$2" "$3"
56 # Command: copyin archivename storedfilename sourcefile
57 mc_arc_fs_copyin()
59 mv "$3" "$2"
60 $ARC_PUT "$1" "$2" 2> /dev/null
63 # Command: rm archivename storedfilename
64 mc_arc_fs_rm()
66 $ARC_DEL "$1" "$2" 2> /dev/null
69 # The main routine
70 umask 077
72 cmd="$1"
73 shift
75 case "$cmd" in
76 list) mc_arc_fs_list "$@" ;;
77 copyout) mc_arc_fs_copyout "$@" ;;
78 copyin) mc_arc_fs_copyin "$@" ;;
79 rm) mc_arc_fs_rm "$@" ;;
80 *) exit 1 ;;
81 esac
82 exit 0