forked from APTE/APTE
-
Notifications
You must be signed in to change notification settings - Fork 0
/
extract.ml
61 lines (52 loc) · 1.74 KB
/
extract.ml
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
let is_ml_mli file =
let size = String.length file in
if (String.sub file (size-3) 3 = ".ml") || (String.sub file (size-4) 4 = ".mli")
then true
else false
let is_mll_mly file =
let size = String.length file in
if String.sub file (size-4) 4 = ".mll" || String.sub file (size-4) 4 = ".mly"
then true
else false
let authorise_dir = [
"parser";
"length_equivalence";
"standard_library";
"trace_equivalence"
]
let rec get_all_adress curdir =
let vect = Sys.readdir curdir in
for i = 0 to (Array.length vect) -1 do
let new_adress = Printf.sprintf "%s/%s" curdir vect.(i) in
if Sys.is_directory new_adress && List.exists (fun t -> t = vect.(i)) authorise_dir
then
begin
let cmd = Printf.sprintf "mkdir Extract/%s" new_adress in
Printf.printf "%s\n" cmd;
ignore (Sys.command cmd);
get_all_adress new_adress
end;
if is_ml_mli new_adress
then
begin
let cmd = Printf.sprintf "cat Source/licence.txt %s >> Extract/%s" new_adress new_adress in
Printf.printf "%s\n" cmd;
ignore (Sys.command cmd)
end;
if vect.(i) = "Makefile" || is_mll_mly new_adress
then
begin
let cmd = Printf.sprintf "cp %s Extract/%s" new_adress new_adress in
Printf.printf "%s\n" cmd;
ignore (Sys.command cmd)
end;
done
let _ =
ignore (Sys.command "rm -rf Extract");
ignore (Sys.command "mkdir Extract");
ignore (Sys.command "mkdir Extract/Source");
ignore (Sys.command "mkdir Extract/Example");
ignore (Sys.command "cp Example/*.txt Extract/Example");
ignore (Sys.command "cp README Extract/README");
ignore (Sys.command "cp Documentation.pdf Extract/Documentation.pdf");
get_all_adress "Source"