mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-07 03:35:34 -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;
|
Printf.bprintf body "<a href=\"/%s\"> (parent directory) </a>\n" p;
|
||||||
end;
|
end;
|
||||||
Printf.bprintf body "<ul>\n";
|
Printf.bprintf body "<ul>\n";
|
||||||
|
let hidden_stop = ref 0 in
|
||||||
Array.iteri
|
Array.iteri
|
||||||
(fun i f ->
|
(fun i f ->
|
||||||
if is_hidden f && (i=0 || not (is_hidden entries.(i-1))) then (
|
if is_hidden f && (i=0 || not (is_hidden entries.(i-1))) then (
|
||||||
Printf.bprintf body "<details> <summary>(hidden files)</summary>\n";
|
hidden_stop := i;
|
||||||
) else if not (is_hidden f) && i>0 && is_hidden entries.(i-1) then (
|
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";
|
Printf.bprintf body "</details/>\n";
|
||||||
);
|
);
|
||||||
if not @@ contains_dot_dot (d // f) then (
|
if not @@ contains_dot_dot (d // f) then (
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue