Jpp 19.3.0-rc.1
the software that should make you happy
Loading...
Searching...
No Matches
getArchive.sh
Go to the documentation of this file.
1#!/usr/bin/env zsh
2#
3# \author mdejong
4#
5script=${0##*/}
6
7source ${0%${script}}ulib.sh
8
9set_variable: DEBUG ARCHIVE_DEBUG 2
10set_variable VERSION "*"
11
12if do_usage $*; then
13 usage "$script <path> [<detector identifier> [<run> [<type> [version]]]]"\
14 "\nUtility script to list files in archive."
15fi
16
17case $# in
18 5) set_variable VERSION $argv[5];&
19 4) set_variable TYPE $argv[4];&
20 3) let RUN=" $argv[3]";&
21 2) let ID=" $argv[2]";&
22 1) set_variable DIR $argv[1];;
23 *) fatal "Wrong number of arguments."
24esac
25
26
27if [[ ! -d $DIR ]]; then
28 fatal "Invalid path $argv[1]"
29fi
30
31
32setopt extendedglob
33
34typeset -Z8 ID
35
36
37#
38# print file properties
39#
40# \param 1 file name
41#
42function archive()
43{
44 typeset -T BUFFER ARRAY /
45
46 BUFFER=$1
47
48 set_variable A_ID ${ARRAY[-6]}
49 set_variable A_TYPE ${ARRAY[-5]}
50 set_variable A_VERSION ${ARRAY[-4]#_}
51 let A_MINRUN=" ${ARRAY[-3]}"
52 let A_MAXRUN=" ${ARRAY[-2]}"
53 set_variable A_FILENAME ${ARRAY[-1]}
54
55 let A_COUNTER="${A_FILENAME:r}"
56
57 if (( $RUN >= $A_MINRUN && $RUN <= $A_MAXRUN )); then
58
59 if [[ $(uname) == "Darwin" ]]; then
60 ls -l $BUFFER
61 else
62 ls -l --author $BUFFER
63 fi
64
65 if (( $DEBUG >= 3 )); then
66 echo "identifier: $(($A_ID))"
67 echo "type: $A_TYPE"
68 echo "version: $A_VERSION"
69 echo "minimal run: $(($A_MINRUN))"
70 echo "maximal run: $(($A_MAXRUN))"
71 echo
72 fi
73 fi
74
75}
76
77
78if (( $# == 1 )); then
79 ls -1 $DIR/ | grep -E ${ANY_ID}; return
80fi
81
82
83if (( $ID == 0 )); then
84 fatal "Invalid detector identifier $argv[2]"
85fi
86
87
88if (( $# == 2 )); then
89 ls -1 $DIR/$ID/; return
90fi
91
92
93if (( $RUN == 0 )); then
94 fatal "Invalid run $argv[3]"
95fi
96
97
98if (( $# == 3 )); then
99
100 eval ls -1 $DIR/$ID/\*/_\*/\*/\*/\* 2> /dev/null | while read BUFFER; do
101 archive $BUFFER
102 done
103fi
104
105
106if (( $# >= 4 )); then
107
108 eval ls -1 $DIR/$ID/$TYPE/_${VERSION}/\*/\*/\* 2> /dev/null | while read BUFFER; do
109 archive $BUFFER
110 done
111fi