(FILECREATED "16-May-85 11:20:35" {ERIS}<LISPCORE>SOURCES>LFSETFILEPTRPATCH.;1 2568 changes to: (VARS LFSETFILEPTRPATCHCOMS)) (* Copyright (c) 1985 by Xerox Corporation. All rights reserved.) (PRETTYCOMPRINT LFSETFILEPTRPATCHCOMS) (RPAQQ LFSETFILEPTRPATCHCOMS ((FNS \LFReadOnePage))) (DEFINEQ (\LFReadOnePage [LAMBDA (stream streamPageNumber buffer lastStreamPage offset) (* mjs "16-May-85 11:10") (* * Reads a single page from stream. Returns the number of bytes read.) (* * If asked to read a page which is off the end of the stream, it will zero the page. Odd though it may seem, reading off the end of the file is reasonable behavior for copybytes: buffer pages must come from somewhere, and copybytes may not have to write the whole page, and in general copybytes does not know whether a page is actually in a file or off the end of it. Seems inefficient, but since reading past eof does not actually require disk access, its not that bad.) (* * Pilot level numbers pages starting from 0; so does stream, but stream does not count the leader page.) (PROG ((vol (fetch (DLIONSTREAM VOLUME) of stream)) (file (fetch (DLIONSTREAM FILEDESC) of stream)) (filePageNumber (ADD1 streamPageNumber)) offset) (RETURN (if (AND (LEQ streamPageNumber lastStreamPage) (LESSP filePageNumber (fetch (FileDescriptor size) of file))) then (* * If page inside stream, then it has presumably already been written; read it in.) (\PFGetPage file filePageNumber (\PFFindPageAddr file filePageNumber) buffer) (if (EQ streamPageNumber lastStreamPage) then (* * If this was the last page in the file, then fill in the trailing bytes with nulls.) (SETQ offset (fetch (DLIONSTREAM EOFFSET) of stream)) (if (EQ offset 0) then (SETQ offset BYTESPERPAGE) else (for byte from offset to (SUB1 BYTESPERPAGE) do (\PUTBASEBYTE buffer byte 0))) offset else BYTESPERPAGE) else (* * If this was outside the stream, clear the buffer.) (\ZEROPAGE (fetch (POINTER PAGE#) of buffer)) 0]) ) (PUTPROPS LFSETFILEPTRPATCH COPYRIGHT ("Xerox Corporation" 1985)) (DECLARE: DONTCOPY (FILEMAP (NIL (309 2480 (\LFReadOnePage 319 . 2478))))) STOP