diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
commit | fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch) | |
tree | bdda434976bc09c864f2e4fa6f16ba1952b1e555 /sys/fio/fsfopen.x | |
download | iraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz |
Initial commit
Diffstat (limited to 'sys/fio/fsfopen.x')
-rw-r--r-- | sys/fio/fsfopen.x | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/sys/fio/fsfopen.x b/sys/fio/fsfopen.x new file mode 100644 index 00000000..21ff9c95 --- /dev/null +++ b/sys/fio/fsfopen.x @@ -0,0 +1,82 @@ +# Copyright(c) 1986 Association of Universities for Research in Astronomy Inc. + +include <config.h> +include <fio.h> + +# FSFOPEN -- Open the subfile list file. A subfile is a physical file which is +# logically subordinate to another file (e.g., the pixel storage file is a +# subfile of an imagefile). The subfile list file is a hidden textfile, +# containing a list of filenames. + +int procedure fsfopen (fname, mode) + +char fname[ARB] # name of logical file +int mode # access mode for subfile list + +int fd +pointer sp, listfile +int open() +errchk open, fsf_getfname + +begin + call smark (sp) + call salloc (listfile, SZ_FNAME, TY_CHAR) + + call fsf_getfname (fname, Memc[listfile], SZ_FNAME) + fd = open (Memc[listfile], mode, TEXT_FILE) + + call sfree (sp) + return (fd) +end + + +# FSFDELETE -- Delete all of the subfiles of a file, then the subfile list +# file itself. + +procedure fsfdelete (fname) + +char fname[ARB] # file whose subfiles are to be deleted +int fd +pointer sp, subfile +int fsfopen(), getline() +errchk getline, delete, fsf_getfname + +begin + call smark (sp) + call salloc (subfile, SZ_FNAME, TY_CHAR) + + # Open the list and delete each subfile. To avoid recursion this must + # be done by calling delete, hence subfiles may not have subfiles. + # It is not an error if the listfile cannot be opened, i.e., if there + # are no subfiles. + + iferr (fd = fsfopen (fname, READ_ONLY)) { + call sfree (sp) + return + } + + while (getline (fd, Memc[subfile]) != EOF) + call delete (Memc[subfile]) + call close (fd) + + # Delete the listfile itself. + + call fsf_getfname (fname, Memc[subfile], SZ_FNAME) + call delete (Memc[subfile]) + + call sfree (sp) +end + + +# FSF_GETFNAME -- Get the name of the subfile list file for a file. + +procedure fsf_getfname (fname, fsf_file, maxch) + +char fname[ARB] # main file +char fsf_file[maxch] # file containing names of subfiles +int maxch + +begin + call strcpy (fname, fsf_file, maxch) + call strcat (SUBFILE_EXTN, fsf_file, maxch) +end |