hey!
what is it you're trying to do exactly?
you want to read and write files or would you like to create random bits of information?
nice!
The offset file will be a json file so you could potentially read it like this:
{:ok, body} = File.read(log.offset)
Then you should be able to decode the body with the Jason
library.
While testing this for myself I noticed that my computer had a lot of issues reading the huge file however.
Alternatively you could execute a command on your file-system instead (through a .sh script) with grep and sed to grab strings from your offset. You can see an example of sed here:
https://git.picodevelopment.nl/hendrikpeter/tmux-mac/blob/master/segments/weather.sh#L61 (I'm reading "icon": "someicon"
in that line there)
The offset file will be a json file
hi, if you mean the ~/.ssb/flume/log.offset
file, this isn't a json file. it's a flumelog-offset
file, an append-only log format where the records in our case are json.
ah you're right @dinoƧ𝔸Ⓤᖇ. neat bit of code there there @punkmonk!
You could potentially make it a tad more tolerant by dealing with the {:error, reason}
and hinting your supervisor how to act (depends on how you set up the supervisor)
so
case {:ok, contents} = :file.pread(io_device, offset, bytes) do
{:ok, contents } -> IO.puts contents
{:error, reason } -> raise "oops", reason
end
What am I writing. sorry that first line needs to be
case :file.pread(io_device, offset, bytes) do
ofc... sorry 'bout that