[plt-scheme] reading a whole file

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Thu Nov 13 16:25:38 EST 2008

At Tue, 4 Nov 2008 14:20:13 +0000, "Stephen De Gabrielle" wrote:
> Is there a function to read a whole file into memory (as a string)
> 
>  (lambda (i) (read-string 80000 i))
> or is there something better?

As of 4.1.2.5, we've added many convenience functions to `scheme/file'
and `scheme/port'. Also, `scheme' now re-exports `scheme/port'.


Added to `scheme/file':

   file->string
   file->bytes
   file->value  ; composes `call-with-input-file*' and `read'
   file->lines
   file->bytes-lines
   display-lines-to-file ; complements both file->lines and file->bytes-lines
   write-to-file
   display-to-file

Added to `scheme/port':

   call-with-input-string
   call-with-input-bytes
   with-input-from-string
   with-input-from-bytes
   call-with-output-string
   call-with-output-bytes
   with-output-to-string
   with-output-to-bytes
   port->string
   port->bytes
   port->lines
   port->bytes-lines
   display-lines


Matthew



Posted on the users mailing list.