From 2e81ecf46d44b91bcdef35ef3e900554f3cb187c Mon Sep 17 00:00:00 2001 From: dianshi Date: Wed, 8 Jul 2020 20:46:26 +0100 Subject: ols simple directory list --- ols/ols.ml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/ols/ols.ml b/ols/ols.ml index e69de29..96f9847 100644 --- a/ols/ols.ml +++ b/ols/ols.ml @@ -0,0 +1,25 @@ +open Arg +open Unix +open Scanf +open Printf + +let main dir = + let _ = Printf.printf "list directory %s" dir in + let dirfd = opendir dir in + try + while true do + let fname = readdir dirfd in + Printf.printf "%s\n" fname + done + with End_of_file -> closedir dirfd + + +let num = Array.length Sys.argv +let _ = if num == 2 then + begin + (*Printf.printf "%s\n" Sys.argv.(1) *) + main Sys.argv.(1) + end + else + main "." + -- cgit v1.2.3