1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 19:38:12 +00:00

WebServer: Sort entries in directory listing

This commit is contained in:
Max Wipfli 2021-06-07 16:53:40 +02:00 committed by Andreas Kling
parent 2c5a8462ec
commit 977b3509f2

View file

@ -11,6 +11,7 @@
#include <AK/LexicalPath.h>
#include <AK/MappedFile.h>
#include <AK/MemoryStream.h>
#include <AK/QuickSort.h>
#include <AK/StringBuilder.h>
#include <AK/URL.h>
#include <LibCore/DateTime.h>
@ -211,9 +212,12 @@ void Client::handle_directory_listing(String const& requested_path, String const
builder.append("<code><table>\n");
Core::DirIterator dt(real_path);
while (dt.has_next()) {
auto name = dt.next_path();
Vector<String> names;
while (dt.has_next())
names.append(dt.next_path());
quick_sort(names);
for (auto& name : names) {
StringBuilder path_builder;
path_builder.append(real_path);
path_builder.append('/');