Update of /project/osicat/cvsroot/src In directory common-lisp.net:/tmp/cvs-serv17998
Modified Files: ffi.lisp osicat.asd osicat.lisp packages.lisp release.txt test-osicat.lisp version.txt Added Files: ports.lisp Log Message: Cleaned up OPEN-TEMPORARY-FILE and separated out MAKE-FD-STREAMS to make way for further fun in that direction. Fixed some tests. Prepared things for upcoming 0.5.0 release.
Date: Sun Sep 25 20:24:35 2005 Author: jsquires
Index: src/ffi.lisp diff -u src/ffi.lisp:1.6 src/ffi.lisp:1.7 --- src/ffi.lisp:1.6 Sat Sep 17 13:03:15 2005 +++ src/ffi.lisp Sun Sep 25 20:24:35 2005 @@ -104,7 +104,7 @@ :returning :int)
(def-array-pointer cstring-array :cstring) -(def-foreign-var "environ" cstring-array "osicat") +(def-foreign-var "environ" 'cstring-array "osicat")
(def-function "getpwnam" ((name :cstring)) :module "osicat"
Index: src/osicat.asd diff -u src/osicat.asd:1.10 src/osicat.asd:1.11 --- src/osicat.asd:1.10 Mon Jul 26 15:25:30 2004 +++ src/osicat.asd Sun Sep 25 20:24:35 2005 @@ -69,7 +69,7 @@ ;;;; SYSTEM
(defsystem :osicat - :version "0.4.1" + :version "0.5.0" :depends-on (:uffi) :components ((:c-source-file "osicat-glue") @@ -77,8 +77,9 @@ (:grovel-file "grovel-constants" :depends-on ("packages")) (:file "early-util" :depends-on ("packages")) (:file "ffi" :depends-on ("early-util")) + (:file "ports" :depends-on ("packages")) (:file "osicat" :depends-on - ("osicat-glue" "ffi" "grovel-constants")))) + ("osicat-glue" "ports" "ffi" "grovel-constants"))))
;;;; TESTING
Index: src/osicat.lisp diff -u src/osicat.lisp:1.36 src/osicat.lisp:1.37 --- src/osicat.lisp:1.36 Sat Sep 17 13:10:48 2005 +++ src/osicat.lisp Sun Sep 25 20:24:35 2005 @@ -21,7 +21,7 @@
(in-package :osicat)
-(defparameter *osicat-version* '(0 4 1) +(defparameter *osicat-version* '(0 5 0) "variable *OSICAT-VERSION*
Osicat version number represented as a list of three integers. The @@ -131,45 +131,51 @@
;;;; Temporary files
-(defun make-temporary-file (&key (element-type 'character)) - "function MAKE-TEMPORARY-FILE (&key element-type) => stream - -Makes a temporary file setup for input and output, and returns a -stream connected to that file. ELEMENT-TYPE specifies the unit of -transaction of the stream. Consider using WITH-TEMPORARY-FILE instead -of this function. +(defun open-temporary-file (&key (element-type 'character) + (external-format :default)) + "function OPEN-TEMPORARY-FILE (&key element-type) => stream + +Creates a temporary file setup for input and output, and returns a +stream connected to that file. The file itself is unlinked once it +has been opened. ELEMENT-TYPE specifies the unit of transaction of +the stream. Consider using WITH-TEMPORARY-FILE instead of this +function.
On failure, a FILE-ERROR may be signalled." - #+(or cmu sbcl) + #+osicat:fd-streams (let ((fd (osicat-tmpfile))) - (unless (>= fd 0) (signal 'file-error)) - #+cmu(sys:make-fd-stream fd :input t :output t - :element-type element-type) - #+sbcl(sb-sys:make-fd-stream fd :input t :output t - :element-type element-type)) - ;; XXX Warn about insecurity? Or is any platform too dumb to have - ;; fds, also relatively safe from race conditions through obscurity? - ;; XXX Will unlinking the file after opening the stream work the way - ;; we expect? (it seems to, from testing.) - #-(or cmu sbcl) - (let* ((name (tmpnam (make-null-pointer 'cstring))) - (stream (open (convert-from-cstring name) :direction :io - :element-type element-type))) - (unlink name) - stream)) + (unless (>= fd 0) (error 'file-error)) + (make-fd-stream fd :direction :io :element-type element-type + :external-format external-format)) + #-osicat:fd-streams + ;; 100 is an arbitrary number of iterations to try before failing. + (do ((counter 100 (1- counter))) + ((zerop counter) (error 'file-error)) + (let* ((name (tmpnam (make-null-pointer 'cstring))) + (stream (open (convert-from-cstring name) :direction :io + :element-type element-type + :external-format external-format + :if-exists nil))) + (when stream + (unlink name) + (return stream)))))
(defmacro with-temporary-file ((stream &key element-type) &body body) "macro WITH-TEMPORARY-FILE (stream &key element-type) &body body => stream
Within the lexical scope of the body, stream is connected to a -temporary file as created by MAKE-TEMPORARY-FILE. The file is closed +temporary file as created by OPEN-TEMPORARY-FILE. The file is closed automatically once BODY exits." - `(let ((,stream (make-temporary-file - ,@(when element-type `(:element-type ,element-type))))) + `(let ((,stream)) (unwind-protect - (progn ,@body) - (close ,stream :abort t)))) + (progn + (setf ,stream + (open-temporary-file + ,@(when element-type `(:element-type ,element-type)))) + ,@body) + (when ,stream + (close ,stream :abort t)))))
;;;; Directory access
Index: src/packages.lisp diff -u src/packages.lisp:1.13 src/packages.lisp:1.14 --- src/packages.lisp:1.13 Tue Jul 5 18:55:46 2005 +++ src/packages.lisp Sun Sep 25 20:24:35 2005 @@ -58,7 +58,7 @@ ;; Permissions #:file-permissions ;; Temporary files - #:make-temporary-file + #:open-temporary-file #:with-temporary-file ;; Password entries #:user-info @@ -69,4 +69,6 @@ #:absolute-pathname-p #:relative-pathname-p #:unmerge-pathnames + ;; FD-streams symbol + #:fd-streams ))
Index: src/release.txt diff -u src/release.txt:1.5 src/release.txt:1.6 --- src/release.txt:1.5 Mon Mar 1 00:52:23 2004 +++ src/release.txt Sun Sep 25 20:24:35 2005 @@ -1,4 +1,5 @@ osicat.asd +ports.lisp ffi.lisp early-util.lisp grovel-constants.lisp
Index: src/test-osicat.lisp diff -u src/test-osicat.lisp:1.11 src/test-osicat.lisp:1.12 --- src/test-osicat.lisp:1.11 Tue Jul 5 18:55:47 2005 +++ src/test-osicat.lisp Sun Sep 25 20:24:35 2005 @@ -49,8 +49,9 @@ (error () :error))))) t)
-;;; XXX: (user-homedir-pathname) is "home:" under CMUCL, so this test -;;; will fail. +;;; FIXME: (user-homedir-pathname) is "home:" under CMUCL, so this +;;; test will fail. +#-cmu (deftest environment.1 (namestring (probe-file (cdr (assoc "HOME" (environment) :test #'equal)))) @@ -171,7 +172,7 @@ #.(namestring *test-dir*))
;; Test the case of reading a link with a very long name. -(deftest read-link.1 +(deftest read-link.2 (let ((link (merge-pathnames "make-link-test-link" *test-dir*)) (file (ensure-file "a-very-long-tmp-file-name-explicitly-for-the-purpose-of-testing-a-certain-condition-in-read-link-please-ignore-thanks"))) (unwind-protect
Index: src/version.txt diff -u src/version.txt:1.11 src/version.txt:1.12 --- src/version.txt:1.11 Mon Jul 26 15:25:30 2004 +++ src/version.txt Sun Sep 25 20:24:35 2005 @@ -1 +1 @@ -0.4.1 +0.5.0