From: Chris Hanson Date: Thu, 25 Feb 1999 22:15:45 +0000 (+0000) Subject: Change heuristics used to find a temporary directory. X-Git-Tag: 20090517-FFI~4597 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=edef5c8b2b422908955139711ec010eb9848b54b;p=mit-scheme.git Change heuristics used to find a temporary directory. --- diff --git a/v7/src/runtime/ntprm.scm b/v7/src/runtime/ntprm.scm index e88b1b18e..3364151fe 100644 --- a/v7/src/runtime/ntprm.scm +++ b/v7/src/runtime/ntprm.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: ntprm.scm,v 1.27 1999/02/01 03:42:09 cph Exp $ +$Id: ntprm.scm,v 1.28 1999/02/25 22:15:45 cph Exp $ Copyright (c) 1992-1999 Massachusetts Institute of Technology @@ -222,16 +222,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. (trydir (get-environment-variable "HOME"))))) (%users-directory (lambda () - (trydir (get-environment-variable "USERDIR")))) - (%system-root-directory - (lambda () - (let ((sysroot - (or (trydir (get-environment-variable "SystemRoot")) - (trydir (get-environment-variable "windir")) - (trydir (get-environment-variable "winbootdir"))))) - (if (not sysroot) - (error "Unable to find Windows system root.")) - (pathname-new-directory sysroot '(ABSOLUTE)))))) + (trydir (get-environment-variable "USERDIR"))))) (set! current-user-name (lambda () @@ -256,7 +247,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. (and user-name usersdir (trydir (merge-pathnames user-name usersdir)))) - (let ((rootdir (%system-root-directory))) + (let ((rootdir (nt/system-root-directory))) (or (and user-name (trydir (merge-pathnames user-name rootdir))) rootdir))))))) @@ -282,7 +273,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. (directory-pathname-as-file homedir)))) ;; Look for USER-NAME in root directory of system ;; drive. - (trydir (merge-pathnames user-name (%system-root-directory))) + (trydir (merge-pathnames user-name (nt/system-root-directory))) ;; OK, give up: (error "Can't find user's home directory:" user-name)))))) @@ -325,15 +316,29 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. (lambda (name) (let ((value (get-environment-variable name))) (and value - (try-directory value)))))) - (or (try-variable "TEMP") + (try-directory value))))) + (try-system-directory + (lambda (directory) + (try-directory + (merge-pathnames directory (nt/system-root-directory)))))) + (or (try-variable "TMPDIR") + (try-variable "TEMP") (try-variable "TMP") - (try-directory "/tmp") - (try-directory "c:/") + (try-system-directory "\\temp") + (try-system-directory "\\tmp") + (try-system-directory "") (try-directory ".") - (try-directory "/") (error "Can't find temporary directory."))))) +(define (nt/system-root-directory) + (let ((sysroot + (or (trydir (get-environment-variable "SystemRoot")) + (trydir (get-environment-variable "windir")) + (trydir (get-environment-variable "winbootdir"))))) + (if (not sysroot) + (error "Unable to find Windows system root.")) + (pathname-new-directory sysroot '(ABSOLUTE)))) + (define (os/file-end-of-line-translation pathname) (if (let ((type (dos/fs-drive-type pathname))) (or (string=? "NFS" (car type)) diff --git a/v7/src/runtime/os2prm.scm b/v7/src/runtime/os2prm.scm index d29275d53..cf68fc23b 100644 --- a/v7/src/runtime/os2prm.scm +++ b/v7/src/runtime/os2prm.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: os2prm.scm,v 1.40 1999/02/01 03:42:01 cph Exp $ +$Id: os2prm.scm,v 1.41 1999/02/25 22:15:41 cph Exp $ Copyright (c) 1994-1999 Massachusetts Institute of Technology @@ -183,15 +183,26 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. (lambda (name) (let ((value (get-environment-variable name))) (and value - (try-directory value)))))) - (or (try-variable "TEMP") + (try-directory value))))) + (try-system-directory + (lambda (directory) + (try-directory + (merge-pathnames directory (os2/system-root-directory)))))) + (or (try-variable "TMPDIR") + (try-variable "TEMP") (try-variable "TMP") - (try-directory "\\tmp") - (try-directory "c:\\") + (try-system-directory "\\temp") + (try-system-directory "\\tmp") + (try-system-directory "") (try-directory ".") - (try-directory "\\") (error "Can't find temporary directory."))))) +(define (os2/system-root-directory) + (let ((system.ini (get-environment-variable "SYSTEM_INI"))) + (if (not (file-exists? system.ini)) + (error "Unable to find OS/2 system.ini file:" system.ini)) + (pathname-new-directory (directory-pathname system.ini) '(ABSOLUTE)))) + (define-integrable os2/current-pid (ucode-primitive current-pid 0)) @@ -212,14 +223,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. (trydir (get-environment-variable "HOME")))) (%users-directory (lambda () - (trydir (get-environment-variable "USERDIR")))) - (%system-root-directory - (lambda () - (let ((system.ini (get-environment-variable "SYSTEM_INI"))) - (if (not (file-exists? system.ini)) - (error "Unable to find OS/2 system.ini file:" system.ini)) - (pathname-new-directory (directory-pathname system.ini) - '(ABSOLUTE)))))) + (trydir (get-environment-variable "USERDIR"))))) (set! current-user-name (lambda () @@ -243,7 +247,7 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. (or (let ((usersdir (%users-directory))) (and usersdir (trydir (merge-pathnames user-name usersdir)))) - (let ((rootdir (%system-root-directory))) + (let ((rootdir (os2/system-root-directory))) (or (trydir (merge-pathnames user-name rootdir)) rootdir))))))) @@ -268,7 +272,8 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. (directory-pathname-as-file homedir)))) ;; Look for USER-NAME in root directory of system ;; drive. - (trydir (merge-pathnames user-name (%system-root-directory))) + (trydir + (merge-pathnames user-name (os2/system-root-directory))) ;; OK, give up: (error "Can't find user's home directory:" user-name)))))) diff --git a/v7/src/runtime/unxprm.scm b/v7/src/runtime/unxprm.scm index 549cb01c6..38059048c 100644 --- a/v7/src/runtime/unxprm.scm +++ b/v7/src/runtime/unxprm.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: unxprm.scm,v 1.53 1999/02/01 03:42:13 cph Exp $ +$Id: unxprm.scm,v 1.54 1999/02/25 22:15:37 cph Exp $ Copyright (c) 1988-1999 Massachusetts Institute of Technology @@ -98,10 +98,12 @@ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. (let ((value (get-environment-variable name))) (and value (try-directory value)))))) - (or (try-variable "TEMP") + (or (try-variable "TMPDIR") + (try-variable "TEMP") (try-variable "TMP") - (try-directory "/tmp") + (try-directory "/var/tmp") (try-directory "/usr/tmp") + (try-directory "/tmp") (error "Can't find temporary directory."))))) (define (file-attributes-direct filename)