diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /sys/fio/rename.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'sys/fio/rename.x')
-rw-r--r-- | sys/fio/rename.x | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/sys/fio/rename.x b/sys/fio/rename.x new file mode 100644 index 00000000..c52c28bf --- /dev/null +++ b/sys/fio/rename.x @@ -0,0 +1,38 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include <error.h> +include <fio.h> + +# RENAME -- Rename a file. First try to rename the file using the ZFRNAM +# kernel primitive, accessed by FRENAME. If that fails try to copy the +# file and delete the original. + +procedure rename (oldname, newname) + +char oldname[ARB] # old filename +char newname[ARB] # new filename + +int junk, protect() +errchk fcopy, protect + +begin + # Try a simple file rename first. + ifnoerr (call frename (oldname, newname)) + return + + # That failed, so copy the file to the new name. + call fcopy (oldname, newname) + + # Now delete the original. Transfer file protection to the new file, + # if the old file was protected. + + if (protect (oldname, QUERY_PROTECTION) == YES) { + iferr (junk = protect (oldname, REMOVE_PROTECTION)) { + call delete (newname) + call erract (EA_ERROR) + } + call delete (oldname) + junk = protect (newname, SET_PROTECTION) + } else + call delete (oldname) +end |