mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 19:17:44 +00:00
Everywhere: Rename {Deprecated => Byte}String
This commit un-deprecates DeprecatedString, and repurposes it as a byte string. As the null state has already been removed, there are no other particularly hairy blockers in repurposing this type as a byte string (what it _really_ is). This commit is auto-generated: $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \ Meta Ports Ladybird Tests Kernel) $ perl -pie 's/\bDeprecatedString\b/ByteString/g; s/deprecated_string/byte_string/g' $xs $ clang-format --style=file -i \ $(git diff --name-only | grep \.cpp\|\.h) $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
parent
38d62563b3
commit
5e1499d104
1615 changed files with 10257 additions and 10257 deletions
|
@ -27,7 +27,7 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
static DeprecatedString get_salt()
|
||||
static ByteString get_salt()
|
||||
{
|
||||
char random_data[12];
|
||||
fill_with_random({ random_data, sizeof(random_data) });
|
||||
|
@ -39,7 +39,7 @@ static DeprecatedString get_salt()
|
|||
auto salt_string = MUST(encode_base64({ random_data, sizeof(random_data) }));
|
||||
builder.append(salt_string);
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
static Vector<gid_t> get_extra_gids(passwd const& pwd)
|
||||
|
@ -191,25 +191,25 @@ void Account::set_password(SecretString const& password)
|
|||
|
||||
void Account::set_password_enabled(bool enabled)
|
||||
{
|
||||
auto flattened_password_hash = m_password_hash.value_or(DeprecatedString::empty());
|
||||
auto flattened_password_hash = m_password_hash.value_or(ByteString::empty());
|
||||
if (enabled && !flattened_password_hash.is_empty() && flattened_password_hash[0] == '!') {
|
||||
m_password_hash = flattened_password_hash.substring(1, flattened_password_hash.length() - 1);
|
||||
} else if (!enabled && (flattened_password_hash.is_empty() || flattened_password_hash[0] != '!')) {
|
||||
StringBuilder builder;
|
||||
builder.append('!');
|
||||
builder.append(flattened_password_hash);
|
||||
m_password_hash = builder.to_deprecated_string();
|
||||
m_password_hash = builder.to_byte_string();
|
||||
}
|
||||
}
|
||||
|
||||
void Account::delete_password()
|
||||
{
|
||||
m_password_hash = DeprecatedString::empty();
|
||||
m_password_hash = ByteString::empty();
|
||||
}
|
||||
|
||||
Account::Account(passwd const& pwd, spwd const& spwd, Vector<gid_t> extra_gids)
|
||||
: m_username(pwd.pw_name)
|
||||
, m_password_hash(spwd.sp_pwdp ? Optional<DeprecatedString>(spwd.sp_pwdp) : OptionalNone {})
|
||||
, m_password_hash(spwd.sp_pwdp ? Optional<ByteString>(spwd.sp_pwdp) : OptionalNone {})
|
||||
, m_uid(pwd.pw_uid)
|
||||
, m_gid(pwd.pw_gid)
|
||||
, m_gecos(pwd.pw_gecos)
|
||||
|
@ -219,7 +219,7 @@ Account::Account(passwd const& pwd, spwd const& spwd, Vector<gid_t> extra_gids)
|
|||
{
|
||||
}
|
||||
|
||||
ErrorOr<DeprecatedString> Account::generate_passwd_file() const
|
||||
ErrorOr<ByteString> Account::generate_passwd_file() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
char buffer[1024] = { 0 };
|
||||
|
@ -250,10 +250,10 @@ ErrorOr<DeprecatedString> Account::generate_passwd_file() const
|
|||
}
|
||||
}
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
ErrorOr<DeprecatedString> Account::generate_group_file() const
|
||||
ErrorOr<ByteString> Account::generate_group_file() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
char buffer[1024] = { 0 };
|
||||
|
@ -283,14 +283,14 @@ ErrorOr<DeprecatedString> Account::generate_group_file() const
|
|||
if (should_be_present && !already_present)
|
||||
members.append(m_username.characters());
|
||||
|
||||
builder.appendff("{}:{}:{}:{}\n", group->gr_name, group->gr_passwd, group->gr_gid, DeprecatedString::join(","sv, members));
|
||||
builder.appendff("{}:{}:{}:{}\n", group->gr_name, group->gr_passwd, group->gr_gid, ByteString::join(","sv, members));
|
||||
}
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
#ifndef AK_OS_BSD_GENERIC
|
||||
ErrorOr<DeprecatedString> Account::generate_shadow_file() const
|
||||
ErrorOr<ByteString> Account::generate_shadow_file() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
|
@ -302,25 +302,25 @@ ErrorOr<DeprecatedString> Account::generate_shadow_file() const
|
|||
if (p->sp_namp == m_username) {
|
||||
if (m_deleted)
|
||||
continue;
|
||||
builder.appendff("{}:{}", m_username, m_password_hash.value_or(DeprecatedString::empty()));
|
||||
builder.appendff("{}:{}", m_username, m_password_hash.value_or(ByteString::empty()));
|
||||
} else
|
||||
builder.appendff("{}:{}", p->sp_namp, p->sp_pwdp);
|
||||
|
||||
builder.appendff(":{}:{}:{}:{}:{}:{}:{}\n",
|
||||
(p->sp_lstchg == -1) ? "" : DeprecatedString::formatted("{}", p->sp_lstchg),
|
||||
(p->sp_min == -1) ? "" : DeprecatedString::formatted("{}", p->sp_min),
|
||||
(p->sp_max == -1) ? "" : DeprecatedString::formatted("{}", p->sp_max),
|
||||
(p->sp_warn == -1) ? "" : DeprecatedString::formatted("{}", p->sp_warn),
|
||||
(p->sp_inact == -1) ? "" : DeprecatedString::formatted("{}", p->sp_inact),
|
||||
(p->sp_expire == -1) ? "" : DeprecatedString::formatted("{}", p->sp_expire),
|
||||
(p->sp_flag == 0) ? "" : DeprecatedString::formatted("{}", p->sp_flag));
|
||||
(p->sp_lstchg == -1) ? "" : ByteString::formatted("{}", p->sp_lstchg),
|
||||
(p->sp_min == -1) ? "" : ByteString::formatted("{}", p->sp_min),
|
||||
(p->sp_max == -1) ? "" : ByteString::formatted("{}", p->sp_max),
|
||||
(p->sp_warn == -1) ? "" : ByteString::formatted("{}", p->sp_warn),
|
||||
(p->sp_inact == -1) ? "" : ByteString::formatted("{}", p->sp_inact),
|
||||
(p->sp_expire == -1) ? "" : ByteString::formatted("{}", p->sp_expire),
|
||||
(p->sp_flag == 0) ? "" : ByteString::formatted("{}", p->sp_flag));
|
||||
}
|
||||
endspent();
|
||||
|
||||
if (errno)
|
||||
return Error::from_errno(errno);
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/SecretString.h>
|
||||
|
@ -40,8 +40,8 @@ public:
|
|||
bool authenticate(SecretString const& password) const;
|
||||
ErrorOr<void> login() const;
|
||||
|
||||
DeprecatedString username() const { return m_username; }
|
||||
DeprecatedString password_hash() const { return m_password_hash.value_or(DeprecatedString::empty()); }
|
||||
ByteString username() const { return m_username; }
|
||||
ByteString password_hash() const { return m_password_hash.value_or(ByteString::empty()); }
|
||||
|
||||
// Setters only affect in-memory copy of password.
|
||||
// You must call sync to apply changes.
|
||||
|
@ -62,9 +62,9 @@ public:
|
|||
|
||||
uid_t uid() const { return m_uid; }
|
||||
gid_t gid() const { return m_gid; }
|
||||
DeprecatedString const& gecos() const { return m_gecos; }
|
||||
DeprecatedString const& home_directory() const { return m_home_directory; }
|
||||
DeprecatedString const& shell() const { return m_shell; }
|
||||
ByteString const& gecos() const { return m_gecos; }
|
||||
ByteString const& home_directory() const { return m_home_directory; }
|
||||
ByteString const& shell() const { return m_shell; }
|
||||
Vector<gid_t> const& extra_gids() const { return m_extra_gids; }
|
||||
|
||||
ErrorOr<void> sync();
|
||||
|
@ -74,20 +74,20 @@ private:
|
|||
|
||||
Account(passwd const& pwd, spwd const& spwd, Vector<gid_t> extra_gids);
|
||||
|
||||
ErrorOr<DeprecatedString> generate_passwd_file() const;
|
||||
ErrorOr<DeprecatedString> generate_group_file() const;
|
||||
ErrorOr<ByteString> generate_passwd_file() const;
|
||||
ErrorOr<ByteString> generate_group_file() const;
|
||||
#ifndef AK_OS_BSD_GENERIC
|
||||
ErrorOr<DeprecatedString> generate_shadow_file() const;
|
||||
ErrorOr<ByteString> generate_shadow_file() const;
|
||||
#endif
|
||||
|
||||
DeprecatedString m_username;
|
||||
ByteString m_username;
|
||||
|
||||
Optional<DeprecatedString> m_password_hash;
|
||||
Optional<ByteString> m_password_hash;
|
||||
uid_t m_uid { 0 };
|
||||
gid_t m_gid { 0 };
|
||||
DeprecatedString m_gecos;
|
||||
DeprecatedString m_home_directory;
|
||||
DeprecatedString m_shell;
|
||||
ByteString m_gecos;
|
||||
ByteString m_home_directory;
|
||||
ByteString m_shell;
|
||||
Vector<gid_t> m_extra_gids;
|
||||
bool m_deleted { false };
|
||||
};
|
||||
|
|
|
@ -88,7 +88,7 @@ bool ArgsParser::parse(Span<StringView> arguments, FailureBehavior failure_behav
|
|||
}
|
||||
}
|
||||
|
||||
auto short_options = short_options_builder.to_deprecated_string();
|
||||
auto short_options = short_options_builder.to_byte_string();
|
||||
size_t option_index = 1;
|
||||
while (true) {
|
||||
auto result = parser.getopt(arguments.slice(1), short_options, long_options, {});
|
||||
|
@ -439,7 +439,7 @@ void ArgsParser::add_option(bool& value, char const* help_string, char const* lo
|
|||
add_option(move(option));
|
||||
}
|
||||
|
||||
void ArgsParser::add_option(DeprecatedString& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode)
|
||||
void ArgsParser::add_option(ByteString& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode)
|
||||
{
|
||||
Option option {
|
||||
OptionArgumentMode::Required,
|
||||
|
@ -599,7 +599,7 @@ void ArgsParser::add_option(Vector<size_t>& values, char const* help_string, cha
|
|||
add_option(move(option));
|
||||
}
|
||||
|
||||
void ArgsParser::add_option(Vector<DeprecatedString>& values, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode)
|
||||
void ArgsParser::add_option(Vector<ByteString>& values, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode)
|
||||
{
|
||||
Option option {
|
||||
OptionArgumentMode::Optional,
|
||||
|
@ -622,7 +622,7 @@ void ArgsParser::add_positional_argument(Arg&& arg)
|
|||
m_positional_args.append(move(arg));
|
||||
}
|
||||
|
||||
void ArgsParser::add_positional_argument(DeprecatedString& value, char const* help_string, char const* name, Required required)
|
||||
void ArgsParser::add_positional_argument(ByteString& value, char const* help_string, char const* name, Required required)
|
||||
{
|
||||
Arg arg {
|
||||
help_string,
|
||||
|
@ -713,7 +713,7 @@ void ArgsParser::add_positional_argument(double& value, char const* help_string,
|
|||
add_positional_argument(move(arg));
|
||||
}
|
||||
|
||||
void ArgsParser::add_positional_argument(Vector<DeprecatedString>& values, char const* help_string, char const* name, Required required)
|
||||
void ArgsParser::add_positional_argument(Vector<ByteString>& values, char const* help_string, char const* name, Required required)
|
||||
{
|
||||
Arg arg {
|
||||
help_string,
|
||||
|
@ -837,12 +837,12 @@ void ArgsParser::autocomplete(FILE* file, StringView program_name, ReadonlySpan<
|
|||
|
||||
auto write_completion = [&](auto format, auto& option, auto has_invariant, auto... args) {
|
||||
JsonObject object;
|
||||
object.set("completion", DeprecatedString::formatted(StringView { format, strlen(format) }, args...));
|
||||
object.set("completion", ByteString::formatted(StringView { format, strlen(format) }, args...));
|
||||
object.set("static_offset", 0);
|
||||
object.set("invariant_offset", has_invariant ? option_to_complete.length() : 0u);
|
||||
object.set("display_trivia", option.help_string);
|
||||
object.set("trailing_trivia", option.argument_mode == OptionArgumentMode::Required ? " " : "");
|
||||
outln(file, "{}", object.to_deprecated_string());
|
||||
outln(file, "{}", object.to_byte_string());
|
||||
};
|
||||
|
||||
if (option_to_complete.starts_with("--"sv)) {
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Concepts.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibMain/Main.h>
|
||||
|
@ -54,11 +54,11 @@ public:
|
|||
Function<ErrorOr<bool>(StringView)> accept_value;
|
||||
OptionHideMode hide_mode { OptionHideMode::None };
|
||||
|
||||
DeprecatedString name_for_display() const
|
||||
ByteString name_for_display() const
|
||||
{
|
||||
if (long_name)
|
||||
return DeprecatedString::formatted("--{}", long_name);
|
||||
return DeprecatedString::formatted("-{:c}", short_name);
|
||||
return ByteString::formatted("--{}", long_name);
|
||||
return ByteString::formatted("-{:c}", short_name);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -101,7 +101,7 @@ public:
|
|||
},
|
||||
.hide_mode = hide_mode });
|
||||
}
|
||||
void add_option(DeprecatedString& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None);
|
||||
void add_option(ByteString& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None);
|
||||
void add_option(String& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None);
|
||||
void add_option(StringView& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None);
|
||||
template<Integral I>
|
||||
|
@ -112,16 +112,16 @@ public:
|
|||
void add_option(Vector<size_t>& values, char const* help_string, char const* long_name, char short_name, char const* value_name, char separator = ',', OptionHideMode hide_mode = OptionHideMode::None);
|
||||
// Note: This option is being used when we expect the user to use the same option
|
||||
// multiple times (e.g. "program --option=example --option=anotherexample ...").
|
||||
void add_option(Vector<DeprecatedString>& values, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None);
|
||||
void add_option(Vector<ByteString>& values, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None);
|
||||
|
||||
void add_positional_argument(Arg&&);
|
||||
void add_positional_argument(DeprecatedString& value, char const* help_string, char const* name, Required required = Required::Yes);
|
||||
void add_positional_argument(ByteString& value, char const* help_string, char const* name, Required required = Required::Yes);
|
||||
void add_positional_argument(StringView& value, char const* help_string, char const* name, Required required = Required::Yes);
|
||||
void add_positional_argument(String& value, char const* help_string, char const* name, Required required = Required::Yes);
|
||||
template<Integral I>
|
||||
void add_positional_argument(I& value, char const* help_string, char const* name, Required required = Required::Yes);
|
||||
void add_positional_argument(double& value, char const* help_string, char const* name, Required required = Required::Yes);
|
||||
void add_positional_argument(Vector<DeprecatedString>& value, char const* help_string, char const* name, Required required = Required::Yes);
|
||||
void add_positional_argument(Vector<ByteString>& value, char const* help_string, char const* name, Required required = Required::Yes);
|
||||
void add_positional_argument(Vector<StringView>& value, char const* help_string, char const* name, Required required = Required::Yes);
|
||||
void add_positional_argument(Vector<String>& value, char const* help_string, char const* name, Required required = Required::Yes);
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ ErrorOr<void> Command::write(StringView input)
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> Command::write_lines(Span<DeprecatedString> lines)
|
||||
ErrorOr<void> Command::write_lines(Span<ByteString> lines)
|
||||
{
|
||||
// It's possible the process dies before we can write everything to the
|
||||
// stdin. So make sure that we don't crash but just stop writing.
|
||||
|
@ -83,8 +83,8 @@ ErrorOr<void> Command::write_lines(Span<DeprecatedString> lines)
|
|||
perror("sigaction");
|
||||
});
|
||||
|
||||
for (DeprecatedString const& line : lines)
|
||||
TRY(m_stdin->write_until_depleted(DeprecatedString::formatted("{}\n", line).bytes()));
|
||||
for (ByteString const& line : lines)
|
||||
TRY(m_stdin->write_until_depleted(ByteString::formatted("{}\n", line).bytes()));
|
||||
|
||||
return {};
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ ErrorOr<Command::ProcessResult> Command::status(int options)
|
|||
// Only supported in serenity mode because we use `posix_spawn_file_actions_addchdir`
|
||||
#ifdef AK_OS_SERENITY
|
||||
|
||||
ErrorOr<CommandResult> command(DeprecatedString const& command_string, Optional<LexicalPath> chdir)
|
||||
ErrorOr<CommandResult> command(ByteString const& command_string, Optional<LexicalPath> chdir)
|
||||
{
|
||||
auto parts = command_string.split(' ');
|
||||
if (parts.is_empty())
|
||||
|
@ -130,7 +130,7 @@ ErrorOr<CommandResult> command(DeprecatedString const& command_string, Optional<
|
|||
return command(program, parts, chdir);
|
||||
}
|
||||
|
||||
ErrorOr<CommandResult> command(DeprecatedString const& program, Vector<DeprecatedString> const& arguments, Optional<LexicalPath> chdir)
|
||||
ErrorOr<CommandResult> command(ByteString const& program, Vector<ByteString> const& arguments, Optional<LexicalPath> chdir)
|
||||
{
|
||||
int stdout_pipe[2] = {};
|
||||
int stderr_pipe[2] = {};
|
||||
|
|
|
@ -25,8 +25,8 @@ struct CommandResult {
|
|||
ByteBuffer error;
|
||||
};
|
||||
|
||||
ErrorOr<CommandResult> command(DeprecatedString const& program, Vector<DeprecatedString> const& arguments, Optional<LexicalPath> chdir);
|
||||
ErrorOr<CommandResult> command(DeprecatedString const& command_string, Optional<LexicalPath> chdir);
|
||||
ErrorOr<CommandResult> command(ByteString const& program, Vector<ByteString> const& arguments, Optional<LexicalPath> chdir);
|
||||
ErrorOr<CommandResult> command(ByteString const& command_string, Optional<LexicalPath> chdir);
|
||||
|
||||
class Command {
|
||||
public:
|
||||
|
@ -41,7 +41,7 @@ public:
|
|||
|
||||
ErrorOr<void> write(StringView input);
|
||||
|
||||
ErrorOr<void> write_lines(Span<DeprecatedString> lines);
|
||||
ErrorOr<void> write_lines(Span<ByteString> lines);
|
||||
|
||||
ErrorOr<ProcessOutputs> read_all();
|
||||
|
||||
|
|
|
@ -17,28 +17,28 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open_for_lib(DeprecatedString const& lib_name, AllowWriting allow_altering)
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open_for_lib(ByteString const& lib_name, AllowWriting allow_altering)
|
||||
{
|
||||
DeprecatedString directory_name = DeprecatedString::formatted("{}/lib", StandardPaths::config_directory());
|
||||
ByteString directory_name = ByteString::formatted("{}/lib", StandardPaths::config_directory());
|
||||
auto directory = TRY(Directory::create(directory_name, Directory::CreateDirectories::Yes));
|
||||
auto path = DeprecatedString::formatted("{}/{}.ini", directory, lib_name);
|
||||
auto path = ByteString::formatted("{}/{}.ini", directory, lib_name);
|
||||
return ConfigFile::open(path, allow_altering);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open_for_app(DeprecatedString const& app_name, AllowWriting allow_altering)
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open_for_app(ByteString const& app_name, AllowWriting allow_altering)
|
||||
{
|
||||
auto directory = TRY(Directory::create(StandardPaths::config_directory(), Directory::CreateDirectories::Yes));
|
||||
auto path = DeprecatedString::formatted("{}/{}.ini", directory, app_name);
|
||||
auto path = ByteString::formatted("{}/{}.ini", directory, app_name);
|
||||
return ConfigFile::open(path, allow_altering);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open_for_system(DeprecatedString const& app_name, AllowWriting allow_altering)
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open_for_system(ByteString const& app_name, AllowWriting allow_altering)
|
||||
{
|
||||
auto path = DeprecatedString::formatted("/etc/{}.ini", app_name);
|
||||
auto path = ByteString::formatted("/etc/{}.ini", app_name);
|
||||
return ConfigFile::open(path, allow_altering);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& filename, AllowWriting allow_altering)
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(ByteString const& filename, AllowWriting allow_altering)
|
||||
{
|
||||
auto maybe_file = File::open(filename, allow_altering == AllowWriting::Yes ? File::OpenMode::ReadWrite : File::OpenMode::Read);
|
||||
OwnPtr<InputBufferedFile> buffered_file;
|
||||
|
@ -57,13 +57,13 @@ ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& file
|
|||
return config_file;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& filename, int fd)
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(ByteString const& filename, int fd)
|
||||
{
|
||||
auto file = TRY(File::adopt_fd(fd, File::OpenMode::ReadWrite));
|
||||
return open(filename, move(file));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& filename, NonnullOwnPtr<Core::File> file)
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(ByteString const& filename, NonnullOwnPtr<Core::File> file)
|
||||
{
|
||||
auto buffered_file = TRY(InputBufferedFile::create(move(file)));
|
||||
|
||||
|
@ -72,7 +72,7 @@ ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& file
|
|||
return config_file;
|
||||
}
|
||||
|
||||
ConfigFile::ConfigFile(DeprecatedString const& filename, OwnPtr<InputBufferedFile> open_file)
|
||||
ConfigFile::ConfigFile(ByteString const& filename, OwnPtr<InputBufferedFile> open_file)
|
||||
: m_filename(filename)
|
||||
, m_file(move(open_file))
|
||||
{
|
||||
|
@ -89,7 +89,7 @@ ErrorOr<void> ConfigFile::reparse()
|
|||
if (!m_file)
|
||||
return {};
|
||||
|
||||
HashMap<DeprecatedString, DeprecatedString>* current_group = nullptr;
|
||||
HashMap<ByteString, ByteString>* current_group = nullptr;
|
||||
|
||||
auto buffer = TRY(ByteBuffer::create_uninitialized(4096));
|
||||
while (TRY(m_file->can_read_line())) {
|
||||
|
@ -113,7 +113,7 @@ ErrorOr<void> ConfigFile::reparse()
|
|||
builder.append(line[i]);
|
||||
++i;
|
||||
}
|
||||
current_group = &m_groups.ensure(builder.to_deprecated_string());
|
||||
current_group = &m_groups.ensure(builder.to_byte_string());
|
||||
break;
|
||||
}
|
||||
default: { // Start of key
|
||||
|
@ -132,15 +132,15 @@ ErrorOr<void> ConfigFile::reparse()
|
|||
// We're not in a group yet, create one with the name ""...
|
||||
current_group = &m_groups.ensure("");
|
||||
}
|
||||
auto value_string = value_builder.to_deprecated_string();
|
||||
current_group->set(key_builder.to_deprecated_string(), value_string.trim_whitespace(TrimMode::Right));
|
||||
auto value_string = value_builder.to_byte_string();
|
||||
current_group->set(key_builder.to_byte_string(), value_string.trim_whitespace(TrimMode::Right));
|
||||
}
|
||||
}
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
Optional<DeprecatedString> ConfigFile::read_entry_optional(const AK::DeprecatedString& group, const AK::DeprecatedString& key) const
|
||||
Optional<ByteString> ConfigFile::read_entry_optional(const AK::ByteString& group, const AK::ByteString& key) const
|
||||
{
|
||||
if (!has_key(group, key))
|
||||
return {};
|
||||
|
@ -149,19 +149,19 @@ Optional<DeprecatedString> ConfigFile::read_entry_optional(const AK::DeprecatedS
|
|||
return jt->value;
|
||||
}
|
||||
|
||||
bool ConfigFile::read_bool_entry(DeprecatedString const& group, DeprecatedString const& key, bool default_value) const
|
||||
bool ConfigFile::read_bool_entry(ByteString const& group, ByteString const& key, bool default_value) const
|
||||
{
|
||||
auto value = read_entry(group, key, default_value ? "true" : "false");
|
||||
return value == "1" || value.equals_ignoring_ascii_case("true"sv);
|
||||
}
|
||||
|
||||
void ConfigFile::write_entry(DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value)
|
||||
void ConfigFile::write_entry(ByteString const& group, ByteString const& key, ByteString const& value)
|
||||
{
|
||||
m_groups.ensure(group).ensure(key) = value;
|
||||
m_dirty = true;
|
||||
}
|
||||
|
||||
void ConfigFile::write_bool_entry(DeprecatedString const& group, DeprecatedString const& key, bool value)
|
||||
void ConfigFile::write_bool_entry(ByteString const& group, ByteString const& key, bool value)
|
||||
{
|
||||
write_entry(group, key, value ? "true" : "false");
|
||||
}
|
||||
|
@ -178,9 +178,9 @@ ErrorOr<void> ConfigFile::sync()
|
|||
TRY(m_file->seek(0, SeekMode::SetPosition));
|
||||
|
||||
for (auto& it : m_groups) {
|
||||
TRY(m_file->write_until_depleted(DeprecatedString::formatted("[{}]\n", it.key).bytes()));
|
||||
TRY(m_file->write_until_depleted(ByteString::formatted("[{}]\n", it.key).bytes()));
|
||||
for (auto& jt : it.value)
|
||||
TRY(m_file->write_until_depleted(DeprecatedString::formatted("{}={}\n", jt.key, jt.value).bytes()));
|
||||
TRY(m_file->write_until_depleted(ByteString::formatted("{}={}\n", jt.key, jt.value).bytes()));
|
||||
TRY(m_file->write_until_depleted("\n"sv.bytes()));
|
||||
}
|
||||
|
||||
|
@ -198,12 +198,12 @@ void ConfigFile::dump() const
|
|||
}
|
||||
}
|
||||
|
||||
Vector<DeprecatedString> ConfigFile::groups() const
|
||||
Vector<ByteString> ConfigFile::groups() const
|
||||
{
|
||||
return m_groups.keys();
|
||||
}
|
||||
|
||||
Vector<DeprecatedString> ConfigFile::keys(DeprecatedString const& group) const
|
||||
Vector<ByteString> ConfigFile::keys(ByteString const& group) const
|
||||
{
|
||||
auto it = m_groups.find(group);
|
||||
if (it == m_groups.end())
|
||||
|
@ -211,7 +211,7 @@ Vector<DeprecatedString> ConfigFile::keys(DeprecatedString const& group) const
|
|||
return it->value.keys();
|
||||
}
|
||||
|
||||
bool ConfigFile::has_key(DeprecatedString const& group, DeprecatedString const& key) const
|
||||
bool ConfigFile::has_key(ByteString const& group, ByteString const& key) const
|
||||
{
|
||||
auto it = m_groups.find(group);
|
||||
if (it == m_groups.end())
|
||||
|
@ -219,24 +219,24 @@ bool ConfigFile::has_key(DeprecatedString const& group, DeprecatedString const&
|
|||
return it->value.contains(key);
|
||||
}
|
||||
|
||||
bool ConfigFile::has_group(DeprecatedString const& group) const
|
||||
bool ConfigFile::has_group(ByteString const& group) const
|
||||
{
|
||||
return m_groups.contains(group);
|
||||
}
|
||||
|
||||
void ConfigFile::add_group(DeprecatedString const& group)
|
||||
void ConfigFile::add_group(ByteString const& group)
|
||||
{
|
||||
m_groups.ensure(group);
|
||||
m_dirty = true;
|
||||
}
|
||||
|
||||
void ConfigFile::remove_group(DeprecatedString const& group)
|
||||
void ConfigFile::remove_group(ByteString const& group)
|
||||
{
|
||||
m_groups.remove(group);
|
||||
m_dirty = true;
|
||||
}
|
||||
|
||||
void ConfigFile::remove_entry(DeprecatedString const& group, DeprecatedString const& key)
|
||||
void ConfigFile::remove_entry(ByteString const& group, ByteString const& key)
|
||||
{
|
||||
auto it = m_groups.find(group);
|
||||
if (it == m_groups.end())
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
|
@ -26,31 +26,31 @@ public:
|
|||
No,
|
||||
};
|
||||
|
||||
static ErrorOr<NonnullRefPtr<ConfigFile>> open_for_lib(DeprecatedString const& lib_name, AllowWriting = AllowWriting::No);
|
||||
static ErrorOr<NonnullRefPtr<ConfigFile>> open_for_app(DeprecatedString const& app_name, AllowWriting = AllowWriting::No);
|
||||
static ErrorOr<NonnullRefPtr<ConfigFile>> open_for_system(DeprecatedString const& app_name, AllowWriting = AllowWriting::No);
|
||||
static ErrorOr<NonnullRefPtr<ConfigFile>> open(DeprecatedString const& filename, AllowWriting = AllowWriting::No);
|
||||
static ErrorOr<NonnullRefPtr<ConfigFile>> open(DeprecatedString const& filename, int fd);
|
||||
static ErrorOr<NonnullRefPtr<ConfigFile>> open(DeprecatedString const& filename, NonnullOwnPtr<Core::File>);
|
||||
static ErrorOr<NonnullRefPtr<ConfigFile>> open_for_lib(ByteString const& lib_name, AllowWriting = AllowWriting::No);
|
||||
static ErrorOr<NonnullRefPtr<ConfigFile>> open_for_app(ByteString const& app_name, AllowWriting = AllowWriting::No);
|
||||
static ErrorOr<NonnullRefPtr<ConfigFile>> open_for_system(ByteString const& app_name, AllowWriting = AllowWriting::No);
|
||||
static ErrorOr<NonnullRefPtr<ConfigFile>> open(ByteString const& filename, AllowWriting = AllowWriting::No);
|
||||
static ErrorOr<NonnullRefPtr<ConfigFile>> open(ByteString const& filename, int fd);
|
||||
static ErrorOr<NonnullRefPtr<ConfigFile>> open(ByteString const& filename, NonnullOwnPtr<Core::File>);
|
||||
~ConfigFile();
|
||||
|
||||
bool has_group(DeprecatedString const&) const;
|
||||
bool has_key(DeprecatedString const& group, DeprecatedString const& key) const;
|
||||
bool has_group(ByteString const&) const;
|
||||
bool has_key(ByteString const& group, ByteString const& key) const;
|
||||
|
||||
Vector<DeprecatedString> groups() const;
|
||||
Vector<DeprecatedString> keys(DeprecatedString const& group) const;
|
||||
Vector<ByteString> groups() const;
|
||||
Vector<ByteString> keys(ByteString const& group) const;
|
||||
|
||||
size_t num_groups() const { return m_groups.size(); }
|
||||
|
||||
DeprecatedString read_entry(DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& default_value = {}) const
|
||||
ByteString read_entry(ByteString const& group, ByteString const& key, ByteString const& default_value = {}) const
|
||||
{
|
||||
return read_entry_optional(group, key).value_or(default_value);
|
||||
}
|
||||
Optional<DeprecatedString> read_entry_optional(DeprecatedString const& group, DeprecatedString const& key) const;
|
||||
bool read_bool_entry(DeprecatedString const& group, DeprecatedString const& key, bool default_value = false) const;
|
||||
Optional<ByteString> read_entry_optional(ByteString const& group, ByteString const& key) const;
|
||||
bool read_bool_entry(ByteString const& group, ByteString const& key, bool default_value = false) const;
|
||||
|
||||
template<Integral T = int>
|
||||
T read_num_entry(DeprecatedString const& group, DeprecatedString const& key, T default_value = 0) const
|
||||
T read_num_entry(ByteString const& group, ByteString const& key, T default_value = 0) const
|
||||
{
|
||||
if (!has_key(group, key))
|
||||
return default_value;
|
||||
|
@ -61,13 +61,13 @@ public:
|
|||
return read_entry(group, key, "").to_uint<T>().value_or(default_value);
|
||||
}
|
||||
|
||||
void write_entry(DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value);
|
||||
void write_bool_entry(DeprecatedString const& group, DeprecatedString const& key, bool value);
|
||||
void write_entry(ByteString const& group, ByteString const& key, ByteString const& value);
|
||||
void write_bool_entry(ByteString const& group, ByteString const& key, bool value);
|
||||
|
||||
template<Integral T = int>
|
||||
void write_num_entry(DeprecatedString const& group, DeprecatedString const& key, T value)
|
||||
void write_num_entry(ByteString const& group, ByteString const& key, T value)
|
||||
{
|
||||
write_entry(group, key, DeprecatedString::number(value));
|
||||
write_entry(group, key, ByteString::number(value));
|
||||
}
|
||||
|
||||
void dump() const;
|
||||
|
@ -76,20 +76,20 @@ public:
|
|||
|
||||
ErrorOr<void> sync();
|
||||
|
||||
void add_group(DeprecatedString const& group);
|
||||
void remove_group(DeprecatedString const& group);
|
||||
void remove_entry(DeprecatedString const& group, DeprecatedString const& key);
|
||||
void add_group(ByteString const& group);
|
||||
void remove_group(ByteString const& group);
|
||||
void remove_entry(ByteString const& group, ByteString const& key);
|
||||
|
||||
DeprecatedString const& filename() const { return m_filename; }
|
||||
ByteString const& filename() const { return m_filename; }
|
||||
|
||||
private:
|
||||
ConfigFile(DeprecatedString const& filename, OwnPtr<InputBufferedFile> open_file);
|
||||
ConfigFile(ByteString const& filename, OwnPtr<InputBufferedFile> open_file);
|
||||
|
||||
ErrorOr<void> reparse();
|
||||
|
||||
DeprecatedString m_filename;
|
||||
ByteString m_filename;
|
||||
OwnPtr<InputBufferedFile> m_file;
|
||||
HashMap<DeprecatedString, HashMap<DeprecatedString, DeprecatedString>> m_groups;
|
||||
HashMap<ByteString, HashMap<ByteString, ByteString>> m_groups;
|
||||
bool m_dirty { false };
|
||||
};
|
||||
|
||||
|
|
|
@ -283,9 +283,9 @@ ErrorOr<String> DateTime::to_string(StringView format) const
|
|||
return builder.to_string();
|
||||
}
|
||||
|
||||
DeprecatedString DateTime::to_deprecated_string(StringView format) const
|
||||
ByteString DateTime::to_byte_string(StringView format) const
|
||||
{
|
||||
return MUST(to_string(format)).to_deprecated_string();
|
||||
return MUST(to_string(format)).to_byte_string();
|
||||
}
|
||||
|
||||
Optional<DateTime> DateTime::parse(StringView format, StringView string)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibIPC/Forward.h>
|
||||
#include <time.h>
|
||||
|
@ -32,7 +32,7 @@ public:
|
|||
|
||||
void set_time(int year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0);
|
||||
ErrorOr<String> to_string(StringView format = "%Y-%m-%d %H:%M:%S"sv) const;
|
||||
DeprecatedString to_deprecated_string(StringView format = "%Y-%m-%d %H:%M:%S"sv) const;
|
||||
ByteString to_byte_string(StringView format = "%Y-%m-%d %H:%M:%S"sv) const;
|
||||
|
||||
static DateTime create(int year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0);
|
||||
static DateTime now();
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
DirIterator::DirIterator(DeprecatedString path, Flags flags)
|
||||
DirIterator::DirIterator(ByteString path, Flags flags)
|
||||
: m_path(move(path))
|
||||
, m_flags(flags)
|
||||
{
|
||||
|
@ -93,7 +93,7 @@ Optional<DirectoryEntry> DirIterator::next()
|
|||
return result;
|
||||
}
|
||||
|
||||
DeprecatedString DirIterator::next_path()
|
||||
ByteString DirIterator::next_path()
|
||||
{
|
||||
auto entry = next();
|
||||
if (entry.has_value())
|
||||
|
@ -101,14 +101,14 @@ DeprecatedString DirIterator::next_path()
|
|||
return "";
|
||||
}
|
||||
|
||||
DeprecatedString DirIterator::next_full_path()
|
||||
ByteString DirIterator::next_full_path()
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(m_path);
|
||||
if (!m_path.ends_with('/'))
|
||||
builder.append('/');
|
||||
builder.append(next_path());
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
int DirIterator::fd() const
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <LibCore/DirectoryEntry.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
|
@ -22,7 +22,7 @@ public:
|
|||
SkipParentAndBaseDir = 0x2,
|
||||
};
|
||||
|
||||
explicit DirIterator(DeprecatedString path, Flags = Flags::NoFlags);
|
||||
explicit DirIterator(ByteString path, Flags = Flags::NoFlags);
|
||||
~DirIterator();
|
||||
|
||||
DirIterator(DirIterator&&);
|
||||
|
@ -32,15 +32,15 @@ public:
|
|||
Error error() const { return Error::copy(m_error.value()); }
|
||||
bool has_next();
|
||||
Optional<DirectoryEntry> next();
|
||||
DeprecatedString next_path();
|
||||
DeprecatedString next_full_path();
|
||||
ByteString next_path();
|
||||
ByteString next_full_path();
|
||||
int fd() const;
|
||||
|
||||
private:
|
||||
DIR* m_dir = nullptr;
|
||||
Optional<Error> m_error;
|
||||
Optional<DirectoryEntry> m_next;
|
||||
DeprecatedString m_path;
|
||||
ByteString m_path;
|
||||
int m_flags;
|
||||
|
||||
bool advance_next();
|
||||
|
|
|
@ -53,7 +53,7 @@ ErrorOr<Directory> Directory::adopt_fd(int fd, LexicalPath path)
|
|||
return Directory { fd, move(path) };
|
||||
}
|
||||
|
||||
ErrorOr<Directory> Directory::create(DeprecatedString path, CreateDirectories create_directories, mode_t creation_mode)
|
||||
ErrorOr<Directory> Directory::create(ByteString path, CreateDirectories create_directories, mode_t creation_mode)
|
||||
{
|
||||
return create(LexicalPath { move(path) }, create_directories, creation_mode);
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ public:
|
|||
};
|
||||
|
||||
static ErrorOr<Directory> create(LexicalPath path, CreateDirectories, mode_t creation_mode = 0755);
|
||||
static ErrorOr<Directory> create(DeprecatedString path, CreateDirectories, mode_t creation_mode = 0755);
|
||||
static ErrorOr<Directory> create(ByteString path, CreateDirectories, mode_t creation_mode = 0755);
|
||||
static ErrorOr<Directory> adopt_fd(int fd, LexicalPath path);
|
||||
|
||||
ErrorOr<NonnullOwnPtr<File>> open(StringView filename, File::OpenMode mode) const;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <dirent.h>
|
||||
|
||||
namespace Core {
|
||||
|
@ -25,7 +25,7 @@ struct DirectoryEntry {
|
|||
};
|
||||
Type type;
|
||||
// FIXME: Once we have a special Path string class, use that.
|
||||
DeprecatedString name;
|
||||
ByteString name;
|
||||
ino_t inode_number;
|
||||
|
||||
static DirectoryEntry from_dirent(dirent const&);
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/HashMap.h>
|
||||
|
@ -67,8 +67,8 @@ public:
|
|||
|
||||
virtual bool is_widget() const { return false; }
|
||||
|
||||
DeprecatedString const& name() const { return m_name; }
|
||||
void set_name(DeprecatedString name) { m_name = move(name); }
|
||||
ByteString const& name() const { return m_name; }
|
||||
void set_name(ByteString name) { m_name = move(name); }
|
||||
|
||||
Vector<NonnullRefPtr<EventReceiver>>& children() { return m_children; }
|
||||
Vector<NonnullRefPtr<EventReceiver>> const& children() const { return m_children; }
|
||||
|
@ -168,7 +168,7 @@ protected:
|
|||
|
||||
private:
|
||||
EventReceiver* m_parent { nullptr };
|
||||
DeprecatedString m_name;
|
||||
ByteString m_name;
|
||||
int m_timer_id { 0 };
|
||||
Vector<NonnullRefPtr<EventReceiver>> m_children;
|
||||
Function<bool(Core::Event&)> m_event_filter;
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/EnumBits.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/Noncopyable.h>
|
||||
|
@ -27,7 +27,7 @@ struct FileWatcherEvent {
|
|||
ChildDeleted = 1 << 4,
|
||||
};
|
||||
Type type { Type::Invalid };
|
||||
DeprecatedString event_path;
|
||||
ByteString event_path;
|
||||
};
|
||||
|
||||
AK_ENUM_BITWISE_OPERATORS(FileWatcherEvent::Type);
|
||||
|
@ -44,9 +44,9 @@ class FileWatcherBase {
|
|||
public:
|
||||
virtual ~FileWatcherBase() = default;
|
||||
|
||||
ErrorOr<bool> add_watch(DeprecatedString path, FileWatcherEvent::Type event_mask);
|
||||
ErrorOr<bool> remove_watch(DeprecatedString path);
|
||||
bool is_watching(DeprecatedString const& path) const { return m_path_to_wd.find(path) != m_path_to_wd.end(); }
|
||||
ErrorOr<bool> add_watch(ByteString path, FileWatcherEvent::Type event_mask);
|
||||
ErrorOr<bool> remove_watch(ByteString path);
|
||||
bool is_watching(ByteString const& path) const { return m_path_to_wd.find(path) != m_path_to_wd.end(); }
|
||||
|
||||
protected:
|
||||
FileWatcherBase(int watcher_fd)
|
||||
|
@ -55,8 +55,8 @@ protected:
|
|||
}
|
||||
|
||||
int m_watcher_fd { -1 };
|
||||
HashMap<DeprecatedString, unsigned> m_path_to_wd;
|
||||
HashMap<unsigned, DeprecatedString> m_wd_to_path;
|
||||
HashMap<ByteString, unsigned> m_path_to_wd;
|
||||
HashMap<unsigned, ByteString> m_wd_to_path;
|
||||
};
|
||||
|
||||
class BlockingFileWatcher final : public FileWatcherBase {
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
*/
|
||||
|
||||
#include "FileWatcher.h"
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/Notifier.h>
|
||||
#include <errno.h>
|
||||
|
@ -34,7 +34,7 @@ static constexpr unsigned file_watcher_flags_to_inotify_flags(FileWatcherFlags f
|
|||
return result;
|
||||
}
|
||||
|
||||
static Optional<FileWatcherEvent> get_event_from_fd(int fd, HashMap<unsigned, DeprecatedString> const& wd_to_path)
|
||||
static Optional<FileWatcherEvent> get_event_from_fd(int fd, HashMap<unsigned, ByteString> const& wd_to_path)
|
||||
{
|
||||
static constexpr auto max_event_size = sizeof(inotify_event) + NAME_MAX + 1;
|
||||
|
||||
|
@ -123,7 +123,7 @@ FileWatcher::FileWatcher(int watcher_fd, NonnullRefPtr<Notifier> notifier)
|
|||
|
||||
FileWatcher::~FileWatcher() = default;
|
||||
|
||||
ErrorOr<bool> FileWatcherBase::add_watch(DeprecatedString path, FileWatcherEvent::Type event_mask)
|
||||
ErrorOr<bool> FileWatcherBase::add_watch(ByteString path, FileWatcherEvent::Type event_mask)
|
||||
{
|
||||
if (m_path_to_wd.find(path) != m_path_to_wd.end()) {
|
||||
dbgln_if(FILE_WATCHER_DEBUG, "add_watch: path '{}' is already being watched", path);
|
||||
|
@ -154,7 +154,7 @@ ErrorOr<bool> FileWatcherBase::add_watch(DeprecatedString path, FileWatcherEvent
|
|||
return true;
|
||||
}
|
||||
|
||||
ErrorOr<bool> FileWatcherBase::remove_watch(DeprecatedString path)
|
||||
ErrorOr<bool> FileWatcherBase::remove_watch(ByteString path)
|
||||
{
|
||||
auto it = m_path_to_wd.find(path);
|
||||
if (it == m_path_to_wd.end()) {
|
||||
|
|
|
@ -29,7 +29,7 @@ static_assert(false, "This file must only be used for macOS");
|
|||
namespace Core {
|
||||
|
||||
struct MonitoredPath {
|
||||
DeprecatedString path;
|
||||
ByteString path;
|
||||
FileWatcherEvent::Type event_mask { FileWatcherEvent::Type::Invalid };
|
||||
};
|
||||
|
||||
|
@ -55,7 +55,7 @@ public:
|
|||
{
|
||||
auto context = TRY(try_make<FSEventStreamContext>());
|
||||
|
||||
auto queue_name = DeprecatedString::formatted("Serenity.FileWatcher.{:p}", context.ptr());
|
||||
auto queue_name = ByteString::formatted("Serenity.FileWatcher.{:p}", context.ptr());
|
||||
auto dispatch_queue = dispatch_queue_create(queue_name.characters(), DISPATCH_QUEUE_SERIAL);
|
||||
if (dispatch_queue == nullptr)
|
||||
return Error::from_errno(errno);
|
||||
|
@ -67,7 +67,7 @@ public:
|
|||
return adopt_nonnull_ref_or_enomem(new (nothrow) FileWatcherMacOS(move(context), dispatch_queue, move(notifier)));
|
||||
}
|
||||
|
||||
ErrorOr<bool> add_watch(DeprecatedString path, FileWatcherEvent::Type event_mask)
|
||||
ErrorOr<bool> add_watch(ByteString path, FileWatcherEvent::Type event_mask)
|
||||
{
|
||||
if (m_path_to_inode_id.contains(path)) {
|
||||
dbgln_if(FILE_WATCHER_DEBUG, "add_watch: path '{}' is already being watched", path);
|
||||
|
@ -84,7 +84,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
ErrorOr<bool> remove_watch(DeprecatedString path)
|
||||
ErrorOr<bool> remove_watch(ByteString path)
|
||||
{
|
||||
auto it = m_path_to_inode_id.find(path);
|
||||
if (it == m_path_to_inode_id.end()) {
|
||||
|
@ -101,7 +101,7 @@ public:
|
|||
return true;
|
||||
}
|
||||
|
||||
ErrorOr<MonitoredPath> canonicalize_path(DeprecatedString path)
|
||||
ErrorOr<MonitoredPath> canonicalize_path(ByteString path)
|
||||
{
|
||||
LexicalPath lexical_path { move(path) };
|
||||
auto parent_path = lexical_path.parent();
|
||||
|
@ -200,7 +200,7 @@ private:
|
|||
dispatch_queue_t m_dispatch_queue { nullptr };
|
||||
FSEventStreamRef m_stream { nullptr };
|
||||
|
||||
HashMap<DeprecatedString, ino_t> m_path_to_inode_id;
|
||||
HashMap<ByteString, ino_t> m_path_to_inode_id;
|
||||
HashMap<ino_t, MonitoredPath> m_inode_id_to_path;
|
||||
};
|
||||
|
||||
|
@ -219,7 +219,7 @@ void on_file_system_event(ConstFSEventStreamRef, void* user_data, size_t event_s
|
|||
continue;
|
||||
}
|
||||
|
||||
auto maybe_monitored_path = file_watcher.canonicalize_path(DeprecatedString { file_path_buffer });
|
||||
auto maybe_monitored_path = file_watcher.canonicalize_path(ByteString { file_path_buffer });
|
||||
if (maybe_monitored_path.is_error()) {
|
||||
dbgln_if(FILE_WATCHER_DEBUG, "Could not canonicalize path {}: {}", file_path_buffer, maybe_monitored_path.error());
|
||||
continue;
|
||||
|
@ -265,13 +265,13 @@ FileWatcher::FileWatcher(int watcher_fd, NonnullRefPtr<Notifier> notifier)
|
|||
|
||||
FileWatcher::~FileWatcher() = default;
|
||||
|
||||
ErrorOr<bool> FileWatcherBase::add_watch(DeprecatedString path, FileWatcherEvent::Type event_mask)
|
||||
ErrorOr<bool> FileWatcherBase::add_watch(ByteString path, FileWatcherEvent::Type event_mask)
|
||||
{
|
||||
auto& file_watcher = verify_cast<FileWatcherMacOS>(*this);
|
||||
return file_watcher.add_watch(move(path), event_mask);
|
||||
}
|
||||
|
||||
ErrorOr<bool> FileWatcherBase::remove_watch(DeprecatedString path)
|
||||
ErrorOr<bool> FileWatcherBase::remove_watch(ByteString path)
|
||||
{
|
||||
auto& file_watcher = verify_cast<FileWatcherMacOS>(*this);
|
||||
return file_watcher.remove_watch(move(path));
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
*/
|
||||
|
||||
#include "FileWatcher.h"
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <Kernel/API/InodeWatcherEvent.h>
|
||||
|
@ -36,7 +36,7 @@ static constexpr unsigned file_watcher_flags_to_inode_watcher_flags(FileWatcherF
|
|||
return static_cast<unsigned>(result);
|
||||
}
|
||||
|
||||
static Optional<FileWatcherEvent> get_event_from_fd(int fd, HashMap<unsigned, DeprecatedString> const& wd_to_path)
|
||||
static Optional<FileWatcherEvent> get_event_from_fd(int fd, HashMap<unsigned, ByteString> const& wd_to_path)
|
||||
{
|
||||
u8 buffer[MAXIMUM_EVENT_SIZE];
|
||||
int rc = read(fd, &buffer, MAXIMUM_EVENT_SIZE);
|
||||
|
@ -55,7 +55,7 @@ static Optional<FileWatcherEvent> get_event_from_fd(int fd, HashMap<unsigned, De
|
|||
dbgln_if(FILE_WATCHER_DEBUG, "get_event_from_fd: Got an event for a non-existent wd {}?!", event->watch_descriptor);
|
||||
return {};
|
||||
}
|
||||
DeprecatedString const& path = it->value;
|
||||
ByteString const& path = it->value;
|
||||
|
||||
switch (event->type) {
|
||||
case InodeWatcherEvent::Type::ChildCreated:
|
||||
|
@ -80,7 +80,7 @@ static Optional<FileWatcherEvent> get_event_from_fd(int fd, HashMap<unsigned, De
|
|||
|
||||
// We trust that the kernel only sends the name when appropriate.
|
||||
if (event->name_length > 0) {
|
||||
DeprecatedString child_name { event->name, event->name_length - 1 };
|
||||
ByteString child_name { event->name, event->name_length - 1 };
|
||||
result.event_path = LexicalPath::join(path, child_name).string();
|
||||
} else {
|
||||
result.event_path = path;
|
||||
|
@ -90,7 +90,7 @@ static Optional<FileWatcherEvent> get_event_from_fd(int fd, HashMap<unsigned, De
|
|||
return result;
|
||||
}
|
||||
|
||||
static DeprecatedString canonicalize_path(DeprecatedString path)
|
||||
static ByteString canonicalize_path(ByteString path)
|
||||
{
|
||||
if (!path.is_empty() && path[0] == '/')
|
||||
return LexicalPath::canonicalized_path(move(path));
|
||||
|
@ -99,9 +99,9 @@ static DeprecatedString canonicalize_path(DeprecatedString path)
|
|||
return LexicalPath::join({ cwd, strlen(cwd) }, move(path)).string();
|
||||
}
|
||||
|
||||
ErrorOr<bool> FileWatcherBase::add_watch(DeprecatedString path, FileWatcherEvent::Type event_mask)
|
||||
ErrorOr<bool> FileWatcherBase::add_watch(ByteString path, FileWatcherEvent::Type event_mask)
|
||||
{
|
||||
DeprecatedString canonical_path = canonicalize_path(move(path));
|
||||
ByteString canonical_path = canonicalize_path(move(path));
|
||||
|
||||
if (m_path_to_wd.find(canonical_path) != m_path_to_wd.end()) {
|
||||
dbgln_if(FILE_WATCHER_DEBUG, "add_watch: path '{}' is already being watched", canonical_path);
|
||||
|
@ -131,9 +131,9 @@ ErrorOr<bool> FileWatcherBase::add_watch(DeprecatedString path, FileWatcherEvent
|
|||
return true;
|
||||
}
|
||||
|
||||
ErrorOr<bool> FileWatcherBase::remove_watch(DeprecatedString path)
|
||||
ErrorOr<bool> FileWatcherBase::remove_watch(ByteString path)
|
||||
{
|
||||
DeprecatedString canonical_path = canonicalize_path(move(path));
|
||||
ByteString canonical_path = canonicalize_path(move(path));
|
||||
|
||||
auto it = m_path_to_wd.find(canonical_path);
|
||||
if (it == m_path_to_wd.end()) {
|
||||
|
|
|
@ -24,12 +24,12 @@ FileWatcher::FileWatcher(int watcher_fd, NonnullRefPtr<Notifier> notifier)
|
|||
|
||||
FileWatcher::~FileWatcher() = default;
|
||||
|
||||
ErrorOr<bool> FileWatcherBase::add_watch(DeprecatedString, FileWatcherEvent::Type)
|
||||
ErrorOr<bool> FileWatcherBase::add_watch(ByteString, FileWatcherEvent::Type)
|
||||
{
|
||||
return Error::from_errno(ENOTSUP);
|
||||
}
|
||||
|
||||
ErrorOr<bool> FileWatcherBase::remove_watch(DeprecatedString)
|
||||
ErrorOr<bool> FileWatcherBase::remove_watch(ByteString)
|
||||
{
|
||||
return Error::from_errno(ENOTSUP);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
ErrorOr<DeprecatedString> Group::generate_group_file() const
|
||||
ErrorOr<ByteString> Group::generate_group_file() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
char buffer[1024] = { 0 };
|
||||
|
@ -29,19 +29,19 @@ ErrorOr<DeprecatedString> Group::generate_group_file() const
|
|||
break;
|
||||
|
||||
if (group->gr_name == m_name)
|
||||
builder.appendff("{}:x:{}:{}\n", m_name, m_id, DeprecatedString::join(',', m_members));
|
||||
builder.appendff("{}:x:{}:{}\n", m_name, m_id, ByteString::join(',', m_members));
|
||||
else {
|
||||
Vector<DeprecatedString> members;
|
||||
Vector<ByteString> members;
|
||||
if (group->gr_mem) {
|
||||
for (size_t i = 0; group->gr_mem[i]; ++i)
|
||||
members.append(group->gr_mem[i]);
|
||||
}
|
||||
|
||||
builder.appendff("{}:x:{}:{}\n", group->gr_name, group->gr_gid, DeprecatedString::join(',', members));
|
||||
builder.appendff("{}:x:{}:{}\n", group->gr_name, group->gr_gid, ByteString::join(',', members));
|
||||
}
|
||||
}
|
||||
|
||||
return builder.to_deprecated_string();
|
||||
return builder.to_byte_string();
|
||||
}
|
||||
|
||||
ErrorOr<void> Group::sync()
|
||||
|
@ -74,7 +74,7 @@ ErrorOr<void> Group::add_group(Group& group)
|
|||
return Error::from_string_literal("Group name can not be empty.");
|
||||
|
||||
// A quick sanity check on group name
|
||||
if (group.name().find_any_of("\\/!@#$%^&*()~+=`:\n"sv, DeprecatedString::SearchDirection::Forward).has_value())
|
||||
if (group.name().find_any_of("\\/!@#$%^&*()~+=`:\n"sv, ByteString::SearchDirection::Forward).has_value())
|
||||
return Error::from_string_literal("Group name has invalid characters.");
|
||||
|
||||
// Disallow names starting with '_', '-' or other non-alpha characters.
|
||||
|
@ -129,7 +129,7 @@ ErrorOr<Vector<Group>> Group::all()
|
|||
if (!group.has_value())
|
||||
break;
|
||||
|
||||
Vector<DeprecatedString> members;
|
||||
Vector<ByteString> members;
|
||||
if (group->gr_mem) {
|
||||
for (size_t i = 0; group->gr_mem[i]; ++i)
|
||||
members.append(group->gr_mem[i]);
|
||||
|
@ -141,7 +141,7 @@ ErrorOr<Vector<Group>> Group::all()
|
|||
return groups;
|
||||
}
|
||||
|
||||
Group::Group(DeprecatedString name, gid_t id, Vector<DeprecatedString> members)
|
||||
Group::Group(ByteString name, gid_t id, Vector<ByteString> members)
|
||||
: m_name(move(name))
|
||||
, m_id(id)
|
||||
, m_members(move(members))
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <grp.h>
|
||||
|
@ -22,17 +22,17 @@ public:
|
|||
static ErrorOr<Vector<Group>> all();
|
||||
|
||||
Group() = default;
|
||||
Group(DeprecatedString name, gid_t id = 0, Vector<DeprecatedString> members = {});
|
||||
Group(ByteString name, gid_t id = 0, Vector<ByteString> members = {});
|
||||
|
||||
~Group() = default;
|
||||
|
||||
DeprecatedString const& name() const { return m_name; }
|
||||
void set_name(DeprecatedString const& name) { m_name = name; }
|
||||
ByteString const& name() const { return m_name; }
|
||||
void set_name(ByteString const& name) { m_name = name; }
|
||||
|
||||
gid_t id() const { return m_id; }
|
||||
void set_group_id(gid_t const id) { m_id = id; }
|
||||
|
||||
Vector<DeprecatedString>& members() { return m_members; }
|
||||
Vector<ByteString>& members() { return m_members; }
|
||||
|
||||
ErrorOr<void> sync();
|
||||
|
||||
|
@ -41,11 +41,11 @@ private:
|
|||
static ErrorOr<bool> id_exists(gid_t id);
|
||||
ErrorOr<struct group> to_libc_group();
|
||||
|
||||
ErrorOr<DeprecatedString> generate_group_file() const;
|
||||
ErrorOr<ByteString> generate_group_file() const;
|
||||
|
||||
DeprecatedString m_name;
|
||||
ByteString m_name;
|
||||
gid_t m_id { 0 };
|
||||
Vector<DeprecatedString> m_members;
|
||||
Vector<ByteString> m_members;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ LocalServer::~LocalServer()
|
|||
::close(m_fd);
|
||||
}
|
||||
|
||||
ErrorOr<void> LocalServer::take_over_from_system_server(DeprecatedString const& socket_path)
|
||||
ErrorOr<void> LocalServer::take_over_from_system_server(ByteString const& socket_path)
|
||||
{
|
||||
if (m_listening)
|
||||
return Error::from_string_literal("Core::LocalServer: Can't perform socket takeover when already listening");
|
||||
|
@ -65,7 +65,7 @@ void LocalServer::setup_notifier()
|
|||
};
|
||||
}
|
||||
|
||||
bool LocalServer::listen(DeprecatedString const& address)
|
||||
bool LocalServer::listen(ByteString const& address)
|
||||
{
|
||||
if (m_listening)
|
||||
return false;
|
||||
|
|
|
@ -16,9 +16,9 @@ class LocalServer : public EventReceiver {
|
|||
public:
|
||||
virtual ~LocalServer() override;
|
||||
|
||||
ErrorOr<void> take_over_from_system_server(DeprecatedString const& path = DeprecatedString());
|
||||
ErrorOr<void> take_over_from_system_server(ByteString const& path = ByteString());
|
||||
bool is_listening() const { return m_listening; }
|
||||
bool listen(DeprecatedString const& address);
|
||||
bool listen(ByteString const& address);
|
||||
|
||||
ErrorOr<NonnullOwnPtr<LocalSocket>> accept();
|
||||
|
||||
|
|
|
@ -27,7 +27,7 @@ ErrorOr<void> MimeData::set_urls(Vector<URL> const& urls)
|
|||
{
|
||||
StringBuilder builder;
|
||||
for (auto& url : urls) {
|
||||
TRY(builder.try_append(url.to_deprecated_string()));
|
||||
TRY(builder.try_append(url.to_byte_string()));
|
||||
TRY(builder.try_append('\n'));
|
||||
}
|
||||
set_data("text/uri-list"_string, TRY(builder.to_byte_buffer()));
|
||||
|
@ -35,12 +35,12 @@ ErrorOr<void> MimeData::set_urls(Vector<URL> const& urls)
|
|||
return {};
|
||||
}
|
||||
|
||||
DeprecatedString MimeData::text() const
|
||||
ByteString MimeData::text() const
|
||||
{
|
||||
return DeprecatedString::copy(m_data.get("text/plain"sv).value_or({}));
|
||||
return ByteString::copy(m_data.get("text/plain"sv).value_or({}));
|
||||
}
|
||||
|
||||
void MimeData::set_text(DeprecatedString const& text)
|
||||
void MimeData::set_text(ByteString const& text)
|
||||
{
|
||||
set_data("text/plain"_string, text.to_byte_buffer());
|
||||
}
|
||||
|
|
|
@ -28,8 +28,8 @@ public:
|
|||
|
||||
// Convenience helpers for "text/plain"
|
||||
bool has_text() const { return has_format("text/plain"sv); }
|
||||
DeprecatedString text() const;
|
||||
void set_text(DeprecatedString const&);
|
||||
ByteString text() const;
|
||||
void set_text(ByteString const&);
|
||||
|
||||
// Convenience helpers for "text/uri-list"
|
||||
bool has_urls() const { return has_format("text/uri-list"sv); }
|
||||
|
|
|
@ -27,7 +27,7 @@ public:
|
|||
virtual ~NetworkJob() override = default;
|
||||
|
||||
// Could fire twice, after Headers and after Trailers!
|
||||
Function<void(HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code)> on_headers_received;
|
||||
Function<void(HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code)> on_headers_received;
|
||||
Function<void(bool success)> on_finish;
|
||||
Function<void(Optional<u64>, u64)> on_progress;
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/ScopeGuard.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
|
@ -35,10 +35,10 @@ extern "C" {
|
|||
namespace Core {
|
||||
|
||||
struct ArgvList {
|
||||
DeprecatedString m_path;
|
||||
ByteString m_path;
|
||||
Vector<char const*, 10> m_argv;
|
||||
|
||||
ArgvList(DeprecatedString path, size_t size)
|
||||
ArgvList(ByteString path, size_t size)
|
||||
: m_path { path }
|
||||
{
|
||||
m_argv.ensure_capacity(size + 2);
|
||||
|
@ -103,12 +103,12 @@ ErrorOr<Process> Process::spawn(ProcessSpawnOptions const& options)
|
|||
return Process { pid };
|
||||
}
|
||||
|
||||
ErrorOr<pid_t> Process::spawn(StringView path, ReadonlySpan<DeprecatedString> arguments, DeprecatedString working_directory, KeepAsChild keep_as_child)
|
||||
ErrorOr<pid_t> Process::spawn(StringView path, ReadonlySpan<ByteString> arguments, ByteString working_directory, KeepAsChild keep_as_child)
|
||||
{
|
||||
auto process = TRY(spawn({
|
||||
.path = path,
|
||||
.arguments = Vector<DeprecatedString> { arguments },
|
||||
.working_directory = working_directory.is_empty() ? Optional<DeprecatedString> {} : Optional<DeprecatedString> { working_directory },
|
||||
.arguments = Vector<ByteString> { arguments },
|
||||
.working_directory = working_directory.is_empty() ? Optional<ByteString> {} : Optional<ByteString> { working_directory },
|
||||
}));
|
||||
|
||||
if (keep_as_child == KeepAsChild::No)
|
||||
|
@ -120,9 +120,9 @@ ErrorOr<pid_t> Process::spawn(StringView path, ReadonlySpan<DeprecatedString> ar
|
|||
return process.pid();
|
||||
}
|
||||
|
||||
ErrorOr<pid_t> Process::spawn(StringView path, ReadonlySpan<StringView> arguments, DeprecatedString working_directory, KeepAsChild keep_as_child)
|
||||
ErrorOr<pid_t> Process::spawn(StringView path, ReadonlySpan<StringView> arguments, ByteString working_directory, KeepAsChild keep_as_child)
|
||||
{
|
||||
Vector<DeprecatedString> backing_strings;
|
||||
Vector<ByteString> backing_strings;
|
||||
backing_strings.ensure_capacity(arguments.size());
|
||||
for (auto const& argument : arguments)
|
||||
backing_strings.append(argument);
|
||||
|
@ -130,7 +130,7 @@ ErrorOr<pid_t> Process::spawn(StringView path, ReadonlySpan<StringView> argument
|
|||
auto process = TRY(spawn({
|
||||
.path = path,
|
||||
.arguments = backing_strings,
|
||||
.working_directory = working_directory.is_empty() ? Optional<DeprecatedString> {} : Optional<DeprecatedString> { working_directory },
|
||||
.working_directory = working_directory.is_empty() ? Optional<ByteString> {} : Optional<ByteString> { working_directory },
|
||||
}));
|
||||
|
||||
if (keep_as_child == KeepAsChild::No)
|
||||
|
@ -140,9 +140,9 @@ ErrorOr<pid_t> Process::spawn(StringView path, ReadonlySpan<StringView> argument
|
|||
return process.pid();
|
||||
}
|
||||
|
||||
ErrorOr<pid_t> Process::spawn(StringView path, ReadonlySpan<char const*> arguments, DeprecatedString working_directory, KeepAsChild keep_as_child)
|
||||
ErrorOr<pid_t> Process::spawn(StringView path, ReadonlySpan<char const*> arguments, ByteString working_directory, KeepAsChild keep_as_child)
|
||||
{
|
||||
Vector<DeprecatedString> backing_strings;
|
||||
Vector<ByteString> backing_strings;
|
||||
backing_strings.ensure_capacity(arguments.size());
|
||||
for (auto const& argument : arguments)
|
||||
backing_strings.append(argument);
|
||||
|
@ -150,7 +150,7 @@ ErrorOr<pid_t> Process::spawn(StringView path, ReadonlySpan<char const*> argumen
|
|||
auto process = TRY(spawn({
|
||||
.path = path,
|
||||
.arguments = backing_strings,
|
||||
.working_directory = working_directory.is_empty() ? Optional<DeprecatedString> {} : Optional<DeprecatedString> { working_directory },
|
||||
.working_directory = working_directory.is_empty() ? Optional<ByteString> {} : Optional<ByteString> { working_directory },
|
||||
}));
|
||||
|
||||
if (keep_as_child == KeepAsChild::No)
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/Span.h>
|
||||
#include <LibCore/File.h>
|
||||
|
@ -18,7 +18,7 @@ namespace Core {
|
|||
namespace FileAction {
|
||||
|
||||
struct OpenFile {
|
||||
DeprecatedString path;
|
||||
ByteString path;
|
||||
File::OpenMode mode = File::OpenMode::NotOpen;
|
||||
int fd = -1;
|
||||
mode_t permissions = 0600;
|
||||
|
@ -29,9 +29,9 @@ struct OpenFile {
|
|||
}
|
||||
|
||||
struct ProcessSpawnOptions {
|
||||
DeprecatedString path;
|
||||
Vector<DeprecatedString> const& arguments = {};
|
||||
Optional<DeprecatedString> working_directory = {};
|
||||
ByteString path;
|
||||
Vector<ByteString> const& arguments = {};
|
||||
Optional<ByteString> working_directory = {};
|
||||
Vector<Variant<FileAction::OpenFile>> const& file_actions = {};
|
||||
};
|
||||
|
||||
|
@ -60,11 +60,11 @@ public:
|
|||
static ErrorOr<Process> spawn(ProcessSpawnOptions const& options);
|
||||
|
||||
// FIXME: Make the following 2 functions return Process instance or delete them.
|
||||
static ErrorOr<pid_t> spawn(StringView path, ReadonlySpan<DeprecatedString> arguments, DeprecatedString working_directory = {}, KeepAsChild keep_as_child = KeepAsChild::No);
|
||||
static ErrorOr<pid_t> spawn(StringView path, ReadonlySpan<StringView> arguments, DeprecatedString working_directory = {}, KeepAsChild keep_as_child = KeepAsChild::No);
|
||||
static ErrorOr<pid_t> spawn(StringView path, ReadonlySpan<ByteString> arguments, ByteString working_directory = {}, KeepAsChild keep_as_child = KeepAsChild::No);
|
||||
static ErrorOr<pid_t> spawn(StringView path, ReadonlySpan<StringView> arguments, ByteString working_directory = {}, KeepAsChild keep_as_child = KeepAsChild::No);
|
||||
|
||||
// FIXME: Remove this. char const* should not exist on this level of abstraction.
|
||||
static ErrorOr<pid_t> spawn(StringView path, ReadonlySpan<char const*> arguments = {}, DeprecatedString working_directory = {}, KeepAsChild keep_as_child = KeepAsChild::No);
|
||||
static ErrorOr<pid_t> spawn(StringView path, ReadonlySpan<char const*> arguments = {}, ByteString working_directory = {}, KeepAsChild keep_as_child = KeepAsChild::No);
|
||||
|
||||
static ErrorOr<String> get_name();
|
||||
enum class SetThreadName {
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
HashMap<uid_t, DeprecatedString> ProcessStatisticsReader::s_usernames;
|
||||
HashMap<uid_t, ByteString> ProcessStatisticsReader::s_usernames;
|
||||
|
||||
ErrorOr<AllProcessesStatistics> ProcessStatisticsReader::get_all(SeekableStream& proc_all_file, bool include_usernames)
|
||||
{
|
||||
|
@ -37,11 +37,11 @@ ErrorOr<AllProcessesStatistics> ProcessStatisticsReader::get_all(SeekableStream&
|
|||
process.gid = process_object.get_u32("gid"sv).value_or(0);
|
||||
process.ppid = process_object.get_u32("ppid"sv).value_or(0);
|
||||
process.kernel = process_object.get_bool("kernel"sv).value_or(false);
|
||||
process.name = process_object.get_deprecated_string("name"sv).value_or("");
|
||||
process.executable = process_object.get_deprecated_string("executable"sv).value_or("");
|
||||
process.tty = process_object.get_deprecated_string("tty"sv).value_or("");
|
||||
process.pledge = process_object.get_deprecated_string("pledge"sv).value_or("");
|
||||
process.veil = process_object.get_deprecated_string("veil"sv).value_or("");
|
||||
process.name = process_object.get_byte_string("name"sv).value_or("");
|
||||
process.executable = process_object.get_byte_string("executable"sv).value_or("");
|
||||
process.tty = process_object.get_byte_string("tty"sv).value_or("");
|
||||
process.pledge = process_object.get_byte_string("pledge"sv).value_or("");
|
||||
process.veil = process_object.get_byte_string("veil"sv).value_or("");
|
||||
process.creation_time = UnixDateTime::from_nanoseconds_since_epoch(process_object.get_i64("creation_time"sv).value_or(0));
|
||||
process.amount_virtual = process_object.get_u32("amount_virtual"sv).value_or(0);
|
||||
process.amount_resident = process_object.get_u32("amount_resident"sv).value_or(0);
|
||||
|
@ -58,8 +58,8 @@ ErrorOr<AllProcessesStatistics> ProcessStatisticsReader::get_all(SeekableStream&
|
|||
Core::ThreadStatistics thread;
|
||||
thread.tid = thread_object.get_u32("tid"sv).value_or(0);
|
||||
thread.times_scheduled = thread_object.get_u32("times_scheduled"sv).value_or(0);
|
||||
thread.name = thread_object.get_deprecated_string("name"sv).value_or("");
|
||||
thread.state = thread_object.get_deprecated_string("state"sv).value_or("");
|
||||
thread.name = thread_object.get_byte_string("name"sv).value_or("");
|
||||
thread.state = thread_object.get_byte_string("state"sv).value_or("");
|
||||
thread.time_user = thread_object.get_u64("time_user"sv).value_or(0);
|
||||
thread.time_kernel = thread_object.get_u64("time_kernel"sv).value_or(0);
|
||||
thread.cpu = thread_object.get_u32("cpu"sv).value_or(0);
|
||||
|
@ -95,7 +95,7 @@ ErrorOr<AllProcessesStatistics> ProcessStatisticsReader::get_all(bool include_us
|
|||
return get_all(*proc_all_file, include_usernames);
|
||||
}
|
||||
|
||||
DeprecatedString ProcessStatisticsReader::username_from_uid(uid_t uid)
|
||||
ByteString ProcessStatisticsReader::username_from_uid(uid_t uid)
|
||||
{
|
||||
if (s_usernames.is_empty()) {
|
||||
setpwent();
|
||||
|
@ -107,6 +107,6 @@ DeprecatedString ProcessStatisticsReader::username_from_uid(uid_t uid)
|
|||
auto it = s_usernames.find(uid);
|
||||
if (it != s_usernames.end())
|
||||
return (*it).value;
|
||||
return DeprecatedString::number(uid);
|
||||
return ByteString::number(uid);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Time.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <unistd.h>
|
||||
|
@ -28,10 +28,10 @@ struct ThreadStatistics {
|
|||
u64 ipv4_socket_write_bytes;
|
||||
u64 file_read_bytes;
|
||||
u64 file_write_bytes;
|
||||
DeprecatedString state;
|
||||
ByteString state;
|
||||
u32 cpu;
|
||||
u32 priority;
|
||||
DeprecatedString name;
|
||||
ByteString name;
|
||||
};
|
||||
|
||||
struct ProcessStatistics {
|
||||
|
@ -45,11 +45,11 @@ struct ProcessStatistics {
|
|||
gid_t gid;
|
||||
pid_t ppid;
|
||||
bool kernel;
|
||||
DeprecatedString name;
|
||||
DeprecatedString executable;
|
||||
DeprecatedString tty;
|
||||
DeprecatedString pledge;
|
||||
DeprecatedString veil;
|
||||
ByteString name;
|
||||
ByteString executable;
|
||||
ByteString tty;
|
||||
ByteString pledge;
|
||||
ByteString veil;
|
||||
UnixDateTime creation_time;
|
||||
size_t amount_virtual;
|
||||
size_t amount_resident;
|
||||
|
@ -62,7 +62,7 @@ struct ProcessStatistics {
|
|||
Vector<Core::ThreadStatistics> threads;
|
||||
|
||||
// synthetic
|
||||
DeprecatedString username;
|
||||
ByteString username;
|
||||
};
|
||||
|
||||
struct AllProcessesStatistics {
|
||||
|
@ -77,8 +77,8 @@ public:
|
|||
static ErrorOr<AllProcessesStatistics> get_all(bool include_usernames = true);
|
||||
|
||||
private:
|
||||
static DeprecatedString username_from_uid(uid_t);
|
||||
static HashMap<uid_t, DeprecatedString> s_usernames;
|
||||
static ByteString username_from_uid(uid_t);
|
||||
static HashMap<uid_t, ByteString> s_usernames;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -72,9 +72,9 @@ Vector<String> ResourceImplementation::child_names(Resource const& resource)
|
|||
VERIFY(resource.m_scheme == Resource::Scheme::File);
|
||||
|
||||
Vector<String> children;
|
||||
Core::DirIterator it(resource.filesystem_path().to_deprecated_string(), Core::DirIterator::SkipParentAndBaseDir);
|
||||
Core::DirIterator it(resource.filesystem_path().to_byte_string(), Core::DirIterator::SkipParentAndBaseDir);
|
||||
while (it.has_next())
|
||||
children.append(MUST(String::from_deprecated_string(it.next_path())));
|
||||
children.append(MUST(String::from_byte_string(it.next_path())));
|
||||
|
||||
return children;
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ ErrorOr<NonnullRefPtr<Resource>> ResourceImplementationFile::load_from_resource_
|
|||
VERIFY(uri.starts_with(resource_scheme));
|
||||
|
||||
auto path = TRY(String::from_utf8(uri.substring_view(resource_scheme.length())));
|
||||
auto full_path = TRY(String::from_deprecated_string(LexicalPath::join(m_base_directory, path).string()));
|
||||
auto full_path = TRY(String::from_byte_string(LexicalPath::join(m_base_directory, path).string()));
|
||||
if (is_directory(full_path))
|
||||
return make_directory_resource(move(path));
|
||||
|
||||
|
@ -34,16 +34,16 @@ ErrorOr<NonnullRefPtr<Resource>> ResourceImplementationFile::load_from_resource_
|
|||
Vector<String> ResourceImplementationFile::child_names_for_resource_scheme(Resource const& resource)
|
||||
{
|
||||
Vector<String> children;
|
||||
Core::DirIterator it(resource.filesystem_path().to_deprecated_string(), Core::DirIterator::SkipParentAndBaseDir);
|
||||
Core::DirIterator it(resource.filesystem_path().to_byte_string(), Core::DirIterator::SkipParentAndBaseDir);
|
||||
while (it.has_next())
|
||||
children.append(MUST(String::from_deprecated_string(it.next_path())));
|
||||
children.append(MUST(String::from_byte_string(it.next_path())));
|
||||
|
||||
return children;
|
||||
}
|
||||
|
||||
String ResourceImplementationFile::filesystem_path_for_resource_scheme(String const& relative_path)
|
||||
{
|
||||
return MUST(String::from_deprecated_string(LexicalPath::join(m_base_directory, relative_path).string()));
|
||||
return MUST(String::from_byte_string(LexicalPath::join(m_base_directory, relative_path).string()));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ ErrorOr<Reply> send_connect_request_message(Core::Socket& socket, Core::SOCKSPro
|
|||
TRY(stream.write_value(header));
|
||||
|
||||
TRY(target.visit(
|
||||
[&](DeprecatedString const& hostname) -> ErrorOr<void> {
|
||||
[&](ByteString const& hostname) -> ErrorOr<void> {
|
||||
u8 address_data[2];
|
||||
address_data[0] = to_underlying(AddressType::DomainName);
|
||||
address_data[1] = hostname.length();
|
||||
|
@ -298,7 +298,7 @@ ErrorOr<NonnullOwnPtr<SOCKSProxyClient>> SOCKSProxyClient::connect(HostOrIPV4 co
|
|||
[&](u32 ipv4) {
|
||||
return Core::TCPSocket::connect({ IPv4Address(ipv4), static_cast<u16>(server_port) });
|
||||
},
|
||||
[&](DeprecatedString const& hostname) {
|
||||
[&](ByteString const& hostname) {
|
||||
return Core::TCPSocket::connect(hostname, static_cast<u16>(server_port));
|
||||
}));
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ public:
|
|||
};
|
||||
|
||||
struct UsernamePasswordAuthenticationData {
|
||||
DeprecatedString username;
|
||||
DeprecatedString password;
|
||||
ByteString username;
|
||||
ByteString password;
|
||||
};
|
||||
|
||||
enum class Command : u8 {
|
||||
|
@ -29,7 +29,7 @@ public:
|
|||
UDPAssociate = 0x03,
|
||||
};
|
||||
|
||||
using HostOrIPV4 = Variant<DeprecatedString, u32>;
|
||||
using HostOrIPV4 = Variant<ByteString, u32>;
|
||||
|
||||
static ErrorOr<NonnullOwnPtr<SOCKSProxyClient>> connect(Socket& underlying, Version, HostOrIPV4 const& target, int target_port, Variant<UsernamePasswordAuthenticationData, Empty> const& auth_data = {}, Command = Command::Connect);
|
||||
static ErrorOr<NonnullOwnPtr<SOCKSProxyClient>> connect(HostOrIPV4 const& server, int server_port, Version, HostOrIPV4 const& target, int target_port, Variant<UsernamePasswordAuthenticationData, Empty> const& auth_data = {}, Command = Command::Connect);
|
||||
|
|
|
@ -34,19 +34,19 @@ ErrorOr<void> logout(Optional<pid_t> force_sid)
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<DeprecatedString> parse_path_with_sid(StringView general_path, Optional<pid_t> force_sid)
|
||||
ErrorOr<ByteString> parse_path_with_sid(StringView general_path, Optional<pid_t> force_sid)
|
||||
{
|
||||
if (general_path.contains("%sid"sv)) {
|
||||
pid_t sid = TRY(root_session_id(force_sid));
|
||||
return general_path.replace("%sid"sv, DeprecatedString::number(sid), ReplaceMode::All);
|
||||
return general_path.replace("%sid"sv, ByteString::number(sid), ReplaceMode::All);
|
||||
}
|
||||
return DeprecatedString(general_path);
|
||||
return ByteString(general_path);
|
||||
}
|
||||
|
||||
ErrorOr<void> create_session_temporary_directory_if_needed(uid_t uid, gid_t gid, Optional<pid_t> force_sid)
|
||||
{
|
||||
pid_t sid = TRY(root_session_id(force_sid));
|
||||
auto const temporary_directory = DeprecatedString::formatted("/tmp/session/{}", sid);
|
||||
auto const temporary_directory = ByteString::formatted("/tmp/session/{}", sid);
|
||||
auto directory = TRY(Core::Directory::create(temporary_directory, Core::Directory::CreateDirectories::Yes));
|
||||
TRY(directory.chown(uid, gid));
|
||||
return {};
|
||||
|
|
|
@ -14,7 +14,7 @@ namespace Core::SessionManagement {
|
|||
ErrorOr<pid_t> root_session_id(Optional<pid_t> force_sid = {});
|
||||
ErrorOr<void> logout(Optional<pid_t> force_sid = {});
|
||||
|
||||
ErrorOr<DeprecatedString> parse_path_with_sid(StringView general_path, Optional<pid_t> force_sid = {});
|
||||
ErrorOr<ByteString> parse_path_with_sid(StringView general_path, Optional<pid_t> force_sid = {});
|
||||
ErrorOr<void> create_session_temporary_directory_if_needed(uid_t uid, gid_t gid, Optional<pid_t> force_sid = {});
|
||||
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
#include <AK/Assertions.h>
|
||||
#include <AK/Atomic.h>
|
||||
#include <AK/BuiltinWrappers.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/Function.h>
|
||||
|
@ -200,7 +200,7 @@ private:
|
|||
|
||||
static ErrorOr<SharedSingleProducerCircularQueue<T, Size>> create_internal(int fd, bool is_new)
|
||||
{
|
||||
auto name = DeprecatedString::formatted("SharedSingleProducerCircularQueue@{:x}", fd);
|
||||
auto name = ByteString::formatted("SharedSingleProducerCircularQueue@{:x}", fd);
|
||||
auto* raw_mapping = TRY(System::mmap(nullptr, sizeof(SharedMemorySPCQ), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0, 0, name));
|
||||
dbgln_if(SHARED_QUEUE_DEBUG, "successfully mmapped {} at {:p}", name, raw_mapping);
|
||||
|
||||
|
@ -212,7 +212,7 @@ private:
|
|||
return SharedSingleProducerCircularQueue<T, Size> { move(name), adopt_ref(*new (nothrow) RefCountedSharedMemorySPCQ(shared_queue, fd)) };
|
||||
}
|
||||
|
||||
SharedSingleProducerCircularQueue(DeprecatedString name, RefPtr<RefCountedSharedMemorySPCQ> queue)
|
||||
SharedSingleProducerCircularQueue(ByteString name, RefPtr<RefCountedSharedMemorySPCQ> queue)
|
||||
: m_queue(queue)
|
||||
, m_name(move(name))
|
||||
{
|
||||
|
@ -220,7 +220,7 @@ private:
|
|||
|
||||
RefPtr<RefCountedSharedMemorySPCQ> m_queue;
|
||||
|
||||
DeprecatedString m_name {};
|
||||
ByteString m_name {};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ ErrorOr<int> Socket::create_fd(SocketDomain domain, SocketType type)
|
|||
#endif
|
||||
}
|
||||
|
||||
ErrorOr<IPv4Address> Socket::resolve_host(DeprecatedString const& host, SocketType type)
|
||||
ErrorOr<IPv4Address> Socket::resolve_host(ByteString const& host, SocketType type)
|
||||
{
|
||||
int socket_type;
|
||||
switch (type) {
|
||||
|
@ -79,7 +79,7 @@ ErrorOr<IPv4Address> Socket::resolve_host(DeprecatedString const& host, SocketTy
|
|||
return Error::from_string_literal("Could not resolve to IPv4 address");
|
||||
}
|
||||
|
||||
ErrorOr<void> Socket::connect_local(int fd, DeprecatedString const& path)
|
||||
ErrorOr<void> Socket::connect_local(int fd, ByteString const& path)
|
||||
{
|
||||
auto address = SocketAddress::local(path);
|
||||
auto maybe_sockaddr = address.to_sockaddr_un();
|
||||
|
@ -189,7 +189,7 @@ void PosixSocketHelper::setup_notifier()
|
|||
m_notifier = Core::Notifier::construct(m_fd, Core::Notifier::Type::Read);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullOwnPtr<TCPSocket>> TCPSocket::connect(DeprecatedString const& host, u16 port)
|
||||
ErrorOr<NonnullOwnPtr<TCPSocket>> TCPSocket::connect(ByteString const& host, u16 port)
|
||||
{
|
||||
auto ip_address = TRY(resolve_host(host, SocketType::Stream));
|
||||
return connect(SocketAddress { ip_address, port });
|
||||
|
@ -231,7 +231,7 @@ ErrorOr<size_t> PosixSocketHelper::pending_bytes() const
|
|||
return static_cast<size_t>(value);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullOwnPtr<UDPSocket>> UDPSocket::connect(DeprecatedString const& host, u16 port, Optional<Duration> timeout)
|
||||
ErrorOr<NonnullOwnPtr<UDPSocket>> UDPSocket::connect(ByteString const& host, u16 port, Optional<Duration> timeout)
|
||||
{
|
||||
auto ip_address = TRY(resolve_host(host, SocketType::Datagram));
|
||||
return connect(SocketAddress { ip_address, port }, timeout);
|
||||
|
@ -253,7 +253,7 @@ ErrorOr<NonnullOwnPtr<UDPSocket>> UDPSocket::connect(SocketAddress const& addres
|
|||
return socket;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullOwnPtr<LocalSocket>> LocalSocket::connect(DeprecatedString const& path, PreventSIGPIPE prevent_sigpipe)
|
||||
ErrorOr<NonnullOwnPtr<LocalSocket>> LocalSocket::connect(ByteString const& path, PreventSIGPIPE prevent_sigpipe)
|
||||
{
|
||||
auto socket = TRY(adopt_nonnull_own_or_enomem(new (nothrow) LocalSocket(prevent_sigpipe)));
|
||||
|
||||
|
|
|
@ -72,9 +72,9 @@ protected:
|
|||
static ErrorOr<int> create_fd(SocketDomain, SocketType);
|
||||
// FIXME: This will need to be updated when IPv6 socket arrives. Perhaps a
|
||||
// base class for all address types is appropriate.
|
||||
static ErrorOr<IPv4Address> resolve_host(DeprecatedString const&, SocketType);
|
||||
static ErrorOr<IPv4Address> resolve_host(ByteString const&, SocketType);
|
||||
|
||||
static ErrorOr<void> connect_local(int fd, DeprecatedString const& path);
|
||||
static ErrorOr<void> connect_local(int fd, ByteString const& path);
|
||||
static ErrorOr<void> connect_inet(int fd, SocketAddress const&);
|
||||
|
||||
int default_flags() const
|
||||
|
@ -97,7 +97,7 @@ public:
|
|||
virtual bool is_connected() = 0;
|
||||
/// Reconnects the socket to the given host and port. Returns EALREADY if
|
||||
/// is_connected() is true.
|
||||
virtual ErrorOr<void> reconnect(DeprecatedString const& host, u16 port) = 0;
|
||||
virtual ErrorOr<void> reconnect(ByteString const& host, u16 port) = 0;
|
||||
/// Connects the socket to the given socket address (IP address + port).
|
||||
/// Returns EALREADY is_connected() is true.
|
||||
virtual ErrorOr<void> reconnect(SocketAddress const&) = 0;
|
||||
|
@ -154,7 +154,7 @@ private:
|
|||
|
||||
class TCPSocket final : public Socket {
|
||||
public:
|
||||
static ErrorOr<NonnullOwnPtr<TCPSocket>> connect(DeprecatedString const& host, u16 port);
|
||||
static ErrorOr<NonnullOwnPtr<TCPSocket>> connect(ByteString const& host, u16 port);
|
||||
static ErrorOr<NonnullOwnPtr<TCPSocket>> connect(SocketAddress const& address);
|
||||
static ErrorOr<NonnullOwnPtr<TCPSocket>> adopt_fd(int fd);
|
||||
|
||||
|
@ -215,7 +215,7 @@ private:
|
|||
|
||||
class UDPSocket final : public Socket {
|
||||
public:
|
||||
static ErrorOr<NonnullOwnPtr<UDPSocket>> connect(DeprecatedString const& host, u16 port, Optional<Duration> timeout = {});
|
||||
static ErrorOr<NonnullOwnPtr<UDPSocket>> connect(ByteString const& host, u16 port, Optional<Duration> timeout = {});
|
||||
static ErrorOr<NonnullOwnPtr<UDPSocket>> connect(SocketAddress const& address, Optional<Duration> timeout = {});
|
||||
|
||||
UDPSocket(UDPSocket&& other)
|
||||
|
@ -289,7 +289,7 @@ private:
|
|||
|
||||
class LocalSocket final : public Socket {
|
||||
public:
|
||||
static ErrorOr<NonnullOwnPtr<LocalSocket>> connect(DeprecatedString const& path, PreventSIGPIPE = PreventSIGPIPE::No);
|
||||
static ErrorOr<NonnullOwnPtr<LocalSocket>> connect(ByteString const& path, PreventSIGPIPE = PreventSIGPIPE::No);
|
||||
static ErrorOr<NonnullOwnPtr<LocalSocket>> adopt_fd(int fd, PreventSIGPIPE = PreventSIGPIPE::No);
|
||||
|
||||
LocalSocket(LocalSocket&& other)
|
||||
|
@ -450,7 +450,7 @@ using BufferedLocalSocket = BufferedSocket<LocalSocket>;
|
|||
template<SocketLike T>
|
||||
class BasicReusableSocket final : public ReusableSocket {
|
||||
public:
|
||||
static ErrorOr<NonnullOwnPtr<BasicReusableSocket<T>>> connect(DeprecatedString const& host, u16 port)
|
||||
static ErrorOr<NonnullOwnPtr<BasicReusableSocket<T>>> connect(ByteString const& host, u16 port)
|
||||
{
|
||||
return make<BasicReusableSocket<T>>(TRY(T::connect(host, port)));
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ public:
|
|||
return m_socket.is_open();
|
||||
}
|
||||
|
||||
virtual ErrorOr<void> reconnect(DeprecatedString const& host, u16 port) override
|
||||
virtual ErrorOr<void> reconnect(ByteString const& host, u16 port) override
|
||||
{
|
||||
if (is_connected())
|
||||
return Error::from_errno(EALREADY);
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
static SocketAddress local(DeprecatedString const& address)
|
||||
static SocketAddress local(ByteString const& address)
|
||||
{
|
||||
SocketAddress addr;
|
||||
addr.m_type = Type::Local;
|
||||
|
@ -51,11 +51,11 @@ public:
|
|||
IPv4Address ipv4_address() const { return m_ipv4_address; }
|
||||
u16 port() const { return m_port; }
|
||||
|
||||
DeprecatedString to_deprecated_string() const
|
||||
ByteString to_byte_string() const
|
||||
{
|
||||
switch (m_type) {
|
||||
case Type::IPv4:
|
||||
return DeprecatedString::formatted("{}:{}", m_ipv4_address, m_port);
|
||||
return ByteString::formatted("{}:{}", m_ipv4_address, m_port);
|
||||
case Type::Local:
|
||||
return m_local_address;
|
||||
default:
|
||||
|
@ -91,16 +91,16 @@ private:
|
|||
Type m_type { Type::Invalid };
|
||||
IPv4Address m_ipv4_address;
|
||||
u16 m_port { 0 };
|
||||
DeprecatedString m_local_address;
|
||||
ByteString m_local_address;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<Core::SocketAddress> : Formatter<DeprecatedString> {
|
||||
struct AK::Formatter<Core::SocketAddress> : Formatter<ByteString> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Core::SocketAddress const& value)
|
||||
{
|
||||
return Formatter<DeprecatedString>::format(builder, value.to_deprecated_string());
|
||||
return Formatter<ByteString>::format(builder, value.to_byte_string());
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/Platform.h>
|
||||
#include <AK/String.h>
|
||||
|
@ -22,42 +22,42 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
DeprecatedString StandardPaths::home_directory()
|
||||
ByteString StandardPaths::home_directory()
|
||||
{
|
||||
if (auto* home_env = getenv("HOME"))
|
||||
return LexicalPath::canonicalized_path(home_env);
|
||||
|
||||
auto* pwd = getpwuid(getuid());
|
||||
DeprecatedString path = pwd ? pwd->pw_dir : "/";
|
||||
ByteString path = pwd ? pwd->pw_dir : "/";
|
||||
endpwent();
|
||||
return LexicalPath::canonicalized_path(path);
|
||||
}
|
||||
|
||||
DeprecatedString StandardPaths::desktop_directory()
|
||||
ByteString StandardPaths::desktop_directory()
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(home_directory());
|
||||
builder.append("/Desktop"sv);
|
||||
return LexicalPath::canonicalized_path(builder.to_deprecated_string());
|
||||
return LexicalPath::canonicalized_path(builder.to_byte_string());
|
||||
}
|
||||
|
||||
DeprecatedString StandardPaths::documents_directory()
|
||||
ByteString StandardPaths::documents_directory()
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(home_directory());
|
||||
builder.append("/Documents"sv);
|
||||
return LexicalPath::canonicalized_path(builder.to_deprecated_string());
|
||||
return LexicalPath::canonicalized_path(builder.to_byte_string());
|
||||
}
|
||||
|
||||
DeprecatedString StandardPaths::downloads_directory()
|
||||
ByteString StandardPaths::downloads_directory()
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(home_directory());
|
||||
builder.append("/Downloads"sv);
|
||||
return LexicalPath::canonicalized_path(builder.to_deprecated_string());
|
||||
return LexicalPath::canonicalized_path(builder.to_byte_string());
|
||||
}
|
||||
|
||||
DeprecatedString StandardPaths::config_directory()
|
||||
ByteString StandardPaths::config_directory()
|
||||
{
|
||||
if (auto* config_directory = getenv("XDG_CONFIG_HOME"))
|
||||
return LexicalPath::canonicalized_path(config_directory);
|
||||
|
@ -71,10 +71,10 @@ DeprecatedString StandardPaths::config_directory()
|
|||
#else
|
||||
builder.append("/.config"sv);
|
||||
#endif
|
||||
return LexicalPath::canonicalized_path(builder.to_deprecated_string());
|
||||
return LexicalPath::canonicalized_path(builder.to_byte_string());
|
||||
}
|
||||
|
||||
DeprecatedString StandardPaths::data_directory()
|
||||
ByteString StandardPaths::data_directory()
|
||||
{
|
||||
if (auto* data_directory = getenv("XDG_DATA_HOME"))
|
||||
return LexicalPath::canonicalized_path(data_directory);
|
||||
|
@ -91,10 +91,10 @@ DeprecatedString StandardPaths::data_directory()
|
|||
builder.append("/.local/share"sv);
|
||||
#endif
|
||||
|
||||
return LexicalPath::canonicalized_path(builder.to_deprecated_string());
|
||||
return LexicalPath::canonicalized_path(builder.to_byte_string());
|
||||
}
|
||||
|
||||
ErrorOr<DeprecatedString> StandardPaths::runtime_directory()
|
||||
ErrorOr<ByteString> StandardPaths::runtime_directory()
|
||||
{
|
||||
if (auto* data_directory = getenv("XDG_RUNTIME_DIR"))
|
||||
return LexicalPath::canonicalized_path(data_directory);
|
||||
|
@ -114,10 +114,10 @@ ErrorOr<DeprecatedString> StandardPaths::runtime_directory()
|
|||
builder.appendff("/run/user/{}", uid);
|
||||
#endif
|
||||
|
||||
return LexicalPath::canonicalized_path(builder.to_deprecated_string());
|
||||
return LexicalPath::canonicalized_path(builder.to_byte_string());
|
||||
}
|
||||
|
||||
DeprecatedString StandardPaths::tempfile_directory()
|
||||
ByteString StandardPaths::tempfile_directory()
|
||||
{
|
||||
return "/tmp";
|
||||
}
|
||||
|
|
|
@ -14,14 +14,14 @@ namespace Core {
|
|||
|
||||
class StandardPaths {
|
||||
public:
|
||||
static DeprecatedString home_directory();
|
||||
static DeprecatedString desktop_directory();
|
||||
static DeprecatedString documents_directory();
|
||||
static DeprecatedString downloads_directory();
|
||||
static DeprecatedString tempfile_directory();
|
||||
static DeprecatedString config_directory();
|
||||
static DeprecatedString data_directory();
|
||||
static ErrorOr<DeprecatedString> runtime_directory();
|
||||
static ByteString home_directory();
|
||||
static ByteString desktop_directory();
|
||||
static ByteString documents_directory();
|
||||
static ByteString downloads_directory();
|
||||
static ByteString tempfile_directory();
|
||||
static ByteString config_directory();
|
||||
static ByteString data_directory();
|
||||
static ErrorOr<ByteString> runtime_directory();
|
||||
static ErrorOr<Vector<String>> font_directories();
|
||||
};
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ByteString.h>
|
||||
#include <AK/FixedArray.h>
|
||||
#include <AK/ScopeGuard.h>
|
||||
#include <AK/ScopedValueRollback.h>
|
||||
|
@ -202,7 +202,7 @@ ErrorOr<void> unveil(StringView path, StringView permissions)
|
|||
{ nullptr, 0 },
|
||||
};
|
||||
|
||||
DeprecatedString parsed_path;
|
||||
ByteString parsed_path;
|
||||
if (!path.is_null()) {
|
||||
parsed_path = TRY(Core::SessionManagement::parse_path_with_sid(path));
|
||||
params.path = { parsed_path.characters(), parsed_path.length() };
|
||||
|
@ -215,7 +215,7 @@ ErrorOr<void> unveil(StringView path, StringView permissions)
|
|||
|
||||
ErrorOr<void> unveil_after_exec(StringView path, StringView permissions)
|
||||
{
|
||||
DeprecatedString parsed_path;
|
||||
ByteString parsed_path;
|
||||
Syscall::SC_unveil_params params {
|
||||
static_cast<int>(UnveilFlags::AfterExec),
|
||||
{ nullptr, 0 },
|
||||
|
@ -448,7 +448,7 @@ ErrorOr<struct stat> fstatat(int fd, StringView path, int flags)
|
|||
Syscall::SC_stat_params params { { path.characters_without_null_termination(), path.length() }, &st, fd, !(flags & AT_SYMLINK_NOFOLLOW) };
|
||||
int rc = syscall(SC_stat, ¶ms);
|
||||
#else
|
||||
DeprecatedString path_string = path;
|
||||
ByteString path_string = path;
|
||||
int rc = ::fstatat(fd, path_string.characters(), &st, flags);
|
||||
#endif
|
||||
HANDLE_SYSCALL_RETURN_VALUE("fstatat", rc, st);
|
||||
|
@ -531,7 +531,7 @@ ErrorOr<int> anon_create([[maybe_unused]] size_t size, [[maybe_unused]] int opti
|
|||
#elif defined(AK_OS_BSD_GENERIC) || defined(AK_OS_EMSCRIPTEN) || defined(AK_OS_HAIKU)
|
||||
struct timespec time;
|
||||
clock_gettime(CLOCK_REALTIME, &time);
|
||||
auto name = DeprecatedString::formatted("/shm-{}{}", (unsigned long)time.tv_sec, (unsigned long)time.tv_nsec);
|
||||
auto name = ByteString::formatted("/shm-{}{}", (unsigned long)time.tv_sec, (unsigned long)time.tv_nsec);
|
||||
fd = shm_open(name.characters(), O_RDWR | O_CREAT | options, 0600);
|
||||
|
||||
if (shm_unlink(name.characters()) == -1) {
|
||||
|
@ -576,7 +576,7 @@ ErrorOr<int> openat(int fd, StringView path, int options, mode_t mode)
|
|||
HANDLE_SYSCALL_RETURN_VALUE("open", rc, rc);
|
||||
#else
|
||||
// NOTE: We have to ensure that the path is null-terminated.
|
||||
DeprecatedString path_string = path;
|
||||
ByteString path_string = path;
|
||||
int rc = ::openat(fd, path_string.characters(), options, mode);
|
||||
if (rc < 0)
|
||||
return Error::from_syscall("open"sv, -errno);
|
||||
|
@ -609,7 +609,7 @@ ErrorOr<struct stat> stat(StringView path)
|
|||
int rc = syscall(SC_stat, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("stat", rc, st);
|
||||
#else
|
||||
DeprecatedString path_string = path;
|
||||
ByteString path_string = path;
|
||||
if (::stat(path_string.characters(), &st) < 0)
|
||||
return Error::from_syscall("stat"sv, -errno);
|
||||
return st;
|
||||
|
@ -627,7 +627,7 @@ ErrorOr<struct stat> lstat(StringView path)
|
|||
int rc = syscall(SC_stat, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("lstat", rc, st);
|
||||
#else
|
||||
DeprecatedString path_string = path;
|
||||
ByteString path_string = path;
|
||||
if (::lstat(path_string.characters(), &st) < 0)
|
||||
return Error::from_syscall("lstat"sv, -errno);
|
||||
return st;
|
||||
|
@ -680,21 +680,21 @@ ErrorOr<int> dup2(int source_fd, int destination_fd)
|
|||
return fd;
|
||||
}
|
||||
|
||||
ErrorOr<DeprecatedString> ptsname(int fd)
|
||||
ErrorOr<ByteString> ptsname(int fd)
|
||||
{
|
||||
auto* name = ::ptsname(fd);
|
||||
if (!name)
|
||||
return Error::from_syscall("ptsname"sv, -errno);
|
||||
return DeprecatedString(name);
|
||||
return ByteString(name);
|
||||
}
|
||||
|
||||
ErrorOr<DeprecatedString> gethostname()
|
||||
ErrorOr<ByteString> gethostname()
|
||||
{
|
||||
char hostname[HOST_NAME_MAX];
|
||||
int rc = ::gethostname(hostname, sizeof(hostname));
|
||||
if (rc < 0)
|
||||
return Error::from_syscall("gethostname"sv, -errno);
|
||||
return DeprecatedString(&hostname[0]);
|
||||
return ByteString(&hostname[0]);
|
||||
}
|
||||
|
||||
ErrorOr<void> sethostname(StringView hostname)
|
||||
|
@ -709,13 +709,13 @@ ErrorOr<void> sethostname(StringView hostname)
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<DeprecatedString> getcwd()
|
||||
ErrorOr<ByteString> getcwd()
|
||||
{
|
||||
auto* cwd = ::getcwd(nullptr, 0);
|
||||
if (!cwd)
|
||||
return Error::from_syscall("getcwd"sv, -errno);
|
||||
|
||||
DeprecatedString string_cwd(cwd);
|
||||
ByteString string_cwd(cwd);
|
||||
free(cwd);
|
||||
return string_cwd;
|
||||
}
|
||||
|
@ -773,7 +773,7 @@ ErrorOr<void> chmod(StringView pathname, mode_t mode)
|
|||
int rc = syscall(SC_chmod, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("chmod", rc, {});
|
||||
#else
|
||||
DeprecatedString path = pathname;
|
||||
ByteString path = pathname;
|
||||
if (::chmod(path.characters(), mode) < 0)
|
||||
return Error::from_syscall("chmod"sv, -errno);
|
||||
return {};
|
||||
|
@ -804,7 +804,7 @@ ErrorOr<void> lchown(StringView pathname, uid_t uid, gid_t gid)
|
|||
int rc = syscall(SC_chown, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("chown", rc, {});
|
||||
#else
|
||||
DeprecatedString path = pathname;
|
||||
ByteString path = pathname;
|
||||
if (::chown(path.characters(), uid, gid) < 0)
|
||||
return Error::from_syscall("chown"sv, -errno);
|
||||
return {};
|
||||
|
@ -821,7 +821,7 @@ ErrorOr<void> chown(StringView pathname, uid_t uid, gid_t gid)
|
|||
int rc = syscall(SC_chown, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("chown", rc, {});
|
||||
#else
|
||||
DeprecatedString path = pathname;
|
||||
ByteString path = pathname;
|
||||
if (::lchown(path.characters(), uid, gid) < 0)
|
||||
return Error::from_syscall("lchown"sv, -errno);
|
||||
return {};
|
||||
|
@ -913,7 +913,7 @@ ErrorOr<void> clock_settime(clockid_t clock_id, struct timespec* ts)
|
|||
static ALWAYS_INLINE ErrorOr<pid_t> posix_spawn_wrapper(StringView path, posix_spawn_file_actions_t const* file_actions, posix_spawnattr_t const* attr, char* const arguments[], char* const envp[], StringView function_name, decltype(::posix_spawn) spawn_function)
|
||||
{
|
||||
pid_t child_pid;
|
||||
if ((errno = spawn_function(&child_pid, path.to_deprecated_string().characters(), file_actions, attr, arguments, envp)))
|
||||
if ((errno = spawn_function(&child_pid, path.to_byte_string().characters(), file_actions, attr, arguments, envp)))
|
||||
return Error::from_syscall(function_name, -errno);
|
||||
return child_pid;
|
||||
}
|
||||
|
@ -1036,8 +1036,8 @@ ErrorOr<void> link(StringView old_path, StringView new_path)
|
|||
int rc = syscall(SC_link, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("link", rc, {});
|
||||
#else
|
||||
DeprecatedString old_path_string = old_path;
|
||||
DeprecatedString new_path_string = new_path;
|
||||
ByteString old_path_string = old_path;
|
||||
ByteString new_path_string = new_path;
|
||||
if (::link(old_path_string.characters(), new_path_string.characters()) < 0)
|
||||
return Error::from_syscall("link"sv, -errno);
|
||||
return {};
|
||||
|
@ -1055,8 +1055,8 @@ ErrorOr<void> symlink(StringView target, StringView link_path)
|
|||
int rc = syscall(SC_symlink, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("symlink", rc, {});
|
||||
#else
|
||||
DeprecatedString target_string = target;
|
||||
DeprecatedString link_path_string = link_path;
|
||||
ByteString target_string = target;
|
||||
ByteString link_path_string = link_path;
|
||||
if (::symlink(target_string.characters(), link_path_string.characters()) < 0)
|
||||
return Error::from_syscall("symlink"sv, -errno);
|
||||
return {};
|
||||
|
@ -1071,7 +1071,7 @@ ErrorOr<void> mkdir(StringView path, mode_t mode)
|
|||
int rc = syscall(SC_mkdir, AT_FDCWD, path.characters_without_null_termination(), path.length(), mode);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("mkdir", rc, {});
|
||||
#else
|
||||
DeprecatedString path_string = path;
|
||||
ByteString path_string = path;
|
||||
if (::mkdir(path_string.characters(), mode) < 0)
|
||||
return Error::from_syscall("mkdir"sv, -errno);
|
||||
return {};
|
||||
|
@ -1086,7 +1086,7 @@ ErrorOr<void> chdir(StringView path)
|
|||
int rc = syscall(SC_chdir, path.characters_without_null_termination(), path.length());
|
||||
HANDLE_SYSCALL_RETURN_VALUE("chdir", rc, {});
|
||||
#else
|
||||
DeprecatedString path_string = path;
|
||||
ByteString path_string = path;
|
||||
if (::chdir(path_string.characters()) < 0)
|
||||
return Error::from_syscall("chdir"sv, -errno);
|
||||
return {};
|
||||
|
@ -1101,7 +1101,7 @@ ErrorOr<void> rmdir(StringView path)
|
|||
int rc = syscall(SC_rmdir, path.characters_without_null_termination(), path.length());
|
||||
HANDLE_SYSCALL_RETURN_VALUE("rmdir", rc, {});
|
||||
#else
|
||||
DeprecatedString path_string = path;
|
||||
ByteString path_string = path;
|
||||
if (::rmdir(path_string.characters()) < 0)
|
||||
return Error::from_syscall("rmdir"sv, -errno);
|
||||
return {};
|
||||
|
@ -1149,8 +1149,8 @@ ErrorOr<void> rename(StringView old_path, StringView new_path)
|
|||
int rc = syscall(SC_rename, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("rename", rc, {});
|
||||
#else
|
||||
DeprecatedString old_path_string = old_path;
|
||||
DeprecatedString new_path_string = new_path;
|
||||
ByteString old_path_string = old_path;
|
||||
ByteString new_path_string = new_path;
|
||||
if (::rename(old_path_string.characters(), new_path_string.characters()) < 0)
|
||||
return Error::from_syscall("rename"sv, -errno);
|
||||
return {};
|
||||
|
@ -1166,7 +1166,7 @@ ErrorOr<void> unlink(StringView path)
|
|||
int rc = syscall(SC_unlink, AT_FDCWD, path.characters_without_null_termination(), path.length(), 0);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("unlink", rc, {});
|
||||
#else
|
||||
DeprecatedString path_string = path;
|
||||
ByteString path_string = path;
|
||||
if (::unlink(path_string.characters()) < 0)
|
||||
return Error::from_syscall("unlink"sv, -errno);
|
||||
return {};
|
||||
|
@ -1185,7 +1185,7 @@ ErrorOr<void> utime(StringView path, Optional<struct utimbuf> maybe_buf)
|
|||
int rc = syscall(SC_utime, path.characters_without_null_termination(), path.length(), buf);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("utime", rc, {});
|
||||
#else
|
||||
DeprecatedString path_string = path;
|
||||
ByteString path_string = path;
|
||||
if (::utime(path_string.characters(), buf) < 0)
|
||||
return Error::from_syscall("utime"sv, -errno);
|
||||
return {};
|
||||
|
@ -1364,22 +1364,22 @@ ErrorOr<void> exec(StringView filename, ReadonlySpan<StringView> arguments, Sear
|
|||
TRY(run_exec(params));
|
||||
VERIFY_NOT_REACHED();
|
||||
#else
|
||||
DeprecatedString filename_string { filename };
|
||||
ByteString filename_string { filename };
|
||||
|
||||
auto argument_strings = TRY(FixedArray<DeprecatedString>::create(arguments.size()));
|
||||
auto argument_strings = TRY(FixedArray<ByteString>::create(arguments.size()));
|
||||
auto argv = TRY(FixedArray<char*>::create(arguments.size() + 1));
|
||||
for (size_t i = 0; i < arguments.size(); ++i) {
|
||||
argument_strings[i] = arguments[i].to_deprecated_string();
|
||||
argument_strings[i] = arguments[i].to_byte_string();
|
||||
argv[i] = const_cast<char*>(argument_strings[i].characters());
|
||||
}
|
||||
argv[arguments.size()] = nullptr;
|
||||
|
||||
int rc = 0;
|
||||
if (environment.has_value()) {
|
||||
auto environment_strings = TRY(FixedArray<DeprecatedString>::create(environment->size()));
|
||||
auto environment_strings = TRY(FixedArray<ByteString>::create(environment->size()));
|
||||
auto envp = TRY(FixedArray<char*>::create(environment->size() + 1));
|
||||
for (size_t i = 0; i < environment->size(); ++i) {
|
||||
environment_strings[i] = environment->at(i).to_deprecated_string();
|
||||
environment_strings[i] = environment->at(i).to_byte_string();
|
||||
envp[i] = const_cast<char*>(environment_strings[i].characters());
|
||||
}
|
||||
envp[environment->size()] = nullptr;
|
||||
|
@ -1396,7 +1396,7 @@ ErrorOr<void> exec(StringView filename, ReadonlySpan<StringView> arguments, Sear
|
|||
return executable_or_error.release_error();
|
||||
}
|
||||
|
||||
DeprecatedString executable = executable_or_error.release_value().to_deprecated_string();
|
||||
ByteString executable = executable_or_error.release_value().to_byte_string();
|
||||
rc = ::execve(executable.characters(), argv.data(), envp.data());
|
||||
# else
|
||||
rc = ::execvpe(filename_string.characters(), argv.data(), envp.data());
|
||||
|
@ -1611,7 +1611,7 @@ ErrorOr<void> mknod(StringView pathname, mode_t mode, dev_t dev)
|
|||
int rc = syscall(SC_mknod, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("mknod", rc, {});
|
||||
#else
|
||||
DeprecatedString path_string = pathname;
|
||||
ByteString path_string = pathname;
|
||||
if (::mknod(path_string.characters(), mode, dev) < 0)
|
||||
return Error::from_syscall("mknod"sv, -errno);
|
||||
return {};
|
||||
|
@ -1705,7 +1705,7 @@ ErrorOr<void> access(StringView pathname, int mode, int flags)
|
|||
int rc = ::syscall(Syscall::SC_faccessat, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("access", rc, {});
|
||||
#else
|
||||
DeprecatedString path_string = pathname;
|
||||
ByteString path_string = pathname;
|
||||
(void)flags;
|
||||
if (::access(path_string.characters(), mode) < 0)
|
||||
return Error::from_syscall("access"sv, -errno);
|
||||
|
@ -1713,7 +1713,7 @@ ErrorOr<void> access(StringView pathname, int mode, int flags)
|
|||
#endif
|
||||
}
|
||||
|
||||
ErrorOr<DeprecatedString> readlink(StringView pathname)
|
||||
ErrorOr<ByteString> readlink(StringView pathname)
|
||||
{
|
||||
// FIXME: Try again with a larger buffer.
|
||||
#ifdef AK_OS_SERENITY
|
||||
|
@ -1724,7 +1724,7 @@ ErrorOr<DeprecatedString> readlink(StringView pathname)
|
|||
.dirfd = AT_FDCWD,
|
||||
};
|
||||
int rc = syscall(SC_readlink, &small_params);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("readlink", rc, DeprecatedString(data, rc));
|
||||
HANDLE_SYSCALL_RETURN_VALUE("readlink", rc, ByteString(data, rc));
|
||||
#elif defined(AK_OS_GNU_HURD)
|
||||
// PATH_MAX is not defined, nor is there an upper limit on path lengths.
|
||||
// Let's do this the right way.
|
||||
|
@ -1732,15 +1732,15 @@ ErrorOr<DeprecatedString> readlink(StringView pathname)
|
|||
auto file = TRY(File::adopt_fd(fd, File::OpenMode::Read));
|
||||
auto buffer = TRY(file->read_until_eof());
|
||||
// TODO: Get rid of this copy here.
|
||||
return DeprecatedString::copy(buffer);
|
||||
return ByteString::copy(buffer);
|
||||
#else
|
||||
char data[PATH_MAX];
|
||||
DeprecatedString path_string = pathname;
|
||||
ByteString path_string = pathname;
|
||||
int rc = ::readlink(path_string.characters(), data, sizeof(data));
|
||||
if (rc == -1)
|
||||
return Error::from_syscall("readlink"sv, -errno);
|
||||
|
||||
return DeprecatedString(data, rc);
|
||||
return ByteString(data, rc);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -1806,7 +1806,7 @@ char** environment()
|
|||
#endif
|
||||
}
|
||||
|
||||
ErrorOr<DeprecatedString> current_executable_path()
|
||||
ErrorOr<ByteString> current_executable_path()
|
||||
{
|
||||
char path[4096] = {};
|
||||
#if defined(AK_OS_LINUX) || defined(AK_OS_ANDROID) || defined(AK_OS_SERENITY)
|
||||
|
@ -1862,7 +1862,7 @@ ErrorOr<DeprecatedString> current_executable_path()
|
|||
return Error::from_string_view("current_executable_path unknown"sv);
|
||||
#endif
|
||||
path[sizeof(path) - 1] = '\0';
|
||||
return DeprecatedString { path, strlen(path) };
|
||||
return ByteString { path, strlen(path) };
|
||||
}
|
||||
|
||||
ErrorOr<Bytes> allocate(size_t count, size_t size)
|
||||
|
|
|
@ -135,10 +135,10 @@ ErrorOr<void> kill(pid_t, int signal);
|
|||
ErrorOr<void> killpg(int pgrp, int signal);
|
||||
ErrorOr<int> dup(int source_fd);
|
||||
ErrorOr<int> dup2(int source_fd, int destination_fd);
|
||||
ErrorOr<DeprecatedString> ptsname(int fd);
|
||||
ErrorOr<DeprecatedString> gethostname();
|
||||
ErrorOr<ByteString> ptsname(int fd);
|
||||
ErrorOr<ByteString> gethostname();
|
||||
ErrorOr<void> sethostname(StringView);
|
||||
ErrorOr<DeprecatedString> getcwd();
|
||||
ErrorOr<ByteString> getcwd();
|
||||
ErrorOr<void> ioctl(int fd, unsigned request, ...);
|
||||
ErrorOr<struct termios> tcgetattr(int fd);
|
||||
ErrorOr<void> tcsetattr(int fd, int optional_actions, struct termios const&);
|
||||
|
@ -235,7 +235,7 @@ ErrorOr<int> posix_openpt(int flags);
|
|||
ErrorOr<void> grantpt(int fildes);
|
||||
ErrorOr<void> unlockpt(int fildes);
|
||||
ErrorOr<void> access(StringView pathname, int mode, int flags = 0);
|
||||
ErrorOr<DeprecatedString> readlink(StringView pathname);
|
||||
ErrorOr<ByteString> readlink(StringView pathname);
|
||||
ErrorOr<int> poll(Span<struct pollfd>, int timeout);
|
||||
|
||||
#ifdef AK_OS_SERENITY
|
||||
|
@ -279,7 +279,7 @@ ErrorOr<String> resolve_executable_from_environment(StringView filename, int fla
|
|||
|
||||
char** environment();
|
||||
|
||||
ErrorOr<DeprecatedString> current_executable_path();
|
||||
ErrorOr<ByteString> current_executable_path();
|
||||
|
||||
ErrorOr<Bytes> allocate(size_t count, size_t size);
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
HashMap<DeprecatedString, int> s_overtaken_sockets {};
|
||||
HashMap<ByteString, int> s_overtaken_sockets {};
|
||||
bool s_overtaken_sockets_parsed { false };
|
||||
|
||||
static void parse_sockets_from_system_server()
|
||||
|
@ -27,7 +27,7 @@ static void parse_sockets_from_system_server()
|
|||
for (auto const socket : StringView { sockets, strlen(sockets) }.split_view(';')) {
|
||||
auto params = socket.split_view(':');
|
||||
VERIFY(params.size() == 2);
|
||||
s_overtaken_sockets.set(params[0].to_deprecated_string(), params[1].to_int().value());
|
||||
s_overtaken_sockets.set(params[0].to_byte_string(), params[1].to_int().value());
|
||||
}
|
||||
|
||||
s_overtaken_sockets_parsed = true;
|
||||
|
@ -36,7 +36,7 @@ static void parse_sockets_from_system_server()
|
|||
unsetenv(socket_takeover);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullOwnPtr<Core::LocalSocket>> take_over_socket_from_system_server(DeprecatedString const& socket_path)
|
||||
ErrorOr<NonnullOwnPtr<Core::LocalSocket>> take_over_socket_from_system_server(ByteString const& socket_path)
|
||||
{
|
||||
if (!s_overtaken_sockets_parsed)
|
||||
parse_sockets_from_system_server();
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
ErrorOr<NonnullOwnPtr<Core::LocalSocket>> take_over_socket_from_system_server(DeprecatedString const& socket_path = {});
|
||||
ErrorOr<NonnullOwnPtr<Core::LocalSocket>> take_over_socket_from_system_server(ByteString const& socket_path = {});
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue