[Factor-talk] stream-read

2015-09-21 Thread Alexander Ilin
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

Re: [Factor-talk] stream-read

2015-09-21 Thread John Benediktsson
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

Re: [Factor-talk] stream-read

2015-09-21 Thread Alexander Ilin
Great, thank you! 21.09.2015, 19:23, "John Benediktsson" : > 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 [