
(defun write-files (files &key
		    (format-spec *selected-format*)
		    (device-spec *selected-device*)
		    (end-of-tape-action :continue)
		    silent)
  "Writes some files to tape from disk.  
FILES
	can be file spec or list of file specs.  Each file spec
	must be a pathname (or string to be parsed into a pathname)
	or a file property list.  (See the tape software documentation
	for more details on using file property lists.)  Wildcards are
	acceptable in pathnames and all disk files matching the pathname
	will be spliced into the list where a wildcarded pathname exists.
	AND NOW...files may be a list of wildcarded pathnames.	--saz, 5/27/88
END-OF-TAPE-ACTION
	This determines what to do if the end of the tape is encountered.
	:CONTINUE specifies that the format software should continue to 
	another tape if possible.  :ERROR will cause an error to be signalled."
  (check-type end-of-tape-action (member :continue :error))
  (using-device (device device-spec)
    (using-format (format format-spec)
      (let ((file-list (typecase files
			 (list (let ((file-list))	
				 (dolist (file-designator files (reverse file-list))
				   (if (pathname-wild-p file-designator)
				       (setq file-list
					     (append
					       (mapcar #'car
						       (full-directory-list file-designator))
					       file-list))
				     (push (fs:parse-pathname file-designator) file-list)))))
			 ((or string pathname)
			  (let ((pn (fs:parse-pathname files)))
			    (if (pathname-wild-p pn)
				(mapcar #'car
					(full-directory-list (fs:parse-pathname files)))
			      (ncons pn))))
			 (t (ferror nil "Invalid files specifier: ~S" files)))))
	(with-device-locked device
	  (dolist (file file-list)
	    (send format :write-file
		  device
		  file
		  :end-of-tape-action end-of-tape-action
		  :silent silent)))))))
