summaryrefslogtreecommitdiff
path: root/ols/ols.ml
blob: 5e53bc7c8d9b1bd004ebed7bf83d4b17a34c67cb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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