Raymond Toy pushed to branch issue-364-add-mkstemp-mkdtemp at cmucl / cmucl

Commits:

1 changed file:

Changes:

  • src/code/unix.lisp
    ... ... @@ -2901,32 +2901,6 @@
    2901 2901
     			  (function (* char))))
    
    2902 2902
     	c-string))
    
    2903 2903
     
    
    2904
    -(defun unix-mkstemp (template)
    
    2905
    -  _N"Generates a unique temporary file name from TEMPLATE, and creates
    
    2906
    -  and opens the file.  On success, the corresponding file descriptor
    
    2907
    -  and name of the file is returned.
    
    2908
    -
    
    2909
    - The last six characters of the template must be \"XXXXXX\"."
    
    2910
    -  ;; Hope this buffer is large enough!
    
    2911
    -  (let ((octets (%name->file template)))
    
    2912
    -    (unless (< (length octets) 8192)
    
    2913
    -      (error "Internal buffer is too small for encoded file name of ~D octets"
    
    2914
    -	     (length octets)))
    
    2915
    -    (with-alien ((buf (array c-call:unsigned-char 8192)))
    
    2916
    -      ;; Convert the Lisp string and copy it to the alien buffer, being
    
    2917
    -      ;; sure to zero-terminate the buffer.
    
    2918
    -      (loop for k from 0
    
    2919
    -	    for c across octets
    
    2920
    -	    do
    
    2921
    -	       (setf (deref buf k) (char-code c))
    
    2922
    -	    finally (setf (deref buf k) 0))
    
    2923
    -
    
    2924
    -      (syscall ("mkstemp" (* c-call:unsigned-char))
    
    2925
    -	       (values result
    
    2926
    -		       ;; Convert the file name back to a Lisp string.
    
    2927
    -		       (%file->name (cast buf c-call:c-string)))
    
    2928
    -	       (cast buf (* c-call:unsigned-char))))))
    
    2929
    -
    
    2930 2904
     (defun unix-mkstemp (template)
    
    2931 2905
       _N"Generates a unique temporary file name from TEMPLATE, and creates
    
    2932 2906
       and opens the file.  On success, the corresponding file descriptor