equal
deleted
inserted
replaced
6 Basic library: functions, options, pairs, booleans, lists, integers, |
6 Basic library: functions, options, pairs, booleans, lists, integers, |
7 strings, lists as sets, association lists, generic tables, balanced trees, |
7 strings, lists as sets, association lists, generic tables, balanced trees, |
8 input / output, timing, filenames, misc functions. |
8 input / output, timing, filenames, misc functions. |
9 *) |
9 *) |
10 |
10 |
11 infix |> ~~ \ \\ orelf ins orf andf prefix upto downto mem union inter subset; |
11 infix |> ~~ \ \\ orelf ins orf andf prefix upto downto mem union inter subset |
|
12 subdir_of; |
12 |
13 |
13 |
14 |
14 structure Library = |
15 structure Library = |
15 struct |
16 struct |
16 |
17 |
693 |
694 |
694 (*For Makefiles: use the file, but exit with error code if errors found.*) |
695 (*For Makefiles: use the file, but exit with error code if errors found.*) |
695 fun exit_use fname = use fname handle _ => exit 1; |
696 fun exit_use fname = use fname handle _ => exit 1; |
696 |
697 |
697 |
698 |
698 (** filenames **) |
699 (** filenames and paths **) |
699 |
700 |
700 (*Convert UNIX filename of the form "path/file" to "path/" and "file"; |
701 (*Convert UNIX filename of the form "path/file" to "path/" and "file"; |
701 if filename contains no slash, then it returns "" and "file"*) |
702 if filename contains no slash, then it returns "" and "file"*) |
702 val split_filename = |
703 val split_filename = |
703 (pairself implode) o take_suffix (not_equal "/") o explode; |
704 (pairself implode) o take_suffix (not_equal "/") o explode; |
729 else (); |
730 else (); |
730 space_implode "/" (mk_relative (space_explode "/" cur_path) |
731 space_implode "/" (mk_relative (space_explode "/" cur_path) |
731 (space_explode "/" dest_path)) |
732 (space_explode "/" dest_path)) |
732 end; |
733 end; |
733 |
734 |
|
735 (*Determine if absolute path1 is a subdirectory of absolute path2*) |
|
736 fun path1 subdir_of path2 = |
|
737 if hd (explode path1) <> "/" orelse hd (explode path2) <> "/" then |
|
738 error "Relative or empty path passed to subdir_of" |
|
739 else (space_explode "/" path2) prefix (space_explode "/" path1); |
|
740 |
734 |
741 |
735 (** misc functions **) |
742 (** misc functions **) |
736 |
743 |
737 (*use the keyfun to make a list of (x, key) pairs*) |
744 (*use the keyfun to make a list of (x, key) pairs*) |
738 fun make_keylist (keyfun: 'a->'b) : 'a list -> ('a * 'b) list = |
745 fun make_keylist (keyfun: 'a->'b) : 'a list -> ('a * 'b) list = |