1 | #LIST /${FISH_DIR } |
---|
2 | LC_TIME=C |
---|
3 | export LC_TIME |
---|
4 | |
---|
5 | fish_list_lsq () |
---|
6 | { |
---|
7 | FISH_DIR="$1" |
---|
8 | ls -Qlan "${FISH_DIR}" 2>/dev/null | grep '^[^cbt]' | ( |
---|
9 | while read p l u g s m d y n; do |
---|
10 | echo "P$p $u.$g" |
---|
11 | echo "S$s" |
---|
12 | echo "d$m $d $y" |
---|
13 | echo ":$n" |
---|
14 | echo |
---|
15 | done |
---|
16 | ) |
---|
17 | |
---|
18 | ls -Qlan "${FISH_DIR}" 2>/dev/null | grep '^[cb]' | ( |
---|
19 | while read p l u g a i m d y n; do |
---|
20 | echo "P$p $u.$g" |
---|
21 | echo "E$a$i" |
---|
22 | echo "d$m $d $y" |
---|
23 | echo ":$n" |
---|
24 | echo |
---|
25 | done |
---|
26 | ) |
---|
27 | echo '### 200' |
---|
28 | } |
---|
29 | |
---|
30 | fish_list_sed () |
---|
31 | { |
---|
32 | FISH_DIR="$1" |
---|
33 | ls -lan "${FISH_DIR}" 2>/dev/null | grep '^[^cbt]' | ( |
---|
34 | while read p l u g s rec; do |
---|
35 | if [ -n "$g" ]; then |
---|
36 | if [ -n "$FISH_HAVE_DATE_MDYT" ]; then |
---|
37 | filename=`echo "$rec"| sed 's/[^[:space:]]\+ \+[^[:space:]]\+ \+[^[:space:]]\+ //'` |
---|
38 | filedate=`echo "$rec"| sed 's/\([^[:space:]]\+ \+[^[:space:]]\+ \+[^[:space:]]\+\) .*/\1/'` |
---|
39 | else |
---|
40 | filename=`echo "$rec"| sed 's/[^[:space:]]\+ \+[^[:space:]]\+ //'` |
---|
41 | filedate=`echo "$rec"| sed 's/\([^[:space:]]\+ \+[^[:space:]]\+\) .*/\1/'` |
---|
42 | fi |
---|
43 | pfile=\"`echo "$filename" | sed -e 's#^\(.*\) -> \(.*\)#\1" -> "\2#'`\" |
---|
44 | echo "P$p $u.$g" |
---|
45 | echo "S$s" |
---|
46 | if [ -n "$FISH_HAVE_DATE_MDYT" ]; then |
---|
47 | echo "d$filedate" |
---|
48 | else |
---|
49 | echo "D$filedate" |
---|
50 | fi |
---|
51 | echo ":$pfile" |
---|
52 | echo |
---|
53 | fi |
---|
54 | done |
---|
55 | ) |
---|
56 | ls -lan "${FISH_DIR}" 2>/dev/null | grep '^[cb]' | ( |
---|
57 | while read p l u g a i rec; do |
---|
58 | if [ -n "$g" ]; then |
---|
59 | if [ -n "$FISH_HAVE_DATE_MDYT" ]; then |
---|
60 | filename=`echo "$rec"| sed 's/[^[:space:]]\+ \+[^[:space:]]\+ \+[^[:space:]]\+ //'` |
---|
61 | filedate=`echo "$rec"| sed 's/\([^[:space:]]\+ \+[^[:space:]]\+ \+[^[:space:]]\+\) .*/\1/'` |
---|
62 | else |
---|
63 | filename=`echo "$rec"| sed 's/[^[:space:]]\+ \+[^[:space:]]\+ //'` |
---|
64 | filedate=`echo "$rec"| sed 's/\([^[:space:]]\+ \+[^[:space:]]\+\) .*/\1/'` |
---|
65 | fi |
---|
66 | pfile=\"`echo "$filename" | sed -e 's#^\(.*\) -> \(.*\)#\1" -> "\2#'`\" |
---|
67 | echo "P$p $u.$g" |
---|
68 | echo "E$a$i" |
---|
69 | if [ -n "$FISH_HAVE_DATE_MDYT" ]; then |
---|
70 | echo "d$filedate" |
---|
71 | else |
---|
72 | echo "D$filedate" |
---|
73 | fi |
---|
74 | echo ":$pfile" |
---|
75 | echo |
---|
76 | fi |
---|
77 | done |
---|
78 | ) |
---|
79 | echo '### 200' |
---|
80 | } |
---|
81 | |
---|
82 | fish_list_poor_ls () |
---|
83 | { |
---|
84 | FISH_DIR="$1" |
---|
85 | ls -lan "${FISH_DIR}" 2>/dev/null | grep '^[^cbt]' | ( |
---|
86 | while read p l u g s m d y n n2 n3; do |
---|
87 | if [ -n "$g" ]; then |
---|
88 | if [ "$m" = "0" ]; then |
---|
89 | s=$d; m=$y; d=$n; y=$n2; n=$n3 |
---|
90 | else |
---|
91 | n=$n" "$n2" "$n3 |
---|
92 | fi |
---|
93 | echo "P$p $u $g" |
---|
94 | echo "S$s" |
---|
95 | echo "d$m $d $y" |
---|
96 | echo ":"$n |
---|
97 | echo |
---|
98 | fi |
---|
99 | done |
---|
100 | ) |
---|
101 | ls -lan "${FISH_DIR}" 2>/dev/null | grep '^[cb]' | ( |
---|
102 | while read p l u g a i m d y n n2 n3; do |
---|
103 | if [ -n "$g" ]; then |
---|
104 | if [ "$a" = "0" ]; then |
---|
105 | a=$m; i=$d; m=$y; d=$n; y=$n2; n=$n3 |
---|
106 | else |
---|
107 | n=$n" "$n2" "$n3 |
---|
108 | fi |
---|
109 | echo "P$p $u $g" |
---|
110 | echo "S$s" |
---|
111 | echo "d$m $d $y" |
---|
112 | echo ":"$n |
---|
113 | echo |
---|
114 | fi |
---|
115 | done |
---|
116 | ) |
---|
117 | echo '### 200' |
---|
118 | } |
---|
119 | |
---|
120 | fish_list_perl () |
---|
121 | { |
---|
122 | FISH_DIR=$1 |
---|
123 | perl -e ' |
---|
124 | use strict; |
---|
125 | use POSIX; |
---|
126 | use Fcntl; |
---|
127 | use POSIX ":fcntl_h"; #S_ISLNK was here until 5.6 |
---|
128 | my $dirname = $ARGV[0]; |
---|
129 | if (opendir (DIR, $dirname)) { |
---|
130 | while((my $filename = readdir (DIR))){ |
---|
131 | my ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blksize,$blocks) = lstat("$dirname/$filename"); |
---|
132 | my $mloctime= strftime("%%m-%%d-%%Y %%H:%%M", localtime $mtime); |
---|
133 | my $strutils_shell_escape_regex = s/([;<>\*\|`&\$!#\(\)\[\]\{\}:'\''"\ \\])/\\$1/g; |
---|
134 | my $e_filename = $filename; |
---|
135 | $e_filename =~ $strutils_shell_escape_regex; |
---|
136 | |
---|
137 | # here we count the required values manually since |
---|
138 | # I was not able to 'link' it anyhow using standard perl way |
---|
139 | my $s_ifmt = $mode & 00170000; |
---|
140 | my $s_imode = $mode & 07777; |
---|
141 | my $s_islnk = ($mode & 00170000) == 0120000; |
---|
142 | |
---|
143 | if ($s_islnk) { |
---|
144 | my $linkname = readlink ("$dirname/$filename"); |
---|
145 | $linkname =~ $strutils_shell_escape_regex; |
---|
146 | printf("R%%o %%o $uid.$gid\nS$size\nd$mloctime\n:\"$e_filename\" -> \"$linkname\"\n\n", $s_imode, $s_ifmt); |
---|
147 | } else { |
---|
148 | printf("R%%o %%o $uid.$gid\nS$size\nd$mloctime\n:\"$e_filename\"\n\n", $s_imode,, $s_ifmt); |
---|
149 | } |
---|
150 | } |
---|
151 | printf("### 200\n"); |
---|
152 | closedir(DIR); |
---|
153 | } else { |
---|
154 | printf("### 500\n"); |
---|
155 | } |
---|
156 | exit 0 |
---|
157 | ' "/${FISH_DIR}" |
---|
158 | } |
---|
159 | |
---|
160 | if [ -n "${FISH_HAVE_PERL}" ]; then |
---|
161 | fish_list_perl "/${FISH_FILENAME}" |
---|
162 | elif [ -n "${FISH_HAVE_LSQ}" ]; then |
---|
163 | fish_list_lsq "/${FISH_FILENAME}" |
---|
164 | elif [ -n "${FISH_HAVE_SED}" ]; then |
---|
165 | fish_list_sed "/${FISH_FILENAME}" |
---|
166 | else |
---|
167 | fish_list_poor_ls "/${FISH_FILENAME}" |
---|
168 | fi |
---|