Skip to content

Commit dd52dd9

Browse files
pmeinhardtandreasknoepfle
authored andcommitted
Simplify tar pipe example
Apparently `:erl_tar.add/3` recursively adds files and subdirectories.
1 parent 59114ef commit dd52dd9

File tree

1 file changed

+1
-12
lines changed

1 file changed

+1
-12
lines changed

examples/tarpipe.exs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,8 @@ end
4343
end)
4444

4545
source = "test/fixtures"
46-
# :ok = :erl_tar.add(tar, to_charlist(source), to_charlist(source))
4746

48-
with {:ok, names} <- File.ls(source) do
49-
Enum.each(names, fn name ->
50-
path = Path.join(source, name)
51-
52-
with {:ok, stat} <- File.stat(path, time: :posix) do
53-
IO.puts("#{stat.type}: #{path}")
54-
55-
:ok = :erl_tar.add(tar, to_charlist(path), to_charlist(path), atime: stat.atime, mtime: stat.mtime, ctime: stat.ctime)
56-
end
57-
end)
58-
end
47+
:ok = :erl_tar.add(tar, to_charlist(source), to_charlist(source))
5948

6049
:ok = :erl_tar.close(tar)
6150

0 commit comments

Comments
 (0)