about summary refs log tree commit diff
path: root/Functions/Zftp/zffcache
diff options
context:
space:
mode:
authorTanaka Akira <akr@users.sourceforge.net>1999-09-10 13:58:19 +0000
committerTanaka Akira <akr@users.sourceforge.net>1999-09-10 13:58:19 +0000
commite7f29cac778f558ca2eaf405827ef8aef32c8892 (patch)
tree261f9fcec8e2fa022a914bd84725911630f4d8d1 /Functions/Zftp/zffcache
parent20e133ad477a60657a5f7ddba168071d0c01a5d7 (diff)
downloadzsh-e7f29cac778f558ca2eaf405827ef8aef32c8892.tar.gz
zsh-e7f29cac778f558ca2eaf405827ef8aef32c8892.tar.xz
zsh-e7f29cac778f558ca2eaf405827ef8aef32c8892.zip
Initial revision
Diffstat (limited to 'Functions/Zftp/zffcache')
-rw-r--r--Functions/Zftp/zffcache24
1 files changed, 24 insertions, 0 deletions
diff --git a/Functions/Zftp/zffcache b/Functions/Zftp/zffcache
new file mode 100644
index 000000000..0d9686660
--- /dev/null
+++ b/Functions/Zftp/zffcache
@@ -0,0 +1,24 @@
+# Generate an array name for storing the cache for the current session,
+# storing it in fcache_name, then generate the cache for the current
+# directory, or with argument -d clear the cache.
+
+fcache_name=$zfconfig[fcache_$ZFTP_SESSION]
+if [[ -z $fcache_name ]]; then
+  local vals
+  vals=(${(v)zfconfig[(I)fcache_*]##zftp_fcache_})
+  integer i
+  while [[ -n ${vals[(r)zftp_fcache_$i]} ]]; do
+    (( i++ ))
+  done
+  fcache_name=zftp_fcache_$i
+  zfconfig[fcache_$ZFTP_SESSION]=$fcache_name
+fi
+
+if [[ $1 = -d ]]; then
+  unset $fcache_name
+elif (( ${(P)#fcache_name} == 0 )); then
+  local tmpf=${TMPPREFIX}zffcache$$
+  zftp ls >$tmpf
+  eval "$fcache_name=(\${(f)\"\$(<\$tmpf)\"})"
+  rm -f $tmpf
+fi