X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcode%2Funix.lisp;h=64db7ed483ee66aef185abe89e3b48cb4a42ccaf;hb=6caf3ed5713773cb423f46bf40a29f2438c97c78;hp=d5ac4836b72c5d6c813d181c199d687ee7fc4913;hpb=bb3994fcc9a556d1a26d35f6ff9386d01030821d;p=sbcl.git diff --git a/src/code/unix.lisp b/src/code/unix.lisp index d5ac483..64db7ed 100644 --- a/src/code/unix.lisp +++ b/src/code/unix.lisp @@ -276,6 +276,7 @@ corresponds to NAME, or NIL if there is none." (void-syscall ("access" c-string int) path mode)) ;;; values for the second argument to UNIX-LSEEK +;;; Note that nowadays these are called SEEK_SET, SEEK_CUR, and SEEK_END (defconstant l_set 0) ; to set the file pointer (defconstant l_incr 1) ; to increment the file pointer (defconstant l_xtnd 2) ; to extend the file size @@ -880,6 +881,31 @@ corresponds to NAME, or NIL if there is none." (syscall ("fstat_wrapper" int (* (struct wrapped_stat))) (%extract-stat-results (addr buf)) fd (addr buf)))) + +#!-win32 +(defun fd-type (fd) + (declare (type unix-fd fd)) + (let ((fmt (logand + sb!unix:s-ifmt + (or (with-alien ((buf (struct wrapped_stat))) + (syscall ("fstat_wrapper" int (* (struct wrapped_stat))) + (slot buf 'st-mode) + fd (addr buf))) + 0)))) + (cond ((logtest sb!unix:s-ififo fmt) + :fifo) + ((logtest sb!unix:s-ifchr fmt) + :character) + ((logtest sb!unix:s-ifdir fmt) + :directory) + ((logtest sb!unix:s-ifblk fmt) + :block) + ((logtest sb!unix:s-ifreg fmt) + :regular) + ((logtest sb!unix:s-ifsock fmt) + :socket) + (t + :unknown)))) ;;;; time.h