1,27 → 1,7 |
#! /usr/bin/env elixir |
#! /usr/bin/env escript |
# https://rosettacode.org/wiki/Walk_a_directory/Recursively |
# TODO : de hele traversal nog schrijven, dit is alleen argument parsing |
|
# ============================================================================= |
# Create |
# name : Andre Rikkert de Koe date: mar 2018 |
# descr : filefind |
# This is a demo of programming in the elixir language. |
# Its part of a project to implement a program to create a directory |
# tree similar to the output of the Unix find program. |
# EUID : Any user who has read access to all the files being searched for. |
# run : interactive |
# |
# Changes |
# name : date: |
# descr : short description |
# |
# ============================================================================= |
|
# ============================================================================= |
# Functions |
# ============================================================================= |
|
defmodule DezeModule do |
|
def usage(progname, mesg) do |
29,29 → 9,8 |
IO.puts mesg |
end |
|
def traverse(directory) do |
File.cd!(directory) |
curdir2 = System.cwd() |
files = File.ls!(directory) |
for file <- files do |
pfile = curdir2 <> "/" <> file |
IO.puts pfile |
if File.dir?(pfile) do |
traverse(pfile) |
end |
end |
end |
|
def start_traverse(directory) do |
IO.puts directory |
traverse(directory) |
end |
end |
|
# ============================================================================= |
# Main |
# ============================================================================= |
# |
progname = System.cwd() |
|
if length(System.argv) == 1 do |
58,7 → 17,7 |
directory = Enum.at(System.argv(), 0) |
if File.dir?(directory) |
do |
DezeModule.start_traverse(directory) |
IO.puts "TODO: Now do the traversal" |
else |
DezeModule.usage(progname, "ERROR: Not a directory : " <> directory) |
end |