mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 20:07:34 +00:00
AK+Everywhere: Remove the null state of DeprecatedString
This commit removes DeprecatedString's "null" state, and replaces all its users with one of the following: - A normal, empty DeprecatedString - Optional<DeprecatedString> Note that null states of DeprecatedFlyString/StringView/etc are *not* affected by this commit. However, DeprecatedString::empty() is now considered equal to a null StringView.
This commit is contained in:
parent
daf6d8173c
commit
aeee98b3a1
189 changed files with 597 additions and 652 deletions
|
@ -188,7 +188,7 @@ Optional<StringView> Launcher::mime_type_for_file(DeprecatedString path)
|
|||
|
||||
bool Launcher::open_url(const URL& url, DeprecatedString const& handler_name)
|
||||
{
|
||||
if (!handler_name.is_null())
|
||||
if (!handler_name.is_empty())
|
||||
return open_with_handler_name(url, handler_name);
|
||||
|
||||
if (url.scheme() == "file")
|
||||
|
|
|
@ -156,8 +156,8 @@ ErrorOr<void> Service::spawn(int socket_fd)
|
|||
|
||||
if (pid == 0) {
|
||||
// We are the child.
|
||||
if (!m_working_directory.is_null())
|
||||
TRY(Core::System::chdir(m_working_directory));
|
||||
if (m_working_directory.has_value())
|
||||
TRY(Core::System::chdir(*m_working_directory));
|
||||
|
||||
struct sched_param p;
|
||||
p.sched_priority = m_priority;
|
||||
|
@ -167,9 +167,9 @@ ErrorOr<void> Service::spawn(int socket_fd)
|
|||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
||||
if (!m_stdio_file_path.is_null()) {
|
||||
if (m_stdio_file_path.has_value()) {
|
||||
close(STDIN_FILENO);
|
||||
auto const fd = TRY(Core::System::open(m_stdio_file_path, O_RDWR, 0));
|
||||
auto const fd = TRY(Core::System::open(*m_stdio_file_path, O_RDWR, 0));
|
||||
VERIFY(fd == 0);
|
||||
|
||||
dup2(STDIN_FILENO, STDOUT_FILENO);
|
||||
|
@ -288,13 +288,13 @@ Service::Service(Core::ConfigFile const& config, StringView name)
|
|||
|
||||
set_name(name);
|
||||
m_executable_path = config.read_entry(name, "Executable", DeprecatedString::formatted("/bin/{}", this->name()));
|
||||
m_extra_arguments = config.read_entry(name, "Arguments", "");
|
||||
m_stdio_file_path = config.read_entry(name, "StdIO");
|
||||
m_extra_arguments = config.read_entry(name, "Arguments");
|
||||
m_stdio_file_path = config.read_entry_optional(name, "StdIO");
|
||||
|
||||
DeprecatedString prio = config.read_entry(name, "Priority");
|
||||
auto prio = config.read_entry_optional(name, "Priority");
|
||||
if (prio == "low")
|
||||
m_priority = 10;
|
||||
else if (prio == "normal" || prio.is_null())
|
||||
else if (prio == "normal" || !prio.has_value())
|
||||
m_priority = 30;
|
||||
else if (prio == "high")
|
||||
m_priority = 50;
|
||||
|
@ -304,9 +304,9 @@ Service::Service(Core::ConfigFile const& config, StringView name)
|
|||
m_keep_alive = config.read_bool_entry(name, "KeepAlive");
|
||||
m_lazy = config.read_bool_entry(name, "Lazy");
|
||||
|
||||
m_user = config.read_entry(name, "User");
|
||||
if (!m_user.is_null()) {
|
||||
auto result = Core::Account::from_name(m_user, Core::Account::Read::PasswdOnly);
|
||||
m_user = config.read_entry_optional(name, "User");
|
||||
if (m_user.has_value()) {
|
||||
auto result = Core::Account::from_name(*m_user, Core::Account::Read::PasswdOnly);
|
||||
if (result.is_error()) {
|
||||
warnln("Failed to resolve user {}: {}", m_user, result.error());
|
||||
} else {
|
||||
|
@ -315,7 +315,7 @@ Service::Service(Core::ConfigFile const& config, StringView name)
|
|||
}
|
||||
}
|
||||
|
||||
m_working_directory = config.read_entry(name, "WorkingDirectory");
|
||||
m_working_directory = config.read_entry_optional(name, "WorkingDirectory");
|
||||
m_environment = config.read_entry(name, "Environment");
|
||||
m_system_modes = config.read_entry(name, "SystemModes", "graphical").split(',');
|
||||
m_multi_instance = config.read_bool_entry(name, "MultiInstance");
|
||||
|
@ -324,7 +324,7 @@ Service::Service(Core::ConfigFile const& config, StringView name)
|
|||
DeprecatedString socket_entry = config.read_entry(name, "Socket");
|
||||
DeprecatedString socket_permissions_entry = config.read_entry(name, "SocketPermissions", "0600");
|
||||
|
||||
if (!socket_entry.is_null()) {
|
||||
if (!socket_entry.is_empty()) {
|
||||
Vector<DeprecatedString> socket_paths = socket_entry.split(',');
|
||||
Vector<DeprecatedString> socket_perms = socket_permissions_entry.split(',');
|
||||
m_sockets.ensure_capacity(socket_paths.size());
|
||||
|
|
|
@ -54,7 +54,7 @@ private:
|
|||
// Extra arguments, starting from argv[1], to pass when exec'ing.
|
||||
DeprecatedString m_extra_arguments;
|
||||
// File path to open as stdio fds.
|
||||
DeprecatedString m_stdio_file_path;
|
||||
Optional<DeprecatedString> m_stdio_file_path;
|
||||
int m_priority { 1 };
|
||||
// Whether we should re-launch it if it exits.
|
||||
bool m_keep_alive { false };
|
||||
|
@ -65,9 +65,9 @@ private:
|
|||
// Whether we should only spawn this service once somebody connects to the socket.
|
||||
bool m_lazy;
|
||||
// The name of the user we should run this service as.
|
||||
DeprecatedString m_user;
|
||||
Optional<DeprecatedString> m_user;
|
||||
// The working directory in which to spawn the service.
|
||||
DeprecatedString m_working_directory;
|
||||
Optional<DeprecatedString> m_working_directory;
|
||||
// System modes in which to run this service. By default, this is the graphical mode.
|
||||
Vector<DeprecatedString> m_system_modes;
|
||||
// Whether several instances of this service can run at once.
|
||||
|
|
|
@ -169,7 +169,7 @@ static DeprecatedString sanitize_entry_name(DeprecatedString const& name)
|
|||
ErrorOr<void> QuickLaunchWidget::add_or_adjust_button(DeprecatedString const& button_name, NonnullOwnPtr<QuickLaunchEntry>&& entry)
|
||||
{
|
||||
auto file_name_to_watch = entry->file_name_to_watch();
|
||||
if (!file_name_to_watch.is_null()) {
|
||||
if (!file_name_to_watch.is_empty()) {
|
||||
if (!m_watcher) {
|
||||
m_watcher = TRY(Core::FileWatcher::create());
|
||||
m_watcher->on_change = [this](Core::FileWatcherEvent const& event) {
|
||||
|
|
|
@ -31,7 +31,7 @@ bool ScreenLayout::is_valid(DeprecatedString* error_msg) const
|
|||
int smallest_y = 0;
|
||||
for (size_t i = 0; i < screens.size(); i++) {
|
||||
auto& screen = screens[i];
|
||||
if (screen.mode == Screen::Mode::Device && (screen.device->is_empty() || screen.device->is_null())) {
|
||||
if (screen.mode == Screen::Mode::Device && screen.device->is_empty()) {
|
||||
if (error_msg)
|
||||
*error_msg = DeprecatedString::formatted("Screen #{} has no path", i);
|
||||
return false;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue