[gambit-list] reading file into string / length of file

lowly coder lowlycoder at huoyanjinjing.com
Sun Jun 28 23:22:25 EDT 2009


I'm an idiot. I forgot about the #f option to read-line ... in fact, I've
even used it myself.

On Sun, Jun 28, 2009 at 8:19 PM, Marc Feeley <feeley at iro.umontreal.ca>wrote:

>
> On 28-Jun-09, at 10:46 PM, lowly coder wrote:
>
>  I want to read a file into a string. After I open it up, is there a way to
>> get the length of the file? (or even before I open it up?)
>>
>> I see that we have read-substring and read-u8vector
>>
>> Currently, the best solution appears to be ... do a read-u8vector on it,
>> get it's string length, then re-open the file and do a read-substring on it
>> ... surely there's something more elegant. :-)
>>
>
> % gsi
> Gambit v4.4.4
>
> > (file-info-size (file-info "test.txt"))
> 53
> > (call-with-input-file "test.txt" (lambda (p) (read-line p #f)))
> "the read-line procedure is\ndocumented in the manual!\n"
> > (help read-line)
>
> Marc
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20090628/4885b690/attachment.htm>


More information about the Gambit-list mailing list