+ eprintf "Time : %f seconds\n%!" (t1 -. t0);
+ eprintf "Considered : %d\n%!" !(count.considered);
+ eprintf "Hashed : %d\n%!" !(count.hashed);
+ eprintf "Skipped due to 0 size : %d\n%!" !(count.empty);
+ eprintf "Skipped due to unique size : %d\n%!" !(count.unique_size);
+ eprintf "Skipped due to unique sample : %d\n%!" !(count.unique_sample);
+ eprintf "Ignored due to regex match : %d\n%!" !(count.ignored)
+
+let get_opt () : opt =
+ let assert_ test x msg =
+ if not (test x) then begin
+ eprintf "%s\n%!" msg;
+ exit 1
+ end
+ in
+ let assert_file_exists path =
+ assert_ Sys.file_exists path (sprintf "File does not exist: %S" path)
+ in
+ let assert_file_is_dir path =
+ assert_ Sys.is_directory path (sprintf "File is not a directory: %S" path)
+ in
+ let input = ref Stdin in
+ let output = ref Stdout in
+ let ignore = ref None in
+ let sample = ref 256 in
+ let spec =
+ [ ( "-out"
+ , Arg.String (fun path ->
+ assert_file_exists path;
+ assert_file_is_dir path;
+ output := Directory path
+ )
+ , " Output to this directory instead of stdout."
+ )
+ ; ( "-ignore"
+ , Arg.String (fun regexp -> ignore := Some (Str.regexp regexp))
+ , " Ignore file paths which match this regexp pattern (see Str module)."
+ )
+ ; ( "-sample"
+ , Arg.Set_int sample
+ , (sprintf " Byte size of file samples to use. Default: %d" !sample)
+ )
+ ]
+ in
+ Arg.parse
+ (Arg.align spec)
+ (fun path ->
+ assert_file_exists path;
+ assert_file_is_dir path;
+ match !input with
+ | Stdin ->
+ input := Directories [path]
+ | Directories paths ->
+ input := Directories (path :: paths)
+ )
+ "";
+ assert_
+ (fun x -> x > 0)
+ !sample
+ (sprintf "Sample size cannot be negative: %d" !sample);
+ { input = !input
+ ; output = !output
+ ; ignore = !ignore
+ ; sample = !sample
+ }