mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-05 19:00:32 -05:00
feat(bin): count number of hidden files
This commit is contained in:
parent
6ddc38a7c1
commit
48a2d3980b
1 changed files with 7 additions and 2 deletions
|
|
@ -59,11 +59,16 @@ let html_list_dir ~top ~parent d : string =
|
|||
Printf.bprintf body "<a href=\"/%s\"> (parent directory) </a>\n" p;
|
||||
end;
|
||||
Printf.bprintf body "<ul>\n";
|
||||
let hidden_stop = ref 0 in
|
||||
Array.iteri
|
||||
(fun i f ->
|
||||
if is_hidden f && (i=0 || not (is_hidden entries.(i-1))) then (
|
||||
Printf.bprintf body "<details> <summary>(hidden files)</summary>\n";
|
||||
) else if not (is_hidden f) && i>0 && is_hidden entries.(i-1) then (
|
||||
hidden_stop := i;
|
||||
while !hidden_stop < Array.length entries && is_hidden entries.(!hidden_stop) do
|
||||
incr hidden_stop;
|
||||
done;
|
||||
Printf.bprintf body "<details> <summary>(%d hidden files)</summary>\n" (!hidden_stop-i);
|
||||
) else if i = !hidden_stop then (
|
||||
Printf.bprintf body "</details/>\n";
|
||||
);
|
||||
if not @@ contains_dot_dot (d // f) then (
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue