From fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 8 Jul 2015 20:46:52 -0400 Subject: Initial commit --- sys/fio/fdirname.x | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 sys/fio/fdirname.x (limited to 'sys/fio/fdirname.x') diff --git a/sys/fio/fdirname.x b/sys/fio/fdirname.x new file mode 100644 index 00000000..aa24709d --- /dev/null +++ b/sys/fio/fdirname.x @@ -0,0 +1,46 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include +include + +# FDIRNAME -- Return the concatenatable directory prefix for the named +# directory. If no vfn is given (null string), a path to the current +# directory is returned. + +procedure fdirname (vfn, path, maxch) + +char vfn[ARB] # VFN of directory +char path[ARB] # unpacked path to directory +int maxch + +int len1, len2, ch +int gstrcpy() + +begin + if (vfn[1] == EOS) { + # Null vfn; return current directory. + call strcpy ("./", path, maxch) + return + } + + # Do we have an OS directory reference? + call zfxdir (vfn, path, maxch, len2) + ch = path[len2] + if (len2 > 0 && !(IS_ALNUM(ch) || ch == '_')) + return + + # Do we have an "ldir$" or "subdir/"? If so, quit, else if the last + # char is a normal identifier class filename char, assume that we have + # a VFN and add the / delimiter. This technique is not infallible, + # and a better solution would be to have ZFXDIR or FDIRNAME itself + # execute on the remote node. + + len1 = gstrcpy (vfn, path, maxch) + ch = path[len1] + if (ch == '$' || ch == '/') + return + + # Must be a subdirectory of the form "subdir". Add the /. + path[len1+1] = '/' + path[len1+2] = EOS +end -- cgit