Hi Charles,
thank you for your proposal.

I think it could be an interesting addition. But rather than just a
convenience function, make it behave more like its IO
conterpart: IO.read/2

Where you can pass the byte length, or :line.
Because sometimes is not about the bytes, but about the information
held in a certain number of lines in the file.

I'm thinking something like 

File.read(file_path, :line, 1)

# or to read the first five lines
File.read(file_path, :line, 1..5)

I would like to know how the rest of the list feels about it.


On Mon, 9 May 2016 10:36:15 -0700 (PDT)
Charles Okwuagwu <okwuagwu...@gmail.com> wrote:

> Can we have this convenience as a function in the File module?
> 
> read(file, start, length)
> 
> 
> 
> http://stackoverflow.com/q/37121605/44080
> 
> The suggested solution is not immideiately obvious 
> 
> {:ok, file} = :file.open(source_file, [:read, :binary]) 
> 
> :file.position(file, 5) # start_position = 5
> 
> :file.read(file, 10) # bytes to read = 10
> 
> 
> 

-- 
You received this message because you are subscribed to the Google Groups 
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to elixir-lang-core+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/elixir-lang-core/20160512192534.35e62698.eksperimental%40autistici.org.
For more options, visit https://groups.google.com/d/optout.

Reply via email to