Changeset 9277


Ignore:
Timestamp:
Apr 25, 2008, 9:10:18 AM (11 years ago)
Author:
gb
Message:

stat fails on windows when pathname has trailing (forward or backward)
slash, so strip it off.
Use USERPROFILE env var to find home directory on Windows.
MS C library wants extra underscore before "unlink".
EOF-TRANSIENT-P on Windows if a console device, to some approximation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/win64/level-1/linux-files.lisp

    r9171 r9277  
    354354      (values nil nil nil nil nil nil nil nil nil)))
    355355
     356#+windows-target
     357(defun windows-strip-trailing-slash (namestring)
     358  (do* ((len (length namestring) (length namestring)))
     359       ((<= len 1) namestring)
     360    (let* ((p (1- len))
     361           (ch (char namestring p)))
     362      (unless (or (eql ch #\\)
     363                  (eql ch #\/))
     364        (return namestring))
     365      (setq namestring (subseq namestring 0 p)))))
     366
     367
    356368(defun %%stat (name stat)
    357   (with-filename-cstrs ((cname name))
     369  (with-filename-cstrs ((cname #+windows-target (windows-strip-trailing-slash name) #-windows-target name))
    358370    (%stat-values
    359371     #+linux-target
     
    674686environment variable. Returns NIL if there is no user with the ID uid."
    675687  #+windows-target
    676   (let* ((homedrive (getenv "HOMEDRIVE"))
    677          (homepath (getenv "HOMEPATH")))
    678     (and homedrive homepath (concatenate 'string homedrive homepath)))
     688  (declare (ignore userid))
     689  (with-native-utf-16-cstrs ((key "USERPROFILE"))
     690    (let* ((p (#__wgetenv key)))
     691      (unless (%null-ptr-p p)
     692        (get-foreign-namestring p))))
    679693  #-windows-target
    680694  (rlet ((pwd :passwd)
     
    691705(defun %delete-file (name)
    692706  (with-cstrs ((n name))
    693     (int-errno-call (#_unlink n))))
     707    (int-errno-call (#+windows-target #__unlink #-windows-target #_unlink n))))
    694708
    695709(defun os-command (string)
     
    12291243        (%errno-disp error))))
    12301244
     1245)
     1246
    12311247;;; EOF on a TTY is transient, but I'm less sure of other cases.
    12321248(defun eof-transient-p (fd)
    12331249  (case (%unix-fd-kind fd)
    12341250    (:tty t)
     1251    #+windows-target (:character-special t)
    12351252    (t nil)))
    12361253
    1237 )
     1254
    12381255
    12391256(defstruct (shared-resource (:constructor make-shared-resource (name)))
Note: See TracChangeset for help on using the changeset viewer.