diff options
| author | Tristan Riehs <tristan.riehs@inria.fr> | 2025-12-28 23:26:50 +0100 |
|---|---|---|
| committer | Tristan Riehs <tristan.riehs@inria.fr> | 2025-12-28 23:26:50 +0100 |
| commit | 3c0115f2147d194b13a327b5e93d30cfdb7dfd4e (patch) | |
| tree | 7868d6c1fbfe6bcc68f8877928997f818cd2816b | |
| parent | ed83187039a1302bc1588d8fbaeccd0638b7bae7 (diff) | |
Delete OCaml script
That was a lot of fun but the file sum thing makes using C and find(1)
make much more sense in my opinion.
| -rw-r--r-- | ocaml/ftag-add-dir-rec.ml | 63 |
1 files changed, 0 insertions, 63 deletions
diff --git a/ocaml/ftag-add-dir-rec.ml b/ocaml/ftag-add-dir-rec.ml deleted file mode 100644 index 3a325b6..0000000 --- a/ocaml/ftag-add-dir-rec.ml +++ /dev/null @@ -1,63 +0,0 @@ -#load "unix.cma";; - -let list_dir_rec dir = - let rec list_dir_rec_intern handle prefix acc = - try - let next = Unix.readdir handle in - let next_expanded = Filename.concat prefix next in - if Sys.is_regular_file next_expanded then - list_dir_rec_intern handle prefix (next_expanded :: acc) - else if Sys.is_directory next_expanded && next = "." && next = ".." then - let new_acc = list_dir_rec_intern (Unix.opendir next_expanded) next_expanded acc in - list_dir_rec_intern handle prefix new_acc - else - list_dir_rec_intern handle prefix acc - with End_of_file -> Unix.closedir handle; acc - in list_dir_rec_intern (Unix.opendir dir) dir [];; - -let basename_equal file0 file1 = - String.equal (Filename.basename file0) (Filename.basename file1);; - -(* Check whether a file with the same basename as FILE exists in FILE_LIST. *) -let rec basename_equal_in file file_list = - match file_list with - | head :: tail -> if basename_equal file head - then true - else basename_equal_in file tail - | [] -> false;; - -let remove_duplicates list = - let rec remove_duplicates_intern list acc = - match list with - | head :: tail -> if basename_equal_in head tail - then remove_duplicates_intern tail acc - else remove_duplicates_intern tail (head :: acc) - | [] -> acc - in remove_duplicates_intern list [];; - -let prompt_yes_or_no () = - print_endline " [Y/n]"; - let input = try read_line () with End_of_file -> "N" in - if String.starts_with "N" input || String.starts_with "n" input - then false - else true;; - -let ftag_add file = - Filename.quote_command "ftag" ["file"; "add"; file] - |> Unix.system - |> ignore;; - -let rec prompt_and_add file = - Printf.printf "Add \"%s\" to ftag database ?" file; - if prompt_yes_or_no () - then ftag_add file;; - -print_endline "===start==="; - -Array.to_list Sys.argv -(* |> List.map print_endline *) -|> List.tl -|> List.map list_dir_rec -|> List.flatten -|> remove_duplicates -|> List.map prompt_and_add;; |
