Ignore:
Timestamp:
Oct 12, 2008, 8:07:56 AM (11 years ago)
Author:
gb
Message:

In the FILE-IOBLOCK defstruct: don't claim that OCTET-POS and FILEEOF
slots are of :type fixnum.

In STREAM-LENGTH methods on FILE-STREAM, return NIL if the ioblock
function returns a negative value (which generally means "we got
an error trying to determine the length of the file.")

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/level-1/l1-sysio.lisp

    r9869 r11059  
    1818
    1919(defstruct (file-ioblock (:include ioblock))
    20   (octet-pos 0 :type fixnum)            ; current io position in octets
    21   (fileeof 0 :type fixnum)              ; file length in elements
     20  (octet-pos 0 )                       ; current io position in octets
     21  (fileeof 0 )                          ; file length in elements
    2222  )
    2323
     
    590590(defmethod stream-length ((stream fundamental-file-input-stream) &optional newlen)
    591591  (with-stream-ioblock-input (file-ioblock stream :speedy t)
    592     (%ioblock-input-file-length file-ioblock newlen)))
     592    (let* ((res (%ioblock-input-file-length file-ioblock newlen)))
     593      (and res (>= res 0) res))))
     594
    593595
    594596(defmethod stream-length ((stream basic-file-input-stream) &optional newlen)
    595597  (let* ((file-ioblock (basic-stream-ioblock stream)))
    596598    (with-ioblock-input-locked (file-ioblock)
    597       (%ioblock-input-file-length file-ioblock newlen))))
     599      (let* ((res (%ioblock-input-file-length file-ioblock newlen)))
     600        (and res (>= res 0) res)))))
    598601
    599602
    600603(defmethod stream-length ((s fundamental-file-output-stream) &optional newlen)
    601604  (with-stream-ioblock-output (file-ioblock s :speedy t)
    602     (%ioblock-output-file-length file-ioblock newlen)))
     605    (let* ((res (%ioblock-output-file-length file-ioblock newlen)))
     606      (and res (>= res 0) res))))
    603607
    604608
     
    606610  (let* ((file-ioblock (basic-stream-ioblock stream)))
    607611    (with-ioblock-output-locked (file-ioblock)
    608       (%ioblock-output-file-length file-ioblock newlen))))
     612      (let* ((res (%ioblock-output-file-length file-ioblock newlen)))
     613        (and res (>= res 0) res)))))
    609614
    610615(defmethod stream-length ((s fundamental-file-io-stream) &optional newlen)
    611616  (with-stream-ioblock-input (file-ioblock s :speedy t)
    612     (%ioblock-output-file-length file-ioblock newlen)))
     617    (let* ((res (%ioblock-output-file-length file-ioblock newlen)))
     618      (and res (>= res 0) res))))
    613619
    614620(defmethod stream-length ((stream basic-file-io-stream) &optional newlen)
    615621  (let* ((file-ioblock (basic-stream-ioblock stream)))
    616622    (with-ioblock-input-locked (file-ioblock)
    617       (%ioblock-output-file-length file-ioblock newlen))))
     623      (let* ((res (%ioblock-output-file-length file-ioblock newlen)))
     624        (and res (>= res 0) res)))))
    618625
    619626(defun close-file-stream (s abort)
Note: See TracChangeset for help on using the changeset viewer.