[Git][cmucl/cmucl][issue-373-handle-temp-files] 2 commits: Remove unused variable.

Raymond Toy pushed to branch issue-373-handle-temp-files at cmucl / cmucl Commits: 19b21612 by Raymond Toy at 2025-02-19T19:10:27-08:00 Remove unused variable. - - - - - 1a051ff3 by Raymond Toy at 2025-02-19T19:10:44-08:00 Update get-os-temp-path to call os_temp_path Directly call os_temp_path in get-os-temp-path. We take care to free the string that was returned. We also throw an error if NULL is returned. The path returned is made to end with a slash so that creating a CL pathname from it only has directory components. - - - - - 2 changed files: - src/code/extensions.lisp - src/lisp/os-common.c Changes: ===================================== src/code/extensions.lisp ===================================== @@ -613,11 +613,24 @@ course) change at arbitary times." `(lisp::pointer-hash ,x)) -(alien:def-alien-routine os-temp-path c-call:c-string) (defun get-os-temp-path () - "Get a path to an appropriate temporary location from the OS" - "/tmp/") + "Get a path to an appropriate temporary location from the OS. A string + is returned to that path. The path ends with a \"/\" character." + (let ((path (alien:alien-funcall + (alien:extern-alien "os_temp_path" + (function (alien:* c-call:char)))))) + (when (alien:null-alien path) + (error "Unable to find path to temporary directory")) + + (unwind-protect + (let* ((string (unix::%file->name (cast path c-call:c-string))) + (len (length string))) + (if (char= #\/ (aref string (1- len))) + string + (concatenate 'string string "/"))) + (unless (alien:null-alien path) + (alien:free-alien path))))) ;;; WITH-TEMPORARY-STREAM -- Public ;;; ===================================== src/lisp/os-common.c ===================================== @@ -946,7 +946,6 @@ os_temp_path() // macosx has a secure per-user temporary directory. // Don't cache the result as this is only called once. char path[PATH_MAX]; - char *result; int pathSize = confstr(_CS_DARWIN_USER_TEMP_DIR, path, PATH_MAX); if (pathSize == 0 || pathSize > PATH_MAX) { View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/1f465c570bf655599cf5cfd... -- View it on GitLab: https://gitlab.common-lisp.net/cmucl/cmucl/-/compare/1f465c570bf655599cf5cfd... You're receiving this email because of your account on gitlab.common-lisp.net.
participants (1)
-
Raymond Toy (@rtoy)