mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:54:58 +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
|
@ -12,7 +12,7 @@
|
|||
|
||||
static bool s_set_variable = false;
|
||||
|
||||
static DeprecatedString get_variable(StringView name)
|
||||
static Optional<DeprecatedString> get_variable(StringView name)
|
||||
{
|
||||
auto path = DeprecatedString::formatted("/sys/kernel/conf/{}", name);
|
||||
auto file = Core::File::open(path, Core::File::OpenMode::Read);
|
||||
|
@ -25,22 +25,22 @@ static DeprecatedString get_variable(StringView name)
|
|||
warnln("Failed to read {}: {}", path, buffer.error());
|
||||
return {};
|
||||
}
|
||||
return { (char const*)buffer.value().data(), buffer.value().size(), Chomp };
|
||||
return DeprecatedString { (char const*)buffer.value().data(), buffer.value().size(), Chomp };
|
||||
}
|
||||
|
||||
static bool read_variable(StringView name)
|
||||
{
|
||||
auto value = get_variable(name);
|
||||
if (value.is_null())
|
||||
if (!value.has_value())
|
||||
return false;
|
||||
outln("{} = {}", name, value);
|
||||
outln("{} = {}", name, *value);
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool write_variable(StringView name, StringView value)
|
||||
{
|
||||
auto old_value = get_variable(name);
|
||||
if (old_value.is_null())
|
||||
if (!old_value.has_value())
|
||||
return false;
|
||||
auto path = DeprecatedString::formatted("/sys/kernel/conf/{}", name);
|
||||
auto file = Core::File::open(path, Core::File::OpenMode::Write);
|
||||
|
@ -52,7 +52,7 @@ static bool write_variable(StringView name, StringView value)
|
|||
warnln("Failed to write {}: {}", path, result.error());
|
||||
return false;
|
||||
}
|
||||
outln("{}: {} -> {}", name, old_value, value);
|
||||
outln("{}: {} -> {}", name, *old_value, value);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue