]> matita.cs.unibo.it Git - helm.git/blob - helm/DEVEL/lablgtk/lablgtk_20000829-0.1.0/applications/browser/useunix.ml
- the mathql interpreter is not helm-dependent any more
[helm.git] / helm / DEVEL / lablgtk / lablgtk_20000829-0.1.0 / applications / browser / useunix.ml
1 (* $Id$ *)
2
3 open Unix
4
5 let get_files_in_directory dir =
6   try
7   let dirh = opendir dir in
8   let rec get_them () =
9     try
10       let x = readdir dirh in
11       x :: get_them ()
12     with
13       _ -> closedir dirh; [] 
14   in
15     Sort.list ~order:(<) (get_them ())
16   with Unix_error _ -> []
17
18 let is_directory name =
19   try
20     (stat name).st_kind = S_DIR
21   with _ -> false
22
23 let get_directories_in_files ~path =
24   List.filter ~pred:(fun x -> is_directory  (path ^ "/" ^ x))
25
26 (************************************************** Subshell call *)
27 let subshell ~cmd =
28   let rc = open_process_in ~cmd in
29   let rec it () =
30     try 
31       let x = input_line rc in x :: it ()
32     with _ -> []
33   in 
34   let answer = it () in
35   close_process_in rc;
36   answer