Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- defmodule Directory do
- def flatten(path, destiny) do
- {:ok, files} = File.ls(path)
- Enum.map(files, fn(file) ->
- new_path = path <> "/" <> file
- if File.dir?(new_path) do
- flatten(new_path, destiny)
- else
- # Filesystem is disabled, so there is no copy function,
- # instead we will just print out our directories
- # File.copy(new_path, destiny <> "/" <> file)
- IO.puts "copy file from: #{new_path}"
- IO.puts "copy file to: #{destiny}/#{file}\n"
- end
- end)
- end
- end
- # No files system so:
- # * "elixir/lib/logger" is the directory which we intend to copy files from
- # * "fake_dir" is the fake directory which we intend to copy to
- Directory.flatten("elixir/lib/logger", "fake_dir")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement