1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-08-02 20:37:35 +00:00

Everywhere: Add sv suffix to strings relying on StringView(char const*)

Each of these strings would previously rely on StringView's char const*
constructor overload, which would call __builtin_strlen on the string.
Since we now have operator ""sv, we can replace these with much simpler
versions. This opens the door to being able to remove
StringView(char const*).

No functional changes.
This commit is contained in:
sin-ack 2022-07-11 17:32:29 +00:00 committed by Andreas Kling
parent e5f09ea170
commit 3f3f45580a
762 changed files with 8315 additions and 8316 deletions

View file

@ -28,7 +28,7 @@ Mixer::Mixer(NonnullRefPtr<Core::ConfigFile> config)
mix();
return 0;
},
"AudioServer[mixer]"))
"AudioServer[mixer]"sv))
, m_config(move(config))
{
if (!m_device->open(Core::OpenMode::WriteOnly)) {

View file

@ -16,7 +16,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
TRY(Core::System::pledge("stdio recvfd thread accept cpath rpath wpath unix"));
auto config = TRY(Core::ConfigFile::open_for_app("Audio", Core::ConfigFile::AllowWriting::Yes));
TRY(Core::System::unveil(config->filename(), "rwc"));
TRY(Core::System::unveil(config->filename(), "rwc"sv));
TRY(Core::System::unveil("/dev/audio", "wc"));
TRY(Core::System::unveil(nullptr, nullptr));

View file

@ -13,8 +13,8 @@ using namespace Chess::UCI;
void ChessEngine::handle_uci()
{
send_command(IdCommand(IdCommand::Type::Name, "ChessEngine"));
send_command(IdCommand(IdCommand::Type::Author, "the SerenityOS developers"));
send_command(IdCommand(IdCommand::Type::Name, "ChessEngine"sv));
send_command(IdCommand(IdCommand::Type::Author, "the SerenityOS developers"sv));
send_command(UCIOkCommand());
}

View file

@ -13,8 +13,8 @@
ErrorOr<int> serenity_main(Main::Arguments)
{
TRY(Core::System::pledge("stdio accept rpath wpath cpath"));
TRY(Core::System::unveil(Core::StandardPaths::config_directory(), "rwc"));
TRY(Core::System::unveil(Core::StandardPaths::home_directory(), "rwc"));
TRY(Core::System::unveil(Core::StandardPaths::config_directory(), "rwc"sv));
TRY(Core::System::unveil(Core::StandardPaths::home_directory(), "rwc"sv));
TRY(Core::System::unveil(nullptr, nullptr));
Core::EventLoop event_loop;

View file

@ -34,7 +34,7 @@ static void wait_until_coredump_is_ready(String const& coredump_path)
static void launch_crash_reporter(String const& coredump_path, bool unlink_on_exit)
{
auto pid = Core::Process::spawn("/bin/CrashReporter",
auto pid = Core::Process::spawn("/bin/CrashReporter"sv,
unlink_on_exit
? Array { "--unlink", coredump_path.characters() }.span()
: Array { coredump_path.characters() }.span());

View file

@ -153,9 +153,9 @@ struct ParsedDHCPv4Options {
String to_string() const
{
StringBuilder builder;
builder.append("DHCP Options (");
builder.append("DHCP Options ("sv);
builder.appendff("{}", options.size());
builder.append(" entries)\n");
builder.append(" entries)\n"sv);
for (auto& opt : options) {
builder.appendff("\toption {} ({} bytes):", (u8)opt.key, (u8)opt.value.length);
for (auto i = 0; i < opt.value.length; ++i)

View file

@ -191,13 +191,13 @@ ErrorOr<DHCPv4Client::Interfaces> DHCPv4Client::get_discoverable_interfaces()
json.value().as_array().for_each([&ifnames_to_immediately_discover, &ifnames_to_attempt_later](auto& value) {
auto if_object = value.as_object();
if (if_object.get("class_name").to_string() == "LoopbackAdapter")
if (if_object.get("class_name"sv).to_string() == "LoopbackAdapter")
return;
auto name = if_object.get("name").to_string();
auto mac = if_object.get("mac_address").to_string();
auto is_up = if_object.get("link_up").to_bool();
auto ipv4_addr_maybe = IPv4Address::from_string(if_object.get("ipv4_address").to_string());
auto name = if_object.get("name"sv).to_string();
auto mac = if_object.get("mac_address"sv).to_string();
auto is_up = if_object.get("link_up"sv).to_bool();
auto ipv4_addr_maybe = IPv4Address::from_string(if_object.get("ipv4_address"sv).to_string());
auto ipv4_addr = ipv4_addr_maybe.has_value() ? ipv4_addr_maybe.value() : IPv4Address { 0, 0, 0, 0 };
if (is_up) {
dbgln_if(DHCPV4_DEBUG, "Found adapter '{}' with mac {}, and it was up!", name, mac);

View file

@ -263,7 +263,7 @@ ErrorOr<int> execute_work_items(Vector<WorkItem> const& items)
outln("MKDIR {}", item.destination);
// FIXME: Support deduplication like open_destination_file() when the directory already exists.
if (mkdir(item.destination.characters(), 0755) < 0 && errno != EEXIST)
return Error::from_syscall("mkdir", -errno);
return Error::from_syscall("mkdir"sv, -errno);
break;
}

View file

@ -69,14 +69,14 @@ void ConnectionFromClient::request_file_handler(i32 request_id, i32 window_serve
access_string = "write to";
auto pid = this->socket().peer_pid().release_value_but_fixme_should_propagate_errors();
auto exe_link = LexicalPath("/proc").append(String::number(pid)).append("exe").string();
auto exe_link = LexicalPath("/proc").append(String::number(pid)).append("exe"sv).string();
auto exe_path = Core::File::real_path_for(exe_link);
auto main_window = create_dummy_child_window(window_server_client_id, parent_window_id);
if (prompt == ShouldPrompt::Yes) {
auto exe_name = LexicalPath::basename(exe_path);
auto result = GUI::MessageBox::show(main_window, String::formatted("Allow {} ({}) to {} \"{}\"?", exe_name, pid, access_string, path), "File Permissions Requested", GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNo);
auto result = GUI::MessageBox::show(main_window, String::formatted("Allow {} ({}) to {} \"{}\"?", exe_name, pid, access_string, path), "File Permissions Requested"sv, GUI::MessageBox::Type::Warning, GUI::MessageBox::InputType::YesNo);
approved = result == GUI::MessageBox::ExecResult::Yes;
} else {
approved = true;

View file

@ -47,17 +47,17 @@ String Handler::to_details_str() const
{
StringBuilder builder;
auto obj = MUST(JsonObjectSerializer<>::try_create(builder));
MUST(obj.add("executable", executable));
MUST(obj.add("name", name));
MUST(obj.add("executable"sv, executable));
MUST(obj.add("name"sv, name));
switch (handler_type) {
case Type::Application:
MUST(obj.add("type", "app"));
MUST(obj.add("type"sv, "app"));
break;
case Type::UserDefault:
MUST(obj.add("type", "userdefault"));
MUST(obj.add("type"sv, "userdefault"));
break;
case Type::UserPreferred:
MUST(obj.add("type", "userpreferred"));
MUST(obj.add("type"sv, "userpreferred"));
break;
default:
break;

View file

@ -18,12 +18,12 @@ LoginWindow::LoginWindow(GUI::Window* parent)
set_resizable(false);
set_minimizable(false);
set_closeable(false);
set_icon(GUI::Icon::default_icon("ladyball").bitmap_for_size(16));
set_icon(GUI::Icon::default_icon("ladyball"sv).bitmap_for_size(16));
auto& widget = set_main_widget<GUI::Widget>();
widget.load_from_gml(login_window_gml);
m_banner = *widget.find_descendant_of_type_named<GUI::ImageWidget>("banner");
m_banner->load_from_file("/res/graphics/brand-banner.png");
m_banner->load_from_file("/res/graphics/brand-banner.png"sv);
m_banner->set_auto_resize(true);
m_username = *widget.find_descendant_of_type_named<GUI::TextBox>("username");

View file

@ -70,9 +70,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto username = window->username();
auto password = Core::SecretString::take_ownership(window->password().to_byte_buffer());
window->set_password("");
window->set_password(""sv);
auto fail_message = "Can't log in: invalid username or password.";
auto fail_message = "Can't log in: invalid username or password."sv;
auto account = Core::Account::from_name(username.characters());
if (account.is_error()) {
@ -87,7 +87,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return;
}
window->set_username("");
window->set_username(""sv);
window->hide();
login(account.value(), *window);

View file

@ -95,7 +95,7 @@ void LookupServer::load_etc_hosts()
if (original_line.is_empty())
break;
auto trimmed_line = original_line.view().trim_whitespace();
auto replaced_line = trimmed_line.replace(" ", "\t", ReplaceMode::All);
auto replaced_line = trimmed_line.replace(" "sv, "\t"sv, ReplaceMode::All);
auto fields = replaced_line.split_view('\t', false);
if (fields.size() < 2) {
@ -119,7 +119,7 @@ void LookupServer::load_etc_hosts()
StringBuilder builder;
builder.append(maybe_address->to_string_reversed());
builder.append(".in-addr.arpa");
builder.append(".in-addr.arpa"sv);
add_answer(builder.to_string(), RecordType::PTR, name.as_string());
}
}
@ -182,7 +182,7 @@ ErrorOr<Vector<Answer>> LookupServer::lookup(Name const& name, RecordType record
}
// Fourth, look up .local names using mDNS instead of DNS nameservers.
if (name.as_string().ends_with(".local")) {
if (name.as_string().ends_with(".local"sv)) {
answers = m_mdns->lookup(name, record_type);
for (auto& answer : answers)
put_in_cache(answer);

View file

@ -127,7 +127,7 @@ Vector<IPv4Address> MulticastDNS::local_addresses() const
json.as_array().for_each([&addresses](auto& value) {
auto if_object = value.as_object();
auto address = if_object.get("ipv4_address").to_string();
auto address = if_object.get("ipv4_address"sv).to_string();
auto ipv4_address = IPv4Address::from_string(address);
// Skip unconfigured interfaces.
if (!ipv4_address.has_value())

View file

@ -48,7 +48,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
Vector<String> interfaces_with_dhcp_enabled;
proc_net_adapters_json.as_array().for_each([&](auto& value) {
auto& if_object = value.as_object();
auto ifname = if_object.get("name").to_string();
auto ifname = if_object.get("name"sv).to_string();
if (ifname == "loop")
return;
@ -73,10 +73,10 @@ ErrorOr<int> serenity_main(Main::Arguments)
// FIXME: Propagate errors
// FIXME: Do this asynchronously
dbgln("Setting up interface {} statically ({}/{})", ifname, config.ipv4_address, config.ipv4_netmask);
MUST(Core::command("ifconfig", { "-a", ifname.characters(), "-i", config.ipv4_address.characters(), "-m", config.ipv4_netmask.characters() }, {}));
MUST(Core::command("ifconfig"sv, { "-a", ifname.characters(), "-i", config.ipv4_address.characters(), "-m", config.ipv4_netmask.characters() }, {}));
if (config.ipv4_gateway != "0.0.0.0") {
MUST(Core::command("route", { "del", "-n", "0.0.0.0", "-m", "0.0.0.0", "-i", ifname }, {}));
MUST(Core::command("route", { "add", "-n", "0.0.0.0", "-m", "0.0.0.0", "-g", config.ipv4_gateway, "-i", ifname }, {}));
MUST(Core::command("route"sv, { "del", "-n", "0.0.0.0", "-m", "0.0.0.0", "-i", ifname }, {}));
MUST(Core::command("route"sv, { "add", "-n", "0.0.0.0", "-m", "0.0.0.0", "-g", config.ipv4_gateway, "-i", ifname }, {}));
}
}
}
@ -90,7 +90,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
args.append(const_cast<char*>(iface.characters()));
args.append(nullptr);
MUST(Core::command("killall", { "DHCPClient" }, {}));
auto dhcp_client_pid = TRY(Core::System::posix_spawnp("DHCPClient", nullptr, nullptr, args.data(), environ));
auto dhcp_client_pid = TRY(Core::System::posix_spawnp("DHCPClient"sv, nullptr, nullptr, args.data(), environ));
TRY(Core::System::disown(dhcp_client_pid));
}
return 0;

View file

@ -71,21 +71,21 @@ OwnPtr<Request> start_request(TBadgedProtocol&& protocol, ConnectionFromClient&
}
HTTP::HttpRequest request;
if (method.equals_ignoring_case("post"))
if (method.equals_ignoring_case("post"sv))
request.set_method(HTTP::HttpRequest::Method::POST);
else if (method.equals_ignoring_case("head"))
else if (method.equals_ignoring_case("head"sv))
request.set_method(HTTP::HttpRequest::Method::HEAD);
else if (method.equals_ignoring_case("delete"))
else if (method.equals_ignoring_case("delete"sv))
request.set_method(HTTP::HttpRequest::Method::DELETE);
else if (method.equals_ignoring_case("patch"))
else if (method.equals_ignoring_case("patch"sv))
request.set_method(HTTP::HttpRequest::Method::PATCH);
else if (method.equals_ignoring_case("options"))
else if (method.equals_ignoring_case("options"sv))
request.set_method(HTTP::HttpRequest::Method::OPTIONS);
else if (method.equals_ignoring_case("trace"))
else if (method.equals_ignoring_case("trace"sv))
request.set_method(HTTP::HttpRequest::Method::TRACE);
else if (method.equals_ignoring_case("connect"))
else if (method.equals_ignoring_case("connect"sv))
request.set_method(HTTP::HttpRequest::Method::CONNECT);
else if (method.equals_ignoring_case("put"))
else if (method.equals_ignoring_case("put"sv))
request.set_method(HTTP::HttpRequest::Method::PUT);
else
request.set_method(HTTP::HttpRequest::Method::GET);

View file

@ -17,7 +17,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
Core::EventLoop loop;
TRY(Core::System::pledge("unix rpath wpath stdio sendfd recvfd"));
TRY(Core::System::unveil(SPICE_DEVICE, "rw"));
TRY(Core::System::unveil(SPICE_DEVICE, "rw"sv));
TRY(Core::System::unveil("/tmp/portal/clipboard", "rw"));
TRY(Core::System::unveil(nullptr, nullptr));

View file

@ -411,7 +411,7 @@ ErrorOr<void> Service::determine_account(int fd)
TRY(Core::System::getsockopt(fd, SOL_SOCKET, SO_PEERCRED, &creds, &creds_size));
auto const directory_name = String::formatted("/proc/{}/", creds.pid);
auto const stat = TRY(Core::System::stat(directory_name.characters()));
auto const stat = TRY(Core::System::stat(directory_name));
m_account = TRY(Core::Account::from_uid(stat.st_uid));
return {};

View file

@ -95,7 +95,7 @@ static ErrorOr<void> chown_all_matching_device_nodes_under_specific_directory(St
auto rc = stat(entry_name.characters(), &cur_file_stat);
if (rc < 0)
continue;
TRY(Core::System::chown(entry_name.characters(), 0, group.gr_gid));
TRY(Core::System::chown(entry_name, 0, group.gr_gid));
}
return {};
}
@ -114,7 +114,7 @@ static ErrorOr<void> chown_all_matching_device_nodes(group const& group, unsigne
continue;
if (major(cur_file_stat.st_rdev) != major_number)
continue;
TRY(Core::System::chown(entry_name.characters(), 0, group.gr_gid));
TRY(Core::System::chown(entry_name, 0, group.gr_gid));
}
return {};
}
@ -370,35 +370,35 @@ static void populate_devtmpfs()
static ErrorOr<void> prepare_synthetic_filesystems()
{
// FIXME: Find a better way to all of this stuff, without hardcoding all of this!
TRY(Core::System::mount(-1, "/proc", "proc", MS_NOSUID));
TRY(Core::System::mount(-1, "/sys", "sys", 0));
TRY(Core::System::mount(-1, "/dev", "dev", 0));
TRY(Core::System::mount(-1, "/proc"sv, "proc"sv, MS_NOSUID));
TRY(Core::System::mount(-1, "/sys"sv, "sys"sv, 0));
TRY(Core::System::mount(-1, "/dev"sv, "dev"sv, 0));
TRY(Core::System::mkdir("/dev/audio", 0755));
TRY(Core::System::mkdir("/dev/audio"sv, 0755));
TRY(Core::System::symlink("/proc/self/fd/0", "/dev/stdin"));
TRY(Core::System::symlink("/proc/self/fd/1", "/dev/stdout"));
TRY(Core::System::symlink("/proc/self/fd/2", "/dev/stderr"));
TRY(Core::System::symlink("/proc/self/fd/0"sv, "/dev/stdin"sv));
TRY(Core::System::symlink("/proc/self/fd/1"sv, "/dev/stdout"sv));
TRY(Core::System::symlink("/proc/self/fd/2"sv, "/dev/stderr"sv));
TRY(Core::System::mkdir("/dev/gpu", 0755));
TRY(Core::System::mkdir("/dev/gpu"sv, 0755));
populate_devtmpfs();
TRY(Core::System::mkdir("/dev/pts", 0755));
TRY(Core::System::mkdir("/dev/pts"sv, 0755));
TRY(Core::System::mount(-1, "/dev/pts", "devpts", 0));
TRY(Core::System::mount(-1, "/dev/pts"sv, "devpts"sv, 0));
TRY(Core::System::symlink("/dev/random", "/dev/urandom"));
TRY(Core::System::symlink("/dev/random"sv, "/dev/urandom"sv));
TRY(Core::System::chmod("/dev/urandom", 0666));
TRY(Core::System::chmod("/dev/urandom"sv, 0666));
auto phys_group = TRY(Core::System::getgrnam("phys"));
auto phys_group = TRY(Core::System::getgrnam("phys"sv));
VERIFY(phys_group.has_value());
// FIXME: Try to find a way to not hardcode the major number of framebuffer device nodes.
TRY(chown_all_matching_device_nodes(phys_group.value(), 29));
auto const filter_chown_ENOENT = [](ErrorOr<void> result) -> ErrorOr<void> {
auto const chown_enoent = Error::from_syscall("chown", -ENOENT);
auto const chown_enoent = Error::from_syscall("chown"sv, -ENOENT);
if (result.is_error() && result.error() == chown_enoent) {
dbgln("{}", result.release_error());
return {};
@ -406,18 +406,18 @@ static ErrorOr<void> prepare_synthetic_filesystems()
return result;
};
TRY(filter_chown_ENOENT(Core::System::chown("/dev/keyboard0", 0, phys_group.value().gr_gid)));
TRY(filter_chown_ENOENT(Core::System::chown("/dev/mouse0", 0, phys_group.value().gr_gid)));
TRY(filter_chown_ENOENT(Core::System::chown("/dev/keyboard0"sv, 0, phys_group.value().gr_gid)));
TRY(filter_chown_ENOENT(Core::System::chown("/dev/mouse0"sv, 0, phys_group.value().gr_gid)));
auto tty_group = TRY(Core::System::getgrnam("tty"));
auto tty_group = TRY(Core::System::getgrnam("tty"sv));
VERIFY(tty_group.has_value());
// FIXME: Try to find a way to not hardcode the major number of tty nodes.
TRY(chown_all_matching_device_nodes(tty_group.release_value(), 4));
auto audio_group = TRY(Core::System::getgrnam("audio"));
auto audio_group = TRY(Core::System::getgrnam("audio"sv));
VERIFY(audio_group.has_value());
TRY(Core::System::chown("/dev/audio", 0, audio_group->gr_gid));
TRY(chown_all_matching_device_nodes_under_specific_directory("/dev/audio", audio_group.release_value()));
TRY(Core::System::chown("/dev/audio"sv, 0, audio_group->gr_gid));
TRY(chown_all_matching_device_nodes_under_specific_directory("/dev/audio"sv, audio_group.release_value()));
// Note: We open the /dev/null device and set file descriptors 0, 1, 2 to it
// because otherwise these file descriptors won't have a custody, making
@ -426,7 +426,7 @@ static ErrorOr<void> prepare_synthetic_filesystems()
// This affects also every other process that inherits the file descriptors
// from SystemServer, so it is important for other things (also for ProcFS
// tests that are running in CI mode).
int stdin_new_fd = TRY(Core::System::open("/dev/null", O_NONBLOCK));
int stdin_new_fd = TRY(Core::System::open("/dev/null"sv, O_NONBLOCK));
TRY(Core::System::dup2(stdin_new_fd, 0));
TRY(Core::System::dup2(stdin_new_fd, 1));
@ -442,7 +442,7 @@ static ErrorOr<void> mount_all_filesystems()
pid_t pid = TRY(Core::System::fork());
if (pid == 0)
TRY(Core::System::exec("/bin/mount", Vector<StringView> { "mount", "-a" }, Core::System::SearchInPath::No));
TRY(Core::System::exec("/bin/mount"sv, Vector { "mount"sv, "-a"sv }, Core::System::SearchInPath::No));
wait(nullptr);
return {};
@ -453,7 +453,7 @@ static ErrorOr<void> create_tmp_coredump_directory()
dbgln("Creating /tmp/coredump directory");
auto old_umask = umask(0);
// FIXME: the coredump directory should be made read-only once CrashDaemon is no longer responsible for compressing coredumps
TRY(Core::System::mkdir("/tmp/coredump", 0777));
TRY(Core::System::mkdir("/tmp/coredump"sv, 0777));
umask(old_umask);
return {};
}

View file

@ -21,7 +21,7 @@ ClockWidget::ClockWidget()
set_frame_shadow(Gfx::FrameShadow::Sunken);
set_frame_thickness(1);
update_format(Config::read_string("Taskbar", "Clock", "TimeFormat", "%T"));
update_format(Config::read_string("Taskbar"sv, "Clock"sv, "TimeFormat"sv, "%T"sv));
m_timer = add<Core::Timer>(1000, [this] {
static time_t last_update_time;
@ -29,7 +29,7 @@ ClockWidget::ClockWidget()
if (now != last_update_time) {
tick_clock();
last_update_time = now;
set_tooltip(Core::DateTime::now().to_string("%Y-%m-%d"));
set_tooltip(Core::DateTime::now().to_string("%Y-%m-%d"sv));
}
});
@ -58,7 +58,7 @@ ClockWidget::ClockWidget()
m_prev_date = navigation_container.add<GUI::Button>();
m_prev_date->set_button_style(Gfx::ButtonStyle::Coolbar);
m_prev_date->set_fixed_size(24, 24);
m_prev_date->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png").release_value_but_fixme_should_propagate_errors());
m_prev_date->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-back.png"sv).release_value_but_fixme_should_propagate_errors());
m_prev_date->on_click = [&](auto) {
unsigned view_month = m_calendar->view_month();
unsigned view_year = m_calendar->view_year();
@ -92,7 +92,7 @@ ClockWidget::ClockWidget()
m_next_date = navigation_container.add<GUI::Button>();
m_next_date->set_button_style(Gfx::ButtonStyle::Coolbar);
m_next_date->set_fixed_size(24, 24);
m_next_date->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png").release_value_but_fixme_should_propagate_errors());
m_next_date->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/go-forward.png"sv).release_value_but_fixme_should_propagate_errors());
m_next_date->on_click = [&](auto) {
unsigned view_month = m_calendar->view_month();
unsigned view_year = m_calendar->view_year();
@ -142,7 +142,7 @@ ClockWidget::ClockWidget()
m_jump_to_button = settings_container.add<GUI::Button>();
m_jump_to_button->set_button_style(Gfx::ButtonStyle::Coolbar);
m_jump_to_button->set_fixed_size(24, 24);
m_jump_to_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/calendar-date.png").release_value_but_fixme_should_propagate_errors());
m_jump_to_button->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/calendar-date.png"sv).release_value_but_fixme_should_propagate_errors());
m_jump_to_button->set_tooltip("Jump to today");
m_jump_to_button->on_click = [this](auto) {
jump_to_current_date();
@ -151,10 +151,10 @@ ClockWidget::ClockWidget()
m_calendar_launcher = settings_container.add<GUI::Button>();
m_calendar_launcher->set_button_style(Gfx::ButtonStyle::Coolbar);
m_calendar_launcher->set_fixed_size(24, 24);
m_calendar_launcher->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-calendar.png").release_value_but_fixme_should_propagate_errors());
m_calendar_launcher->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-calendar.png"sv).release_value_but_fixme_should_propagate_errors());
m_calendar_launcher->set_tooltip("Calendar");
m_calendar_launcher->on_click = [this](auto) {
GUI::Process::spawn_or_show_error(window(), "/bin/Calendar");
GUI::Process::spawn_or_show_error(window(), "/bin/Calendar"sv);
};
}

View file

@ -92,7 +92,7 @@ QuickLaunchWidget::QuickLaunchWidget()
m_context_menu = GUI::Menu::construct();
m_context_menu_default_action = GUI::Action::create("&Remove", [this](auto&) {
Config::remove_key("Taskbar", quick_launch, m_context_menu_app_name);
Config::remove_key("Taskbar"sv, quick_launch, m_context_menu_app_name);
auto button = find_child_of_type_named<GUI::Button>(m_context_menu_app_name);
if (button) {
remove_child(*button);
@ -100,9 +100,9 @@ QuickLaunchWidget::QuickLaunchWidget()
});
m_context_menu->add_action(*m_context_menu_default_action);
auto keys = Config::list_keys("Taskbar", quick_launch);
auto keys = Config::list_keys("Taskbar"sv, quick_launch);
for (auto& name : keys) {
auto value = Config::read_string("Taskbar", quick_launch, name);
auto value = Config::read_string("Taskbar"sv, quick_launch, name);
auto entry = QuickLaunchEntry::create_from_config_value(value);
if (!entry)
continue;
@ -112,7 +112,7 @@ QuickLaunchWidget::QuickLaunchWidget()
OwnPtr<QuickLaunchEntry> QuickLaunchEntry::create_from_config_value(StringView value)
{
if (!value.starts_with("/") && value.ends_with(".af")) {
if (!value.starts_with("/") && value.ends_with(".af"sv)) {
auto af_path = String::formatted("{}/{}", Desktop::AppFile::APP_FILES_DIRECTORY, value);
return make<QuickLaunchEntryAppFile>(Desktop::AppFile::open(af_path));
}
@ -121,7 +121,7 @@ OwnPtr<QuickLaunchEntry> QuickLaunchEntry::create_from_config_value(StringView v
OwnPtr<QuickLaunchEntry> QuickLaunchEntry::create_from_path(StringView path)
{
if (path.ends_with(".af"))
if (path.ends_with(".af"sv))
return make<QuickLaunchEntryAppFile>(Desktop::AppFile::open(path));
auto stat_or_error = Core::System::stat(path);
if (stat_or_error.is_error()) {
@ -137,7 +137,7 @@ OwnPtr<QuickLaunchEntry> QuickLaunchEntry::create_from_path(StringView path)
static String sanitize_entry_name(String const& name)
{
return name.replace(" ", "", ReplaceMode::All).replace("=", "", ReplaceMode::All);
return name.replace(" "sv, ""sv, ReplaceMode::All).replace("="sv, ""sv, ReplaceMode::All);
}
void QuickLaunchWidget::add_or_adjust_button(String const& button_name, NonnullOwnPtr<QuickLaunchEntry>&& entry)
@ -212,7 +212,7 @@ void QuickLaunchWidget::drop_event(GUI::DropEvent& event)
if (entry) {
auto item_name = sanitize_entry_name(entry->name());
add_or_adjust_button(item_name, entry.release_nonnull());
Config::write_string("Taskbar", quick_launch, item_name, url.path());
Config::write_string("Taskbar"sv, quick_launch, item_name, url.path());
}
}
}

View file

@ -48,7 +48,7 @@ ShutdownDialog::ShutdownDialog()
widget.layout()->set_spacing(0);
auto& banner_image = widget.add<GUI::ImageWidget>();
banner_image.load_from_file("/res/graphics/brand-banner.png");
banner_image.load_from_file("/res/graphics/brand-banner.png"sv);
auto& content_container = widget.add<GUI::Widget>();
content_container.set_layout<GUI::HorizontalBoxLayout>();
@ -63,7 +63,7 @@ ShutdownDialog::ShutdownDialog()
icon_wrapper.set_layout<GUI::VerticalBoxLayout>();
auto& icon_image = icon_wrapper.add<GUI::ImageWidget>();
icon_image.set_bitmap(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/shutdown.png").release_value_but_fixme_should_propagate_errors());
icon_image.set_bitmap(Gfx::Bitmap::try_load_from_file("/res/icons/32x32/shutdown.png"sv).release_value_but_fixme_should_propagate_errors());
auto& right_container = content_container.add<GUI::Widget>();
right_container.set_layout<GUI::VerticalBoxLayout>();
@ -113,7 +113,7 @@ ShutdownDialog::ShutdownDialog()
center_on_screen();
set_resizable(false);
set_title("Exit SerenityOS");
set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/power.png").release_value_but_fixme_should_propagate_errors());
set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/power.png"sv).release_value_but_fixme_should_propagate_errors());
// Request WindowServer to re-update us on the current theme as we might've not been alive for the last notification.
refresh_system_theme();

View file

@ -67,7 +67,7 @@ TaskbarWindow::TaskbarWindow(NonnullRefPtr<GUI::Menu> start_menu)
m_start_button = GUI::Button::construct("Serenity");
set_start_button_font(Gfx::FontDatabase::default_font().bold_variant());
m_start_button->set_icon_spacing(0);
auto app_icon = GUI::Icon::default_icon("ladyball");
auto app_icon = GUI::Icon::default_icon("ladyball"sv);
m_start_button->set_icon(app_icon.bitmap_for_size(16));
m_start_button->set_menu(m_start_menu);
@ -78,7 +78,7 @@ TaskbarWindow::TaskbarWindow(NonnullRefPtr<GUI::Menu> start_menu)
m_task_button_container->set_layout<GUI::HorizontalBoxLayout>();
m_task_button_container->layout()->set_spacing(3);
m_default_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png").release_value_but_fixme_should_propagate_errors();
m_default_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window.png"sv).release_value_but_fixme_should_propagate_errors();
m_applet_area_container = main_widget.add<GUI::Frame>();
m_applet_area_container->set_frame_thickness(1);
@ -89,7 +89,7 @@ TaskbarWindow::TaskbarWindow(NonnullRefPtr<GUI::Menu> start_menu)
m_show_desktop_button = GUI::Button::construct();
m_show_desktop_button->set_tooltip("Show Desktop");
m_show_desktop_button->set_icon(GUI::Icon::default_icon("desktop").bitmap_for_size(16));
m_show_desktop_button->set_icon(GUI::Icon::default_icon("desktop"sv).bitmap_for_size(16));
m_show_desktop_button->set_button_style(Gfx::ButtonStyle::Coolbar);
m_show_desktop_button->set_fixed_size(24, 24);
m_show_desktop_button->on_click = TaskbarWindow::show_desktop_button_clicked;

View file

@ -123,7 +123,7 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(WindowRefence& window_ref)
Vector<String> const sorted_app_categories = TRY(discover_apps_and_categories());
auto system_menu = TRY(GUI::Menu::try_create("\xE2\x9A\xA1")); // HIGH VOLTAGE SIGN
system_menu->add_action(GUI::Action::create("&About SerenityOS", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/ladyball.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
system_menu->add_action(GUI::Action::create("&About SerenityOS", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/ladyball.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
GUI::Process::spawn_or_show_error(window_ref.get(), "/bin/About"sv);
}));
@ -221,7 +221,7 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(WindowRefence& window_ref)
g_themes_group.set_unchecking_allowed(false);
g_themes_menu = &system_menu->add_submenu("&Themes");
g_themes_menu->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/themes.png").release_value_but_fixme_should_propagate_errors());
g_themes_menu->set_icon(Gfx::Bitmap::try_load_from_file("/res/icons/16x16/themes.png"sv).release_value_but_fixme_should_propagate_errors());
g_themes = Gfx::list_installed_system_themes();
auto current_theme_name = GUI::ConnectionToWindowServer::the().get_system_theme();
@ -254,15 +254,15 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(WindowRefence& window_ref)
}
};
system_menu->add_action(GUI::Action::create("&Settings", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-settings.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
system_menu->add_action(GUI::Action::create("&Settings", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-settings.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
GUI::Process::spawn_or_show_error(window_ref.get(), "/bin/Settings"sv);
}));
system_menu->add_separator();
system_menu->add_action(GUI::Action::create("&Help", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png").release_value_but_fixme_should_propagate_errors(), [&](auto&) {
system_menu->add_action(GUI::Action::create("&Help", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-help.png"sv).release_value_but_fixme_should_propagate_errors(), [&](auto&) {
GUI::Process::spawn_or_show_error(window_ref.get(), "/bin/Help"sv);
}));
system_menu->add_action(GUI::Action::create("&Run...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-run.png").release_value_but_fixme_should_propagate_errors(), [](auto&) {
system_menu->add_action(GUI::Action::create("&Run...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/app-run.png"sv).release_value_but_fixme_should_propagate_errors(), [](auto&) {
posix_spawn_file_actions_t spawn_actions;
posix_spawn_file_actions_init(&spawn_actions);
auto home_directory = Core::StandardPaths::home_directory();
@ -280,7 +280,7 @@ ErrorOr<NonnullRefPtr<GUI::Menu>> build_system_menu(WindowRefence& window_ref)
posix_spawn_file_actions_destroy(&spawn_actions);
}));
system_menu->add_separator();
system_menu->add_action(GUI::Action::create("E&xit...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/power.png").release_value_but_fixme_should_propagate_errors(), [](auto&) {
system_menu->add_action(GUI::Action::create("E&xit...", Gfx::Bitmap::try_load_from_file("/res/icons/16x16/power.png"sv).release_value_but_fixme_should_propagate_errors(), [](auto&) {
auto command = ShutdownDialog::show();
if (command.size() == 0)

View file

@ -170,10 +170,10 @@ ErrorOr<void> Client::send_data(StringView data)
switch (c) {
case '\n':
builder.append("\r\n");
builder.append("\r\n"sv);
break;
case IAC:
builder.append("\xff\xff");
builder.append("\xff\xff"sv);
break;
default:
builder.append(c);

View file

@ -27,30 +27,30 @@ struct Command {
switch (command) {
case CMD_WILL:
builder.append("WILL");
builder.append("WILL"sv);
break;
case CMD_WONT:
builder.append("WONT");
builder.append("WONT"sv);
break;
case CMD_DO:
builder.append("DO");
builder.append("DO"sv);
break;
case CMD_DONT:
builder.append("DONT");
builder.append("DONT"sv);
break;
default:
builder.append(String::formatted("UNKNOWN<{:02x}>", command));
break;
}
builder.append(" ");
builder.append(" "sv);
switch (subcommand) {
case SUB_ECHO:
builder.append("ECHO");
builder.append("ECHO"sv);
break;
case SUB_SUPPRESS_GO_AHEAD:
builder.append("SUPPRESS_GO_AHEAD");
builder.append("SUPPRESS_GO_AHEAD"sv);
break;
default:
builder.append(String::formatted("UNKNOWN<{:02x}>", subcommand));

View file

@ -22,7 +22,7 @@ void Parser::write(StringView data)
break;
case '\r':
if (on_data)
on_data("\n");
on_data("\n"sv);
break;
case '\0':
case '\n':
@ -39,7 +39,7 @@ void Parser::write(StringView data)
case IAC: {
m_state = State::Free;
if (on_data)
on_data("\xff");
on_data("\xff"sv);
break;
}
case CMD_WILL:

View file

@ -321,24 +321,24 @@ Messages::WebContentServer::InspectDomNodeResponse ConnectionFromClient::inspect
auto box_model = box->box_model();
StringBuilder builder;
auto serializer = MUST(JsonObjectSerializer<>::try_create(builder));
MUST(serializer.add("padding_top", box_model.padding.top));
MUST(serializer.add("padding_right", box_model.padding.right));
MUST(serializer.add("padding_bottom", box_model.padding.bottom));
MUST(serializer.add("padding_left", box_model.padding.left));
MUST(serializer.add("margin_top", box_model.margin.top));
MUST(serializer.add("margin_right", box_model.margin.right));
MUST(serializer.add("margin_bottom", box_model.margin.bottom));
MUST(serializer.add("margin_left", box_model.margin.left));
MUST(serializer.add("border_top", box_model.border.top));
MUST(serializer.add("border_right", box_model.border.right));
MUST(serializer.add("border_bottom", box_model.border.bottom));
MUST(serializer.add("border_left", box_model.border.left));
MUST(serializer.add("padding_top"sv, box_model.padding.top));
MUST(serializer.add("padding_right"sv, box_model.padding.right));
MUST(serializer.add("padding_bottom"sv, box_model.padding.bottom));
MUST(serializer.add("padding_left"sv, box_model.padding.left));
MUST(serializer.add("margin_top"sv, box_model.margin.top));
MUST(serializer.add("margin_right"sv, box_model.margin.right));
MUST(serializer.add("margin_bottom"sv, box_model.margin.bottom));
MUST(serializer.add("margin_left"sv, box_model.margin.left));
MUST(serializer.add("border_top"sv, box_model.border.top));
MUST(serializer.add("border_right"sv, box_model.border.right));
MUST(serializer.add("border_bottom"sv, box_model.border.bottom));
MUST(serializer.add("border_left"sv, box_model.border.left));
if (auto* paint_box = box->paint_box()) {
MUST(serializer.add("content_width", paint_box->content_width()));
MUST(serializer.add("content_height", paint_box->content_height()));
MUST(serializer.add("content_width"sv, paint_box->content_width()));
MUST(serializer.add("content_height"sv, paint_box->content_height()));
} else {
MUST(serializer.add("content_width", 0));
MUST(serializer.add("content_height", 0));
MUST(serializer.add("content_width"sv, 0));
MUST(serializer.add("content_height"sv, 0));
}
MUST(serializer.finish());

View file

@ -50,7 +50,7 @@ void WebContentConsoleClient::handle_input(String const& js_source)
StringBuilder output_html;
if (result.is_abrupt()) {
output_html.append("Uncaught exception: ");
output_html.append("Uncaught exception: "sv);
auto error = *result.release_error().value();
if (error.is_object())
output_html.append(JS::MarkupGenerator::html_from_error(error.as_object()));
@ -111,19 +111,19 @@ void WebContentConsoleClient::send_messages(i32 start_index)
auto& message = m_message_log[i];
switch (message.type) {
case ConsoleOutput::Type::HTML:
message_types.append("html");
message_types.append("html"sv);
break;
case ConsoleOutput::Type::Clear:
message_types.append("clear");
message_types.append("clear"sv);
break;
case ConsoleOutput::Type::BeginGroup:
message_types.append("group");
message_types.append("group"sv);
break;
case ConsoleOutput::Type::BeginGroupCollapsed:
message_types.append("groupCollapsed");
message_types.append("groupCollapsed"sv);
break;
case ConsoleOutput::Type::EndGroup:
message_types.append("groupEnd");
message_types.append("groupEnd"sv);
break;
}
@ -147,10 +147,10 @@ JS::ThrowCompletionOr<JS::Value> WebContentConsoleClient::printer(JS::Console::L
if (!trace.label.is_empty())
html.appendff("<span class='title'>{}</span><br>", escape_html_entities(trace.label));
html.append("<span class='trace'>");
html.append("<span class='trace'>"sv);
for (auto& function_name : trace.stack)
html.appendff("-> {}<br>", escape_html_entities(function_name));
html.append("</span>");
html.append("</span>"sv);
print_html(html.string_view());
return JS::js_undefined();
@ -162,34 +162,34 @@ JS::ThrowCompletionOr<JS::Value> WebContentConsoleClient::printer(JS::Console::L
return JS::js_undefined();
}
auto output = String::join(" ", arguments.get<JS::MarkedVector<JS::Value>>());
auto output = String::join(' ', arguments.get<JS::MarkedVector<JS::Value>>());
m_console.output_debug_message(log_level, output);
StringBuilder html;
switch (log_level) {
case JS::Console::LogLevel::Debug:
html.append("<span class=\"debug\">(d) ");
html.append("<span class=\"debug\">(d) "sv);
break;
case JS::Console::LogLevel::Error:
html.append("<span class=\"error\">(e) ");
html.append("<span class=\"error\">(e) "sv);
break;
case JS::Console::LogLevel::Info:
html.append("<span class=\"info\">(i) ");
html.append("<span class=\"info\">(i) "sv);
break;
case JS::Console::LogLevel::Log:
html.append("<span class=\"log\"> ");
html.append("<span class=\"log\"> "sv);
break;
case JS::Console::LogLevel::Warn:
case JS::Console::LogLevel::CountReset:
html.append("<span class=\"warn\">(w) ");
html.append("<span class=\"warn\">(w) "sv);
break;
default:
html.append("<span>");
html.append("<span>"sv);
break;
}
html.append(escape_html_entities(output));
html.append("</span>");
html.append("</span>"sv);
print_html(html.string_view());
return JS::js_undefined();
}

View file

@ -77,7 +77,7 @@ void Client::start()
}
builder.append(StringView { maybe_bytes_read.value() });
builder.append("\r\n");
builder.append("\r\n"sv);
}
auto request = builder.to_byte_buffer();
@ -120,7 +120,7 @@ ErrorOr<bool> Client::handle_request(ReadonlyBytes raw_request)
}
}
auto requested_path = LexicalPath::join("/", request.resource()).string();
auto requested_path = LexicalPath::join("/"sv, request.resource()).string();
dbgln_if(WEBSERVER_DEBUG, "Canonical requested path: '{}'", requested_path);
StringBuilder path_builder;
@ -134,7 +134,7 @@ ErrorOr<bool> Client::handle_request(ReadonlyBytes raw_request)
StringBuilder red;
red.append(requested_path);
red.append("/");
red.append("/"sv);
TRY(send_redirect(red.to_string(), request));
return true;
@ -142,7 +142,7 @@ ErrorOr<bool> Client::handle_request(ReadonlyBytes raw_request)
StringBuilder index_html_path_builder;
index_html_path_builder.append(real_path);
index_html_path_builder.append("/index.html");
index_html_path_builder.append("/index.html"sv);
auto index_html_path = index_html_path_builder.to_string();
if (!Core::File::exists(index_html_path)) {
TRY(handle_directory_listing(requested_path, real_path, request));
@ -171,17 +171,17 @@ ErrorOr<bool> Client::handle_request(ReadonlyBytes raw_request)
ErrorOr<void> Client::send_response(InputStream& response, HTTP::HttpRequest const& request, ContentInfo content_info)
{
StringBuilder builder;
builder.append("HTTP/1.0 200 OK\r\n");
builder.append("Server: WebServer (SerenityOS)\r\n");
builder.append("X-Frame-Options: SAMEORIGIN\r\n");
builder.append("X-Content-Type-Options: nosniff\r\n");
builder.append("Pragma: no-cache\r\n");
builder.append("HTTP/1.0 200 OK\r\n"sv);
builder.append("Server: WebServer (SerenityOS)\r\n"sv);
builder.append("X-Frame-Options: SAMEORIGIN\r\n"sv);
builder.append("X-Content-Type-Options: nosniff\r\n"sv);
builder.append("Pragma: no-cache\r\n"sv);
if (content_info.type == "text/plain")
builder.appendff("Content-Type: {}; charset=utf-8\r\n", content_info.type);
else
builder.appendff("Content-Type: {}\r\n", content_info.type);
builder.appendff("Content-Length: {}\r\n", content_info.length);
builder.append("\r\n");
builder.append("\r\n"sv);
auto builder_contents = builder.to_byte_buffer();
TRY(m_socket->write(builder_contents));
@ -206,8 +206,8 @@ ErrorOr<void> Client::send_response(InputStream& response, HTTP::HttpRequest con
} while (true);
auto keep_alive = false;
if (auto it = request.headers().find_if([](auto& header) { return header.name.equals_ignoring_case("Connection"); }); !it.is_end()) {
if (it->value.trim_whitespace().equals_ignoring_case("keep-alive"))
if (auto it = request.headers().find_if([](auto& header) { return header.name.equals_ignoring_case("Connection"sv); }); !it.is_end()) {
if (it->value.trim_whitespace().equals_ignoring_case("keep-alive"sv))
keep_alive = true;
}
if (!keep_alive)
@ -219,11 +219,11 @@ ErrorOr<void> Client::send_response(InputStream& response, HTTP::HttpRequest con
ErrorOr<void> Client::send_redirect(StringView redirect_path, HTTP::HttpRequest const& request)
{
StringBuilder builder;
builder.append("HTTP/1.0 301 Moved Permanently\r\n");
builder.append("Location: ");
builder.append("HTTP/1.0 301 Moved Permanently\r\n"sv);
builder.append("Location: "sv);
builder.append(redirect_path);
builder.append("\r\n");
builder.append("\r\n");
builder.append("\r\n"sv);
builder.append("\r\n"sv);
auto builder_contents = builder.to_byte_buffer();
TRY(m_socket->write(builder_contents));
@ -236,7 +236,7 @@ static String folder_image_data()
{
static String cache;
if (cache.is_empty()) {
auto file = Core::MappedFile::map("/res/icons/16x16/filetype-folder.png").release_value_but_fixme_should_propagate_errors();
auto file = Core::MappedFile::map("/res/icons/16x16/filetype-folder.png"sv).release_value_but_fixme_should_propagate_errors();
cache = encode_base64(file->bytes());
}
return cache;
@ -246,7 +246,7 @@ static String file_image_data()
{
static String cache;
if (cache.is_empty()) {
auto file = Core::MappedFile::map("/res/icons/16x16/filetype-unknown.png").release_value_but_fixme_should_propagate_errors();
auto file = Core::MappedFile::map("/res/icons/16x16/filetype-unknown.png"sv).release_value_but_fixme_should_propagate_errors();
cache = encode_base64(file->bytes());
}
return cache;
@ -256,24 +256,24 @@ ErrorOr<void> Client::handle_directory_listing(String const& requested_path, Str
{
StringBuilder builder;
builder.append("<!DOCTYPE html>\n");
builder.append("<html>\n");
builder.append("<head><meta charset=\"utf-8\">\n");
builder.append("<title>Index of ");
builder.append("<!DOCTYPE html>\n"sv);
builder.append("<html>\n"sv);
builder.append("<head><meta charset=\"utf-8\">\n"sv);
builder.append("<title>Index of "sv);
builder.append(escape_html_entities(requested_path));
builder.append("</title><style>\n");
builder.append(".folder { width: 16px; height: 16px; background-image: url('data:image/png;base64,");
builder.append("</title><style>\n"sv);
builder.append(".folder { width: 16px; height: 16px; background-image: url('data:image/png;base64,"sv);
builder.append(folder_image_data());
builder.append("'); }\n");
builder.append(".file { width: 16px; height: 16px; background-image: url('data:image/png;base64,");
builder.append("'); }\n"sv);
builder.append(".file { width: 16px; height: 16px; background-image: url('data:image/png;base64,"sv);
builder.append(file_image_data());
builder.append("'); }\n");
builder.append("</style></head><body>\n");
builder.append("<h1>Index of ");
builder.append("'); }\n"sv);
builder.append("</style></head><body>\n"sv);
builder.append("<h1>Index of "sv);
builder.append(escape_html_entities(requested_path));
builder.append("</h1>\n");
builder.append("<hr>\n");
builder.append("<code><table>\n");
builder.append("</h1>\n"sv);
builder.append("<hr>\n"sv);
builder.append("<code><table>\n"sv);
Core::DirIterator dt(real_path);
Vector<String> names;
@ -288,7 +288,7 @@ ErrorOr<void> Client::handle_directory_listing(String const& requested_path, Str
// NOTE: In the root directory of the webserver, ".." should be equal to ".", since we don't want
// the user to see e.g. the size of the parent directory (and it isn't unveiled, so stat fails).
if (requested_path == "/" && name == "..")
path_builder.append(".");
path_builder.append("."sv);
else
path_builder.append(name);
@ -301,30 +301,30 @@ ErrorOr<void> Client::handle_directory_listing(String const& requested_path, Str
bool is_directory = S_ISDIR(st.st_mode);
builder.append("<tr>");
builder.append("<tr>"sv);
builder.appendff("<td><div class=\"{}\"></div></td>", is_directory ? "folder" : "file");
builder.append("<td><a href=\"");
builder.append("<td><a href=\""sv);
builder.append(URL::percent_encode(name));
// NOTE: For directories, we append a slash so we don't always hit the redirect case,
// which adds a slash anyways.
if (is_directory)
builder.append('/');
builder.append("\">");
builder.append("\">"sv);
builder.append(escape_html_entities(name));
builder.append("</a></td><td>&nbsp;</td>");
builder.append("</a></td><td>&nbsp;</td>"sv);
builder.appendff("<td>{:10}</td><td>&nbsp;</td>", st.st_size);
builder.append("<td>");
builder.append("<td>"sv);
builder.append(Core::DateTime::from_timestamp(st.st_mtime).to_string());
builder.append("</td>");
builder.append("</tr>\n");
builder.append("</td>"sv);
builder.append("</tr>\n"sv);
}
builder.append("</table></code>\n");
builder.append("<hr>\n");
builder.append("<i>Generated by WebServer (SerenityOS)</i>\n");
builder.append("</body>\n");
builder.append("</html>\n");
builder.append("</table></code>\n"sv);
builder.append("<hr>\n"sv);
builder.append("<i>Generated by WebServer (SerenityOS)</i>\n"sv);
builder.append("</body>\n"sv);
builder.append("</html>\n"sv);
auto response = builder.to_string();
InputMemoryStream stream { response.bytes() };
@ -336,23 +336,23 @@ ErrorOr<void> Client::send_error_response(unsigned code, HTTP::HttpRequest const
auto reason_phrase = HTTP::HttpResponse::reason_phrase_for_code(code);
StringBuilder content_builder;
content_builder.append("<!DOCTYPE html><html><body><h1>");
content_builder.append("<!DOCTYPE html><html><body><h1>"sv);
content_builder.appendff("{} ", code);
content_builder.append(reason_phrase);
content_builder.append("</h1></body></html>");
content_builder.append("</h1></body></html>"sv);
StringBuilder header_builder;
header_builder.appendff("HTTP/1.0 {} ", code);
header_builder.append(reason_phrase);
header_builder.append("\r\n");
header_builder.append("\r\n"sv);
for (auto& header : headers) {
header_builder.append(header);
header_builder.append("\r\n");
header_builder.append("\r\n"sv);
}
header_builder.append("Content-Type: text/html; charset=UTF-8\r\n");
header_builder.append("Content-Type: text/html; charset=UTF-8\r\n"sv);
header_builder.appendff("Content-Length: {}\r\n", content_builder.length());
header_builder.append("\r\n");
header_builder.append("\r\n"sv);
TRY(m_socket->write(header_builder.to_byte_buffer()));
TRY(m_socket->write(content_builder.to_byte_buffer()));
@ -370,7 +370,7 @@ bool Client::verify_credentials(Vector<HTTP::HttpRequest::Header> const& headers
VERIFY(Configuration::the().credentials().has_value());
auto& configured_credentials = Configuration::the().credentials().value();
for (auto& header : headers) {
if (header.name.equals_ignoring_case("Authorization")) {
if (header.name.equals_ignoring_case("Authorization"sv)) {
auto provided_credentials = HTTP::HttpRequest::parse_http_basic_authentication_header(header.value);
if (provided_credentials.has_value() && configured_credentials.username == provided_credentials->username && configured_credentials.password == provided_credentials->password)
return true;

View file

@ -96,7 +96,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/etc/timezone", "r"));
TRY(Core::System::unveil("/res/icons", "r"));
TRY(Core::System::unveil(real_root_path.characters(), "r"));
TRY(Core::System::unveil(real_root_path, "r"sv));
TRY(Core::System::unveil(nullptr, nullptr));
TRY(Core::System::pledge("stdio accept rpath"));

View file

@ -60,7 +60,7 @@ ErrorOr<void> HardwareScreenBackend::set_head_mode_setting(GraphicsHeadModeSetti
rc = graphics_connector_set_safe_head_mode_setting(m_framebuffer_fd);
if (rc != 0) {
dbgln("Failed to set backend safe mode setting: aborting");
return Error::from_syscall("graphics_connector_set_safe_head_mode_setting", rc);
return Error::from_syscall("graphics_connector_set_safe_head_mode_setting"sv, rc);
}
dbgln("Failed to set backend mode setting: falling back to safe resolution - success.");
}
@ -83,7 +83,7 @@ ErrorOr<void> HardwareScreenBackend::map_framebuffer()
memset(&mode_setting, 0, sizeof(GraphicsHeadModeSetting));
int rc = graphics_connector_get_head_mode_setting(m_framebuffer_fd, &mode_setting);
if (rc != 0) {
return Error::from_syscall("graphics_connector_get_head_mode_setting", rc);
return Error::from_syscall("graphics_connector_get_head_mode_setting"sv, rc);
}
m_size_in_bytes = mode_setting.horizontal_stride * mode_setting.vertical_active * 2;
m_framebuffer = (Gfx::ARGB32*)TRY(Core::System::mmap(nullptr, m_size_in_bytes, PROT_READ | PROT_WRITE, MAP_SHARED, m_framebuffer_fd, 0));
@ -108,7 +108,7 @@ ErrorOr<GraphicsHeadModeSetting> HardwareScreenBackend::get_head_mode_setting()
memset(&mode_setting, 0, sizeof(GraphicsHeadModeSetting));
int rc = graphics_connector_get_head_mode_setting(m_framebuffer_fd, &mode_setting);
if (rc != 0) {
return Error::from_syscall("graphics_connector_get_head_mode_setting", rc);
return Error::from_syscall("graphics_connector_get_head_mode_setting"sv, rc);
}
m_pitch = mode_setting.horizontal_stride;
return mode_setting;
@ -131,7 +131,7 @@ ErrorOr<void> HardwareScreenBackend::flush_framebuffer_rects(int buffer_index, S
if (rc == -ENOTSUP)
m_can_device_flush_buffers = false;
else if (rc != 0)
return Error::from_syscall("fb_flush_buffers", rc);
return Error::from_syscall("fb_flush_buffers"sv, rc);
return {};
}
@ -141,7 +141,7 @@ ErrorOr<void> HardwareScreenBackend::flush_framebuffer()
if (rc == -ENOTSUP)
m_can_device_flush_entire_framebuffer = false;
else if (rc != 0)
return Error::from_syscall("fb_flush_head", rc);
return Error::from_syscall("fb_flush_head"sv, rc);
return {};
}
}

View file

@ -96,13 +96,13 @@ String KeymapSwitcher::get_current_keymap() const
auto json = JsonValue::from_string(proc_keymap->read_all()).release_value_but_fixme_should_propagate_errors();
auto const& keymap_object = json.as_object();
VERIFY(keymap_object.has("keymap"));
return keymap_object.get("keymap").to_string();
VERIFY(keymap_object.has("keymap"sv));
return keymap_object.get("keymap"sv).to_string();
}
void KeymapSwitcher::setkeymap(const AK::String& keymap)
{
if (Core::Process::spawn("/bin/keymap", Array { "-m", keymap.characters() }).is_error())
if (Core::Process::spawn("/bin/keymap"sv, Array { "-m", keymap.characters() }).is_error())
dbgln("Failed to call /bin/keymap, error: {} ({})", errno, strerror(errno));
if (on_keymap_change)

View file

@ -61,7 +61,7 @@ static constexpr Gfx::CharacterBitmap s_submenu_arrow_bitmap {
" ### "
" ## "
" # "
" ",
" "sv,
9, 9
};
@ -204,9 +204,9 @@ void Menu::draw()
bool can_go_up = m_scroll_offset > 0;
bool can_go_down = m_scroll_offset < m_max_scroll_offset;
Gfx::IntRect up_indicator_rect { frame_thickness(), frame_thickness(), content_width(), item_height() };
painter.draw_text(up_indicator_rect, "\xE2\xAC\x86", Gfx::TextAlignment::Center, can_go_up ? palette.menu_base_text() : palette.color(ColorRole::DisabledText));
painter.draw_text(up_indicator_rect, "\xE2\xAC\x86"sv, Gfx::TextAlignment::Center, can_go_up ? palette.menu_base_text() : palette.color(ColorRole::DisabledText));
Gfx::IntRect down_indicator_rect { frame_thickness(), menu_window()->height() - item_height() - frame_thickness(), content_width(), item_height() };
painter.draw_text(down_indicator_rect, "\xE2\xAC\x87", Gfx::TextAlignment::Center, can_go_down ? palette.menu_base_text() : palette.color(ColorRole::DisabledText));
painter.draw_text(down_indicator_rect, "\xE2\xAC\x87"sv, Gfx::TextAlignment::Center, can_go_down ? palette.menu_base_text() : palette.color(ColorRole::DisabledText));
}
int visible_item_count = this->visible_item_count();

View file

@ -37,7 +37,7 @@ public:
{
#define __ENUMERATE_MODE_ENUM(val) \
case Mode::val: \
return #val;
return #val##sv;
switch (mode) {
__ENUMERATE_MODE_ENUM(Invalid)

View file

@ -38,7 +38,7 @@ static Gfx::Bitmap& minimize_icon()
{
static RefPtr<Gfx::Bitmap> s_icon;
if (!s_icon)
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png").release_value_but_fixme_should_propagate_errors();
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/downward-triangle.png"sv).release_value_but_fixme_should_propagate_errors();
return *s_icon;
}
@ -46,7 +46,7 @@ static Gfx::Bitmap& maximize_icon()
{
static RefPtr<Gfx::Bitmap> s_icon;
if (!s_icon)
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png").release_value_but_fixme_should_propagate_errors();
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/upward-triangle.png"sv).release_value_but_fixme_should_propagate_errors();
return *s_icon;
}
@ -54,7 +54,7 @@ static Gfx::Bitmap& restore_icon()
{
static RefPtr<Gfx::Bitmap> s_icon;
if (!s_icon)
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-restore.png").release_value_but_fixme_should_propagate_errors();
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-restore.png"sv).release_value_but_fixme_should_propagate_errors();
return *s_icon;
}
@ -62,7 +62,7 @@ static Gfx::Bitmap& close_icon()
{
static RefPtr<Gfx::Bitmap> s_icon;
if (!s_icon)
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-close.png").release_value_but_fixme_should_propagate_errors();
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-close.png"sv).release_value_but_fixme_should_propagate_errors();
return *s_icon;
}
@ -70,7 +70,7 @@ static Gfx::Bitmap& pin_icon()
{
static RefPtr<Gfx::Bitmap> s_icon;
if (!s_icon)
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-pin.png").release_value_but_fixme_should_propagate_errors();
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/window-pin.png"sv).release_value_but_fixme_should_propagate_errors();
return *s_icon;
}
@ -78,7 +78,7 @@ static Gfx::Bitmap& move_icon()
{
static RefPtr<Gfx::Bitmap> s_icon;
if (!s_icon)
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/move.png").release_value_but_fixme_should_propagate_errors();
s_icon = Gfx::Bitmap::try_load_from_file("/res/icons/16x16/move.png"sv).release_value_but_fixme_should_propagate_errors();
return *s_icon;
}
@ -1183,7 +1183,7 @@ void Window::set_modified(bool modified)
String Window::computed_title() const
{
String title = m_title.replace("[*]", is_modified() ? " (*)" : "", ReplaceMode::FirstOnly);
String title = m_title.replace("[*]"sv, is_modified() ? " (*)"sv : ""sv, ReplaceMode::FirstOnly);
if (client() && client()->is_unresponsive())
return String::formatted("{} (Not responding)", title);
return title;

View file

@ -142,7 +142,7 @@ void WindowFrame::reload_config()
{
String icons_path = WindowManager::the().palette().title_button_icons_path();
auto reload_bitmap = [&](RefPtr<MultiScaleBitmaps>& multiscale_bitmap, StringView path, StringView default_path = "") {
auto reload_bitmap = [&](RefPtr<MultiScaleBitmaps>& multiscale_bitmap, StringView path, StringView default_path = ""sv) {
StringBuilder full_path;
full_path.append(icons_path);
full_path.append(path);
@ -155,19 +155,19 @@ void WindowFrame::reload_config()
auto reload_icon = [&](Button::Icon& icon, StringView name, StringView default_path) {
StringBuilder full_name;
full_name.append(name);
full_name.append(".png");
full_name.append(".png"sv);
reload_bitmap(icon.bitmap, full_name.string_view(), default_path);
// Note: No default for hover bitmaps
full_name.clear();
full_name.append(name);
full_name.append("-hover.png");
full_name.append("-hover.png"sv);
reload_bitmap(icon.hover_bitmap, full_name.string_view());
};
reload_icon(s_minimize_icon, "window-minimize", "/res/icons/16x16/downward-triangle.png");
reload_icon(s_maximize_icon, "window-maximize", "/res/icons/16x16/upward-triangle.png");
reload_icon(s_restore_icon, "window-restore", "/res/icons/16x16/window-restore.png");
reload_icon(s_close_icon, "window-close", "/res/icons/16x16/window-close.png");
reload_icon(s_close_modified_icon, "window-close-modified", "/res/icons/16x16/window-close-modified.png");
reload_icon(s_minimize_icon, "window-minimize"sv, "/res/icons/16x16/downward-triangle.png"sv);
reload_icon(s_maximize_icon, "window-maximize"sv, "/res/icons/16x16/upward-triangle.png"sv);
reload_icon(s_restore_icon, "window-restore"sv, "/res/icons/16x16/window-restore.png"sv);
reload_icon(s_close_icon, "window-close"sv, "/res/icons/16x16/window-close.png"sv);
reload_icon(s_close_modified_icon, "window-close-modified"sv, "/res/icons/16x16/window-close-modified.png"sv);
auto load_shadow = [](String const& path, String& last_path, RefPtr<MultiScaleBitmaps>& shadow_bitmap) {
if (path.is_empty()) {

View file

@ -2274,7 +2274,7 @@ void WindowManager::apply_cursor_theme(String const& theme_name)
auto reload_cursor = [&](RefPtr<Cursor>& cursor, String const& name) {
bool is_current_cursor = current_cursor && current_cursor == cursor.ptr();
static auto const s_default_cursor_path = "/res/cursor-themes/Default/arrow.x2y2.png";
static auto const s_default_cursor_path = "/res/cursor-themes/Default/arrow.x2y2.png"sv;
cursor = Cursor::create(String::formatted("/res/cursor-themes/{}/{}", theme_name, cursor_theme_config->read_entry("Cursor", name)), s_default_cursor_path);
if (is_current_cursor) {

View file

@ -53,7 +53,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
{
// FIXME: Map switched tty from screens.
// FIXME: Gracefully cleanup the TTY graphics mode.
int tty_fd = TRY(Core::System::open("/dev/tty", O_RDWR));
int tty_fd = TRY(Core::System::open("/dev/tty"sv, O_RDWR));
TRY(Core::System::ioctl(tty_fd, KDSETMODE, KD_GRAPHICS));
TRY(Core::System::close(tty_fd));
}
@ -73,7 +73,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
Core::DirIterator di("/dev/gpu", Core::DirIterator::SkipParentAndBaseDir);
while (di.has_next()) {
auto path = di.next_path();
if (!path.starts_with("connector"))
if (!path.starts_with("connector"sv))
continue;
auto full_path = String::formatted("/dev/gpu/{}", path);
if (!Core::File::is_device(full_path))