open Arg open Unix open Scanf open Printf let files = ref [];; let main dir = let _ = Printf.printf "list directory %s" dir in (*let files = ref [""] in*) let dirfd = opendir dir in try while true do let fname = readdir dirfd in let _ = (Printf.printf "%s\n" fname) in files := List.append !files [fname] done with End_of_file -> closedir dirfd let rec print_list lst = match lst with | [] -> [] | hd::tl -> let _ = Printf.printf "%s\n" hd in print_list tl let num = Array.length Sys.argv let _ = if num == 2 then begin (*Printf.printf "%s\n" Sys.argv.(1) *) let _ = main Sys.argv.(1) in let _ = print_list !files in Printf.printf "\n" end else begin main "." end