Raymond Toy pushed to branch issue-373-handle-temp-files at cmucl / cmucl

Commits:

1 changed file:

Changes:

  • src/code/extensions.lisp
    ... ... @@ -658,6 +658,21 @@
    658 658
     	   (close ,s)
    
    659 659
     	   (unix:unix-close ,fd))))))
    
    660 660
     
    
    661
    +;;; WITH-TEMPORARY-FILE  -- Public
    
    662
    +(defmacro with-temporary-file ((filename)
    
    663
    +			       &parse-body (forms decls))
    
    664
    +  (let ((fd (gensym "FD-")))
    
    665
    +    `(let (,filename)
    
    666
    +       (unwind-protect
    
    667
    +	    (let (,fd)
    
    668
    +	      (multiple-value-setq (,fd ,filename)
    
    669
    +		(unix::unix-mkstemp "/tmp/cmucl-temp-file-XXXXXX"))
    
    670
    +	      (unix:unix-close ,fd)
    
    671
    +	      (locally ,@decls
    
    672
    +		,@forms))
    
    673
    +	 (delete-file ,filename)))))
    
    674
    +	
    
    675
    +
    
    661 676
     ;;; WITH-TEMPORARY-DIRECTORY  -- Public
    
    662 677
     (defmacro with-temporary-directory ((dirname template)
    
    663 678
     				    &parse-body (forms decls))