A related problem is that the code will only work on Windows ("C:" does not exist on Mac or Linux), and there is no guarantee that “C:\tmp” will be writeable.
A simple solution would be to query Audacity for the location of the “Documents” directory (which should be writeable on all platforms):
(setf savepath (string-right-trim "\/"(get '*system-dir* 'documents)))
To be absolutely sure that the output directory is writeable, a test function could be added:
(defun iswriteable (path fname)
;; Return T if path is writeable, else NIL.
(setf path (string-right-trim "\/" path))
(setf path (format nil "~a~a~a"
path *file-separator* fname))
(let ((fp (open path :direction :output))
rslt)
(if fp
(progn (close fp)
t)
nil)))
(print (iswriteable "C:\tmp" "test.txt"))
However, the above code will create a zero byte file “C:\tmp\test.txt” if the directory is writeable, so in practice it would be better to use the actual filename that you intend to write to.