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

Commits:

2 changed files:

Changes:

  • src/code/extensions.lisp
    ... ... @@ -613,11 +613,24 @@
    613 613
       course) change at arbitary times."
    
    614 614
       `(lisp::pointer-hash ,x))
    
    615 615
     
    
    616
    -(alien:def-alien-routine os-temp-path c-call:c-string)
    
    617 616
     
    
    618 617
     (defun get-os-temp-path ()
    
    619
    -  "Get a path to an appropriate temporary location from the OS"
    
    620
    -  "/tmp/")
    
    618
    +  "Get a path to an appropriate temporary location from the OS.  A string
    
    619
    +  is returned to that path.  The path ends with a \"/\" character."
    
    620
    +  (let ((path (alien:alien-funcall
    
    621
    +	       (alien:extern-alien "os_temp_path"
    
    622
    +				   (function (alien:* c-call:char))))))
    
    623
    +    (when (alien:null-alien path)
    
    624
    +      (error "Unable to find path to temporary directory"))
    
    625
    +
    
    626
    +    (unwind-protect
    
    627
    +	 (let* ((string (unix::%file->name (cast path c-call:c-string)))
    
    628
    +		(len (length string)))
    
    629
    +	   (if (char= #\/ (aref string (1- len)))
    
    630
    +	       string
    
    631
    +	       (concatenate 'string string "/")))
    
    632
    +      (unless (alien:null-alien path)
    
    633
    +	(alien:free-alien path)))))
    
    621 634
     
    
    622 635
     ;;; WITH-TEMPORARY-STREAM  -- Public
    
    623 636
     ;;;
    

  • src/lisp/os-common.c
    ... ... @@ -946,7 +946,6 @@ os_temp_path()
    946 946
         // macosx has a secure per-user temporary directory.
    
    947 947
         // Don't cache the result as this is only called once.
    
    948 948
         char path[PATH_MAX];
    
    949
    -    char *result;
    
    950 949
     
    
    951 950
         int pathSize = confstr(_CS_DARWIN_USER_TEMP_DIR, path, PATH_MAX);
    
    952 951
         if (pathSize == 0 || pathSize > PATH_MAX) {