Browse files

remove unused accumulate variable since file:read_file/1 is used

  • Loading branch information...
1 parent 60840b4 commit b30e61e84399cc955a9559afda84461cbfe88df1 @technoweenie committed Mar 2, 2012
Showing with 4 additions and 9 deletions.
  1. +4 −9 lib/file_utils.ex
View
13 lib/file_utils.ex
@@ -24,25 +24,20 @@ defmodule FileUtils do
def read(filename, mode, cb) when is_function(cb) do
{:ok, io} = :file.open(filename, mode)
- read_file_chunk(io, false, cb)
+ read_file_chunk(io, cb)
end
- defp read_file_chunk(io, acc, cb) do
+ defp read_file_chunk(io, cb) do
res = :file.read(io, 16384)
case res do
match: {:ok, data}
- if is_function(cb, 1) do
- cb.(data)
- else:
- acc = cb.(acc || [], data)
- end
- read_file_chunk(io, acc, cb)
+ cb.(data)
+ read_file_chunk(io, cb)
match: {:error, reason}
:file.close(io)
res
match: :eof
:file.close(io)
- acc
end
end
end

0 comments on commit b30e61e

Please sign in to comment.