mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-06 11:09:05 +03:00
LibWeb: Use human-readable sizes on directory listing
A size is also no longer displayed for directories.
This commit is contained in:
parent
19dfdeeaec
commit
cbf39dfddd
Notes:
sideshowbarker
2024-07-17 03:03:44 +09:00
Author: https://github.com/tcl3 Commit: https://github.com/SerenityOS/serenity/commit/cbf39dfddd Pull-request: https://github.com/SerenityOS/serenity/pull/21096 Reviewed-by: https://github.com/ADKaster ✅
@ -4,6 +4,7 @@
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/NumberFormat.h>
|
||||
#include <AK/QuickSort.h>
|
||||
#include <AK/SourceGenerator.h>
|
||||
#include <LibCore/DateTime.h>
|
||||
@ -31,10 +32,12 @@ ErrorOr<DeprecatedString> load_file_directory_page(LoadRequest const& request)
|
||||
auto maybe_st = Core::System::stat(path.string());
|
||||
if (!maybe_st.is_error()) {
|
||||
auto st = maybe_st.release_value();
|
||||
auto is_directory = S_ISDIR(st.st_mode);
|
||||
|
||||
contents.append("<tr>"sv);
|
||||
contents.appendff("<td><span class=\"{}\"></span></td>", S_ISDIR(st.st_mode) ? "folder" : "file");
|
||||
contents.appendff("<td><span class=\"{}\"></span></td>", is_directory ? "folder" : "file");
|
||||
contents.appendff("<td><a href=\"file://{}\">{}</a></td><td> </td>"sv, path, name);
|
||||
contents.appendff("<td>{:10}</td><td> </td>", st.st_size);
|
||||
contents.appendff("<td>{:10}</td><td> </td>", is_directory ? "-" : human_readable_size(st.st_size));
|
||||
contents.appendff("<td>{}</td>"sv, Core::DateTime::from_timestamp(st.st_mtime).to_deprecated_string());
|
||||
contents.append("</tr>\n"sv);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user