You can just use read (or stream-read) which returns less bytes if the file is smaller:
http://docs.factorcode.org/content/word-read,io.html So this does what you want: "/path/to/file" utf8 [ 1024 read ] with-file-reader The stream-read-partial is used for some performance improvements in slurping a whole file in chunks via each-stream-block. On Mon, Sep 21, 2015 at 8:35 AM, Alexander Ilin <ajs...@yandex.ru> wrote: > Hello! > > I need to read a head of a file (name provided) up to 1024 bytes (return > shorter string if the file size is less than 1024). I will then hash the > read data. > > I'd like to understand the difference between stream-read and > stream-read-partial. Which one should I use for my task? Is the difference > in the blocking behaviour? > > ---=====--- > Александр > > > ------------------------------------------------------------------------------ > _______________________________________________ > Factor-talk mailing list > Factor-talk@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/factor-talk >
------------------------------------------------------------------------------
_______________________________________________ Factor-talk mailing list Factor-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/factor-talk