this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 24 lines 772 B view raw
1let nproc () = 2 let ic = Unix.open_process_in "nproc" in 3 let n = In_channel.input_line ic |> Option.get |> String.trim |> int_of_string in 4 ignore (Unix.close_process_in ic); 5 n 6 7let dir_size path = 8 let rec walk acc dir = 9 let entries = Bos.OS.Dir.contents dir |> Result.get_ok in 10 List.fold_left 11 (fun acc entry -> 12 let stat = Unix.lstat (Fpath.to_string entry) in 13 match stat.Unix.st_kind with 14 | Unix.S_DIR -> walk acc entry 15 | Unix.S_REG -> acc + stat.Unix.st_size 16 | _ -> acc) 17 acc entries 18 in 19 try Ok (walk 0 path) 20 with 21 | Unix.Unix_error (e, fn, arg) -> 22 Rresult.R.error_msgf "%s(%s): %s" fn arg (Unix.error_message e) 23 | exn -> 24 Rresult.R.error_msgf "dir_size: %s" (Printexc.to_string exn)