Skip to content

Commit 48a2d39

Browse files
committed
feat(bin): count number of hidden files
1 parent 6ddc38a commit 48a2d39

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

src/bin/http_of_dir.ml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,16 @@ let html_list_dir ~top ~parent d : string =
5959
Printf.bprintf body "<a href=\"/%s\"> (parent directory) </a>\n" p;
6060
end;
6161
Printf.bprintf body "<ul>\n";
62+
let hidden_stop = ref 0 in
6263
Array.iteri
6364
(fun i f ->
6465
if is_hidden f && (i=0 || not (is_hidden entries.(i-1))) then (
65-
Printf.bprintf body "<details> <summary>(hidden files)</summary>\n";
66-
) else if not (is_hidden f) && i>0 && is_hidden entries.(i-1) then (
66+
hidden_stop := i;
67+
while !hidden_stop < Array.length entries && is_hidden entries.(!hidden_stop) do
68+
incr hidden_stop;
69+
done;
70+
Printf.bprintf body "<details> <summary>(%d hidden files)</summary>\n" (!hidden_stop-i);
71+
) else if i = !hidden_stop then (
6772
Printf.bprintf body "</details/>\n";
6873
);
6974
if not @@ contains_dot_dot (d // f) then (

0 commit comments

Comments
 (0)