mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:37:45 +00:00
AK+Everywhere: Rename String to DeprecatedString
We have a new, improved string type coming up in AK (OOM aware, no null state), and while it's going to use UTF-8, the name UTF8String is a mouthful - so let's free up the String name by renaming the existing class. Making the old one have an annoying name will hopefully also help with quick adoption :^)
This commit is contained in:
parent
f74251606d
commit
6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions
|
@ -27,7 +27,7 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
static String get_salt()
|
||||
static DeprecatedString get_salt()
|
||||
{
|
||||
char random_data[12];
|
||||
fill_with_random(random_data, sizeof(random_data));
|
||||
|
@ -223,7 +223,7 @@ Account::Account(passwd const& pwd, spwd const& spwd, Vector<gid_t> extra_gids)
|
|||
{
|
||||
}
|
||||
|
||||
ErrorOr<String> Account::generate_passwd_file() const
|
||||
ErrorOr<DeprecatedString> Account::generate_passwd_file() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
|
@ -256,7 +256,7 @@ ErrorOr<String> Account::generate_passwd_file() const
|
|||
}
|
||||
|
||||
#ifndef AK_OS_BSD_GENERIC
|
||||
ErrorOr<String> Account::generate_shadow_file() const
|
||||
ErrorOr<DeprecatedString> Account::generate_shadow_file() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
|
@ -268,24 +268,24 @@ ErrorOr<String> Account::generate_shadow_file() const
|
|||
if (p->sp_namp == m_username) {
|
||||
builder.appendff("{}:{}:{}:{}:{}:{}:{}:{}:{}\n",
|
||||
m_username, m_password_hash,
|
||||
(p->sp_lstchg == -1) ? "" : String::formatted("{}", p->sp_lstchg),
|
||||
(p->sp_min == -1) ? "" : String::formatted("{}", p->sp_min),
|
||||
(p->sp_max == -1) ? "" : String::formatted("{}", p->sp_max),
|
||||
(p->sp_warn == -1) ? "" : String::formatted("{}", p->sp_warn),
|
||||
(p->sp_inact == -1) ? "" : String::formatted("{}", p->sp_inact),
|
||||
(p->sp_expire == -1) ? "" : String::formatted("{}", p->sp_expire),
|
||||
(p->sp_flag == 0) ? "" : String::formatted("{}", p->sp_flag));
|
||||
(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));
|
||||
|
||||
} else {
|
||||
builder.appendff("{}:{}:{}:{}:{}:{}:{}:{}:{}\n",
|
||||
p->sp_namp, p->sp_pwdp,
|
||||
(p->sp_lstchg == -1) ? "" : String::formatted("{}", p->sp_lstchg),
|
||||
(p->sp_min == -1) ? "" : String::formatted("{}", p->sp_min),
|
||||
(p->sp_max == -1) ? "" : String::formatted("{}", p->sp_max),
|
||||
(p->sp_warn == -1) ? "" : String::formatted("{}", p->sp_warn),
|
||||
(p->sp_inact == -1) ? "" : String::formatted("{}", p->sp_inact),
|
||||
(p->sp_expire == -1) ? "" : String::formatted("{}", p->sp_expire),
|
||||
(p->sp_flag == 0) ? "" : String::formatted("{}", p->sp_flag));
|
||||
(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));
|
||||
}
|
||||
}
|
||||
endspent();
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.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;
|
||||
|
||||
String username() const { return m_username; }
|
||||
String password_hash() const { return m_password_hash; }
|
||||
DeprecatedString username() const { return m_username; }
|
||||
DeprecatedString password_hash() const { return m_password_hash; }
|
||||
|
||||
// Setters only affect in-memory copy of password.
|
||||
// You must call sync to apply changes.
|
||||
|
@ -60,9 +60,9 @@ public:
|
|||
|
||||
uid_t uid() const { return m_uid; }
|
||||
gid_t gid() const { return m_gid; }
|
||||
String const& gecos() const { return m_gecos; }
|
||||
String const& home_directory() const { return m_home_directory; }
|
||||
String const& shell() const { return m_shell; }
|
||||
DeprecatedString const& gecos() const { return m_gecos; }
|
||||
DeprecatedString const& home_directory() const { return m_home_directory; }
|
||||
DeprecatedString const& shell() const { return m_shell; }
|
||||
Vector<gid_t> const& extra_gids() const { return m_extra_gids; }
|
||||
|
||||
ErrorOr<void> sync();
|
||||
|
@ -72,19 +72,19 @@ private:
|
|||
|
||||
Account(passwd const& pwd, spwd const& spwd, Vector<gid_t> extra_gids);
|
||||
|
||||
ErrorOr<String> generate_passwd_file() const;
|
||||
ErrorOr<DeprecatedString> generate_passwd_file() const;
|
||||
#ifndef AK_OS_BSD_GENERIC
|
||||
ErrorOr<String> generate_shadow_file() const;
|
||||
ErrorOr<DeprecatedString> generate_shadow_file() const;
|
||||
#endif
|
||||
|
||||
String m_username;
|
||||
DeprecatedString m_username;
|
||||
|
||||
String m_password_hash;
|
||||
DeprecatedString m_password_hash;
|
||||
uid_t m_uid { 0 };
|
||||
gid_t m_gid { 0 };
|
||||
String m_gecos;
|
||||
String m_home_directory;
|
||||
String m_shell;
|
||||
DeprecatedString m_gecos;
|
||||
DeprecatedString m_home_directory;
|
||||
DeprecatedString m_shell;
|
||||
Vector<gid_t> m_extra_gids;
|
||||
};
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ bool ArgsParser::parse(int argc, char* const* argv, FailureBehavior failure_beha
|
|||
}
|
||||
long_options.append({ 0, 0, 0, 0 });
|
||||
|
||||
String short_options = short_options_builder.build();
|
||||
DeprecatedString short_options = short_options_builder.build();
|
||||
|
||||
while (true) {
|
||||
int c = getopt_long(argc, argv, short_options.characters(), long_options.data(), nullptr);
|
||||
|
@ -426,7 +426,7 @@ void ArgsParser::add_option(char const*& value, char const* help_string, char co
|
|||
add_option(move(option));
|
||||
}
|
||||
|
||||
void ArgsParser::add_option(String& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode)
|
||||
void ArgsParser::add_option(DeprecatedString& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode)
|
||||
{
|
||||
Option option {
|
||||
OptionArgumentMode::Required,
|
||||
|
@ -570,7 +570,7 @@ void ArgsParser::add_option(Vector<size_t>& values, char const* help_string, cha
|
|||
add_option(move(option));
|
||||
}
|
||||
|
||||
void ArgsParser::add_option(Vector<String>& values, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode)
|
||||
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)
|
||||
{
|
||||
Option option {
|
||||
OptionArgumentMode::Optional,
|
||||
|
@ -579,7 +579,7 @@ void ArgsParser::add_option(Vector<String>& values, char const* help_string, cha
|
|||
short_name,
|
||||
value_name,
|
||||
[&values](char const* s) {
|
||||
String value = s;
|
||||
DeprecatedString value = s;
|
||||
values.append(value);
|
||||
return true;
|
||||
},
|
||||
|
@ -609,7 +609,7 @@ void ArgsParser::add_positional_argument(char const*& value, char const* help_st
|
|||
add_positional_argument(move(arg));
|
||||
}
|
||||
|
||||
void ArgsParser::add_positional_argument(String& value, char const* help_string, char const* name, Required required)
|
||||
void ArgsParser::add_positional_argument(DeprecatedString& value, char const* help_string, char const* name, Required required)
|
||||
{
|
||||
Arg arg {
|
||||
help_string,
|
||||
|
@ -702,7 +702,7 @@ void ArgsParser::add_positional_argument(Vector<char const*>& values, char const
|
|||
add_positional_argument(move(arg));
|
||||
}
|
||||
|
||||
void ArgsParser::add_positional_argument(Vector<String>& values, char const* help_string, char const* name, Required required)
|
||||
void ArgsParser::add_positional_argument(Vector<DeprecatedString>& values, char const* help_string, char const* name, Required required)
|
||||
{
|
||||
Arg arg {
|
||||
help_string,
|
||||
|
@ -813,7 +813,7 @@ void ArgsParser::autocomplete(FILE* file, StringView program_name, Span<char con
|
|||
|
||||
auto write_completion = [&](auto format, auto& option, auto has_invariant, auto... args) {
|
||||
JsonObject object;
|
||||
object.set("completion", String::formatted(StringView { format, strlen(format) }, args...));
|
||||
object.set("completion", DeprecatedString::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);
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibMain/Main.h>
|
||||
#include <stdio.h>
|
||||
|
@ -53,11 +53,11 @@ public:
|
|||
Function<bool(char const*)> accept_value;
|
||||
OptionHideMode hide_mode { OptionHideMode::None };
|
||||
|
||||
String name_for_display() const
|
||||
DeprecatedString name_for_display() const
|
||||
{
|
||||
if (long_name)
|
||||
return String::formatted("--{}", long_name);
|
||||
return String::formatted("-{:c}", short_name);
|
||||
return DeprecatedString::formatted("--{}", long_name);
|
||||
return DeprecatedString::formatted("-{:c}", short_name);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -87,7 +87,7 @@ public:
|
|||
void add_ignored(char const* long_name, char short_name, OptionHideMode hide_mode = OptionHideMode::None);
|
||||
void add_option(bool& value, char const* help_string, char const* long_name, char short_name, OptionHideMode hide_mode = OptionHideMode::None);
|
||||
void add_option(char const*& 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(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(StringView& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None);
|
||||
template<typename Integral>
|
||||
void add_option(Integral& value, char const* help_string, char const* long_name, char short_name, char const* value_name, OptionHideMode hide_mode = OptionHideMode::None)
|
||||
|
@ -98,17 +98,17 @@ 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<String>& 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<DeprecatedString>& 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(char const*& 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);
|
||||
void add_positional_argument(DeprecatedString& 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(int& value, char const* help_string, char const* name, Required required = Required::Yes);
|
||||
void add_positional_argument(unsigned& 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<char const*>& 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);
|
||||
void add_positional_argument(Vector<DeprecatedString>& 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);
|
||||
|
||||
private:
|
||||
|
|
|
@ -18,7 +18,7 @@ namespace Core {
|
|||
// Only supported in serenity mode because we use `posix_spawn_file_actions_addchdir`
|
||||
#ifdef AK_OS_SERENITY
|
||||
|
||||
ErrorOr<CommandResult> command(String const& command_string, Optional<LexicalPath> chdir)
|
||||
ErrorOr<CommandResult> command(DeprecatedString const& command_string, Optional<LexicalPath> chdir)
|
||||
{
|
||||
auto parts = command_string.split(' ');
|
||||
if (parts.is_empty())
|
||||
|
@ -28,7 +28,7 @@ ErrorOr<CommandResult> command(String const& command_string, Optional<LexicalPat
|
|||
return command(program, parts, chdir);
|
||||
}
|
||||
|
||||
ErrorOr<CommandResult> command(String const& program, Vector<String> const& arguments, Optional<LexicalPath> chdir)
|
||||
ErrorOr<CommandResult> command(DeprecatedString const& program, Vector<DeprecatedString> const& arguments, Optional<LexicalPath> chdir)
|
||||
{
|
||||
int stdout_pipe[2] = {};
|
||||
int stderr_pipe[2] = {};
|
||||
|
@ -78,7 +78,7 @@ ErrorOr<CommandResult> command(String const& program, Vector<String> const& argu
|
|||
perror("open");
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
return String::copy(result_file->read_all());
|
||||
return DeprecatedString::copy(result_file->read_all());
|
||||
};
|
||||
auto output = read_all_from_pipe(stdout_pipe);
|
||||
auto error = read_all_from_pipe(stderr_pipe);
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/Optional.h>
|
||||
#include <AK/String.h>
|
||||
#include <spawn.h>
|
||||
|
||||
namespace Core {
|
||||
|
@ -17,11 +17,11 @@ namespace Core {
|
|||
|
||||
struct CommandResult {
|
||||
int exit_code { 0 };
|
||||
String output;
|
||||
String error;
|
||||
DeprecatedString output;
|
||||
DeprecatedString error;
|
||||
};
|
||||
|
||||
ErrorOr<CommandResult> command(String const& program, Vector<String> const& arguments, Optional<LexicalPath> chdir);
|
||||
ErrorOr<CommandResult> command(String const& command_string, Optional<LexicalPath> chdir);
|
||||
ErrorOr<CommandResult> command(DeprecatedString const& program, Vector<DeprecatedString> const& arguments, Optional<LexicalPath> chdir);
|
||||
ErrorOr<CommandResult> command(DeprecatedString const& command_string, Optional<LexicalPath> chdir);
|
||||
|
||||
}
|
||||
|
|
|
@ -17,28 +17,28 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open_for_lib(String const& lib_name, AllowWriting allow_altering)
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open_for_lib(DeprecatedString const& lib_name, AllowWriting allow_altering)
|
||||
{
|
||||
String directory_name = String::formatted("{}/lib", StandardPaths::config_directory());
|
||||
DeprecatedString directory_name = DeprecatedString::formatted("{}/lib", StandardPaths::config_directory());
|
||||
auto directory = TRY(Directory::create(directory_name, Directory::CreateDirectories::Yes));
|
||||
auto path = String::formatted("{}/{}.ini", directory, lib_name);
|
||||
auto path = DeprecatedString::formatted("{}/{}.ini", directory, lib_name);
|
||||
return ConfigFile::open(path, allow_altering);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open_for_app(String const& app_name, AllowWriting allow_altering)
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open_for_app(DeprecatedString const& app_name, AllowWriting allow_altering)
|
||||
{
|
||||
auto directory = TRY(Directory::create(StandardPaths::config_directory(), Directory::CreateDirectories::Yes));
|
||||
auto path = String::formatted("{}/{}.ini", directory, app_name);
|
||||
auto path = DeprecatedString::formatted("{}/{}.ini", directory, app_name);
|
||||
return ConfigFile::open(path, allow_altering);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open_for_system(String const& app_name, AllowWriting allow_altering)
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open_for_system(DeprecatedString const& app_name, AllowWriting allow_altering)
|
||||
{
|
||||
auto path = String::formatted("/etc/{}.ini", app_name);
|
||||
auto path = DeprecatedString::formatted("/etc/{}.ini", app_name);
|
||||
return ConfigFile::open(path, allow_altering);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(String const& filename, AllowWriting allow_altering)
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& filename, AllowWriting allow_altering)
|
||||
{
|
||||
auto maybe_file = Stream::File::open(filename, allow_altering == AllowWriting::Yes ? Stream::OpenMode::ReadWrite : Stream::OpenMode::Read);
|
||||
OwnPtr<Stream::BufferedFile> buffered_file;
|
||||
|
@ -57,13 +57,13 @@ ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(String const& filename, Allo
|
|||
return config_file;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(String const& filename, int fd)
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& filename, int fd)
|
||||
{
|
||||
auto file = TRY(Stream::File::adopt_fd(fd, Stream::OpenMode::ReadWrite));
|
||||
return open(filename, move(file));
|
||||
}
|
||||
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(String const& filename, NonnullOwnPtr<Core::Stream::File> file)
|
||||
ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(DeprecatedString const& filename, NonnullOwnPtr<Core::Stream::File> file)
|
||||
{
|
||||
auto buffered_file = TRY(Stream::BufferedFile::create(move(file)));
|
||||
|
||||
|
@ -72,7 +72,7 @@ ErrorOr<NonnullRefPtr<ConfigFile>> ConfigFile::open(String const& filename, Nonn
|
|||
return config_file;
|
||||
}
|
||||
|
||||
ConfigFile::ConfigFile(String const& filename, OwnPtr<Stream::BufferedFile> open_file)
|
||||
ConfigFile::ConfigFile(DeprecatedString const& filename, OwnPtr<Stream::BufferedFile> open_file)
|
||||
: m_filename(filename)
|
||||
, m_file(move(open_file))
|
||||
{
|
||||
|
@ -89,7 +89,7 @@ ErrorOr<void> ConfigFile::reparse()
|
|||
if (!m_file)
|
||||
return {};
|
||||
|
||||
HashMap<String, String>* current_group = nullptr;
|
||||
HashMap<DeprecatedString, DeprecatedString>* current_group = nullptr;
|
||||
|
||||
auto buffer = TRY(ByteBuffer::create_uninitialized(4096));
|
||||
while (TRY(m_file->can_read_line())) {
|
||||
|
@ -140,7 +140,7 @@ ErrorOr<void> ConfigFile::reparse()
|
|||
return {};
|
||||
}
|
||||
|
||||
String ConfigFile::read_entry(String const& group, String const& key, String const& default_value) const
|
||||
DeprecatedString ConfigFile::read_entry(DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& default_value) const
|
||||
{
|
||||
if (!has_key(group, key)) {
|
||||
return default_value;
|
||||
|
@ -150,7 +150,7 @@ String ConfigFile::read_entry(String const& group, String const& key, String con
|
|||
return jt->value;
|
||||
}
|
||||
|
||||
int ConfigFile::read_num_entry(String const& group, String const& key, int default_value) const
|
||||
int ConfigFile::read_num_entry(DeprecatedString const& group, DeprecatedString const& key, int default_value) const
|
||||
{
|
||||
if (!has_key(group, key)) {
|
||||
return default_value;
|
||||
|
@ -159,24 +159,24 @@ int ConfigFile::read_num_entry(String const& group, String const& key, int defau
|
|||
return read_entry(group, key).to_int().value_or(default_value);
|
||||
}
|
||||
|
||||
bool ConfigFile::read_bool_entry(String const& group, String const& key, bool default_value) const
|
||||
bool ConfigFile::read_bool_entry(DeprecatedString const& group, DeprecatedString const& key, bool default_value) const
|
||||
{
|
||||
auto value = read_entry(group, key, default_value ? "true" : "false");
|
||||
return value == "1" || value.equals_ignoring_case("true"sv);
|
||||
}
|
||||
|
||||
void ConfigFile::write_entry(String const& group, String const& key, String const& value)
|
||||
void ConfigFile::write_entry(DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value)
|
||||
{
|
||||
m_groups.ensure(group).ensure(key) = value;
|
||||
m_dirty = true;
|
||||
}
|
||||
|
||||
void ConfigFile::write_num_entry(String const& group, String const& key, int value)
|
||||
void ConfigFile::write_num_entry(DeprecatedString const& group, DeprecatedString const& key, int value)
|
||||
{
|
||||
write_entry(group, key, String::number(value));
|
||||
write_entry(group, key, DeprecatedString::number(value));
|
||||
}
|
||||
|
||||
void ConfigFile::write_bool_entry(String const& group, String const& key, bool value)
|
||||
void ConfigFile::write_bool_entry(DeprecatedString const& group, DeprecatedString const& key, bool value)
|
||||
{
|
||||
write_entry(group, key, value ? "true" : "false");
|
||||
}
|
||||
|
@ -193,9 +193,9 @@ ErrorOr<void> ConfigFile::sync()
|
|||
TRY(m_file->seek(0, Stream::SeekMode::SetPosition));
|
||||
|
||||
for (auto& it : m_groups) {
|
||||
TRY(m_file->write(String::formatted("[{}]\n", it.key).bytes()));
|
||||
TRY(m_file->write(DeprecatedString::formatted("[{}]\n", it.key).bytes()));
|
||||
for (auto& jt : it.value)
|
||||
TRY(m_file->write(String::formatted("{}={}\n", jt.key, jt.value).bytes()));
|
||||
TRY(m_file->write(DeprecatedString::formatted("{}={}\n", jt.key, jt.value).bytes()));
|
||||
TRY(m_file->write("\n"sv.bytes()));
|
||||
}
|
||||
|
||||
|
@ -213,12 +213,12 @@ void ConfigFile::dump() const
|
|||
}
|
||||
}
|
||||
|
||||
Vector<String> ConfigFile::groups() const
|
||||
Vector<DeprecatedString> ConfigFile::groups() const
|
||||
{
|
||||
return m_groups.keys();
|
||||
}
|
||||
|
||||
Vector<String> ConfigFile::keys(String const& group) const
|
||||
Vector<DeprecatedString> ConfigFile::keys(DeprecatedString const& group) const
|
||||
{
|
||||
auto it = m_groups.find(group);
|
||||
if (it == m_groups.end())
|
||||
|
@ -226,7 +226,7 @@ Vector<String> ConfigFile::keys(String const& group) const
|
|||
return it->value.keys();
|
||||
}
|
||||
|
||||
bool ConfigFile::has_key(String const& group, String const& key) const
|
||||
bool ConfigFile::has_key(DeprecatedString const& group, DeprecatedString const& key) const
|
||||
{
|
||||
auto it = m_groups.find(group);
|
||||
if (it == m_groups.end())
|
||||
|
@ -234,24 +234,24 @@ bool ConfigFile::has_key(String const& group, String const& key) const
|
|||
return it->value.contains(key);
|
||||
}
|
||||
|
||||
bool ConfigFile::has_group(String const& group) const
|
||||
bool ConfigFile::has_group(DeprecatedString const& group) const
|
||||
{
|
||||
return m_groups.contains(group);
|
||||
}
|
||||
|
||||
void ConfigFile::add_group(String const& group)
|
||||
void ConfigFile::add_group(DeprecatedString const& group)
|
||||
{
|
||||
m_groups.ensure(group);
|
||||
m_dirty = true;
|
||||
}
|
||||
|
||||
void ConfigFile::remove_group(String const& group)
|
||||
void ConfigFile::remove_group(DeprecatedString const& group)
|
||||
{
|
||||
m_groups.remove(group);
|
||||
m_dirty = true;
|
||||
}
|
||||
|
||||
void ConfigFile::remove_entry(String const& group, String const& key)
|
||||
void ConfigFile::remove_entry(DeprecatedString const& group, DeprecatedString const& key)
|
||||
{
|
||||
auto it = m_groups.find(group);
|
||||
if (it == m_groups.end())
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/Stream.h>
|
||||
|
||||
|
@ -25,29 +25,29 @@ public:
|
|||
No,
|
||||
};
|
||||
|
||||
static ErrorOr<NonnullRefPtr<ConfigFile>> open_for_lib(String const& lib_name, AllowWriting = AllowWriting::No);
|
||||
static ErrorOr<NonnullRefPtr<ConfigFile>> open_for_app(String const& app_name, AllowWriting = AllowWriting::No);
|
||||
static ErrorOr<NonnullRefPtr<ConfigFile>> open_for_system(String const& app_name, AllowWriting = AllowWriting::No);
|
||||
static ErrorOr<NonnullRefPtr<ConfigFile>> open(String const& filename, AllowWriting = AllowWriting::No);
|
||||
static ErrorOr<NonnullRefPtr<ConfigFile>> open(String const& filename, int fd);
|
||||
static ErrorOr<NonnullRefPtr<ConfigFile>> open(String const& filename, NonnullOwnPtr<Core::Stream::File>);
|
||||
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::Stream::File>);
|
||||
~ConfigFile();
|
||||
|
||||
bool has_group(String const&) const;
|
||||
bool has_key(String const& group, String const& key) const;
|
||||
bool has_group(DeprecatedString const&) const;
|
||||
bool has_key(DeprecatedString const& group, DeprecatedString const& key) const;
|
||||
|
||||
Vector<String> groups() const;
|
||||
Vector<String> keys(String const& group) const;
|
||||
Vector<DeprecatedString> groups() const;
|
||||
Vector<DeprecatedString> keys(DeprecatedString const& group) const;
|
||||
|
||||
size_t num_groups() const { return m_groups.size(); }
|
||||
|
||||
String read_entry(String const& group, String const& key, String const& default_value = String()) const;
|
||||
int read_num_entry(String const& group, String const& key, int default_value = 0) const;
|
||||
bool read_bool_entry(String const& group, String const& key, bool default_value = false) const;
|
||||
DeprecatedString read_entry(DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& default_value = DeprecatedString()) const;
|
||||
int read_num_entry(DeprecatedString const& group, DeprecatedString const& key, int default_value = 0) const;
|
||||
bool read_bool_entry(DeprecatedString const& group, DeprecatedString const& key, bool default_value = false) const;
|
||||
|
||||
void write_entry(String const& group, String const& key, String const& value);
|
||||
void write_num_entry(String const& group, String const& key, int value);
|
||||
void write_bool_entry(String const& group, String const& key, bool value);
|
||||
void write_entry(DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value);
|
||||
void write_num_entry(DeprecatedString const& group, DeprecatedString const& key, int value);
|
||||
void write_bool_entry(DeprecatedString const& group, DeprecatedString const& key, bool value);
|
||||
|
||||
void dump() const;
|
||||
|
||||
|
@ -55,20 +55,20 @@ public:
|
|||
|
||||
ErrorOr<void> sync();
|
||||
|
||||
void add_group(String const& group);
|
||||
void remove_group(String const& group);
|
||||
void remove_entry(String const& group, String const& key);
|
||||
void add_group(DeprecatedString const& group);
|
||||
void remove_group(DeprecatedString const& group);
|
||||
void remove_entry(DeprecatedString const& group, DeprecatedString const& key);
|
||||
|
||||
String const& filename() const { return m_filename; }
|
||||
DeprecatedString const& filename() const { return m_filename; }
|
||||
|
||||
private:
|
||||
ConfigFile(String const& filename, OwnPtr<Stream::BufferedFile> open_file);
|
||||
ConfigFile(DeprecatedString const& filename, OwnPtr<Stream::BufferedFile> open_file);
|
||||
|
||||
ErrorOr<void> reparse();
|
||||
|
||||
String m_filename;
|
||||
DeprecatedString m_filename;
|
||||
OwnPtr<Stream::BufferedFile> m_file;
|
||||
HashMap<String, HashMap<String, String>> m_groups;
|
||||
HashMap<DeprecatedString, HashMap<DeprecatedString, DeprecatedString>> m_groups;
|
||||
bool m_dirty { false };
|
||||
};
|
||||
|
||||
|
|
|
@ -84,7 +84,7 @@ void DateTime::set_time(int year, int month, int day, int hour, int minute, int
|
|||
m_second = tm.tm_sec;
|
||||
}
|
||||
|
||||
String DateTime::to_string(StringView format) const
|
||||
DeprecatedString DateTime::to_string(StringView format) const
|
||||
{
|
||||
struct tm tm;
|
||||
localtime_r(&m_timestamp, &tm);
|
||||
|
@ -120,7 +120,7 @@ String DateTime::to_string(StringView format) const
|
|||
builder.append(format[i]);
|
||||
} else {
|
||||
if (++i == format_len)
|
||||
return String();
|
||||
return DeprecatedString();
|
||||
|
||||
switch (format[i]) {
|
||||
case 'a':
|
||||
|
@ -276,7 +276,7 @@ String DateTime::to_string(StringView format) const
|
|||
return builder.build();
|
||||
}
|
||||
|
||||
Optional<DateTime> DateTime::parse(StringView format, String const& string)
|
||||
Optional<DateTime> DateTime::parse(StringView format, DeprecatedString const& string)
|
||||
{
|
||||
unsigned format_pos = 0;
|
||||
unsigned string_pos = 0;
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <LibIPC/Forward.h>
|
||||
#include <time.h>
|
||||
|
@ -31,12 +31,12 @@ public:
|
|||
bool is_leap_year() const;
|
||||
|
||||
void set_time(int year, int month = 1, int day = 1, int hour = 0, int minute = 0, int second = 0);
|
||||
String to_string(StringView format = "%Y-%m-%d %H:%M:%S"sv) const;
|
||||
DeprecatedString to_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();
|
||||
static DateTime from_timestamp(time_t);
|
||||
static Optional<DateTime> parse(StringView format, String const& string);
|
||||
static Optional<DateTime> parse(StringView format, DeprecatedString const& string);
|
||||
|
||||
bool operator<(DateTime const& other) const { return m_timestamp < other.m_timestamp; }
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
DirIterator::DirIterator(String path, Flags flags)
|
||||
DirIterator::DirIterator(DeprecatedString path, Flags flags)
|
||||
: m_path(move(path))
|
||||
, m_flags(flags)
|
||||
{
|
||||
|
@ -49,7 +49,7 @@ bool DirIterator::advance_next()
|
|||
auto* de = readdir(m_dir);
|
||||
if (!de) {
|
||||
m_error = errno;
|
||||
m_next = String();
|
||||
m_next = DeprecatedString();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -75,17 +75,17 @@ bool DirIterator::has_next()
|
|||
return advance_next();
|
||||
}
|
||||
|
||||
String DirIterator::next_path()
|
||||
DeprecatedString DirIterator::next_path()
|
||||
{
|
||||
if (m_next.is_null())
|
||||
advance_next();
|
||||
|
||||
auto tmp = m_next;
|
||||
m_next = String();
|
||||
m_next = DeprecatedString();
|
||||
return tmp;
|
||||
}
|
||||
|
||||
String DirIterator::next_full_path()
|
||||
DeprecatedString DirIterator::next_full_path()
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(m_path);
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <dirent.h>
|
||||
#include <string.h>
|
||||
|
||||
|
@ -20,7 +20,7 @@ public:
|
|||
SkipParentAndBaseDir = 0x2,
|
||||
};
|
||||
|
||||
explicit DirIterator(String path, Flags = Flags::NoFlags);
|
||||
explicit DirIterator(DeprecatedString path, Flags = Flags::NoFlags);
|
||||
~DirIterator();
|
||||
|
||||
DirIterator(DirIterator&&);
|
||||
|
@ -30,15 +30,15 @@ public:
|
|||
int error() const { return m_error; }
|
||||
char const* error_string() const { return strerror(m_error); }
|
||||
bool has_next();
|
||||
String next_path();
|
||||
String next_full_path();
|
||||
DeprecatedString next_path();
|
||||
DeprecatedString next_full_path();
|
||||
int fd() const;
|
||||
|
||||
private:
|
||||
DIR* m_dir = nullptr;
|
||||
int m_error = 0;
|
||||
String m_next;
|
||||
String m_path;
|
||||
DeprecatedString m_next;
|
||||
DeprecatedString m_path;
|
||||
int m_flags;
|
||||
|
||||
bool advance_next();
|
||||
|
|
|
@ -53,7 +53,7 @@ ErrorOr<Directory> Directory::adopt_fd(int fd, Optional<LexicalPath> path)
|
|||
return Directory { fd, move(path) };
|
||||
}
|
||||
|
||||
ErrorOr<Directory> Directory::create(String path, CreateDirectories create_directories, mode_t creation_mode)
|
||||
ErrorOr<Directory> Directory::create(DeprecatedString path, CreateDirectories create_directories, mode_t creation_mode)
|
||||
{
|
||||
return create(LexicalPath { move(path) }, create_directories, creation_mode);
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
};
|
||||
|
||||
static ErrorOr<Directory> create(LexicalPath path, CreateDirectories, mode_t creation_mode = 0755);
|
||||
static ErrorOr<Directory> create(String path, CreateDirectories, mode_t creation_mode = 0755);
|
||||
static ErrorOr<Directory> create(DeprecatedString path, CreateDirectories, mode_t creation_mode = 0755);
|
||||
static ErrorOr<Directory> adopt_fd(int fd, Optional<LexicalPath> path = {});
|
||||
|
||||
ErrorOr<NonnullOwnPtr<Stream::File>> open(StringView filename, Stream::OpenMode mode) const;
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <LibCore/DeferredInvocationContext.h>
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
ErrorOr<NonnullRefPtr<File>> File::open(String filename, OpenMode mode, mode_t permissions)
|
||||
ErrorOr<NonnullRefPtr<File>> File::open(DeprecatedString filename, OpenMode mode, mode_t permissions)
|
||||
{
|
||||
auto file = File::construct(move(filename));
|
||||
if (!file->open_impl(mode, permissions))
|
||||
|
@ -37,7 +37,7 @@ ErrorOr<NonnullRefPtr<File>> File::open(String filename, OpenMode mode, mode_t p
|
|||
return file;
|
||||
}
|
||||
|
||||
File::File(String filename, Object* parent)
|
||||
File::File(DeprecatedString filename, Object* parent)
|
||||
: IODevice(parent)
|
||||
, m_filename(move(filename))
|
||||
{
|
||||
|
@ -109,7 +109,7 @@ bool File::is_device() const
|
|||
return S_ISBLK(stat.st_mode) || S_ISCHR(stat.st_mode);
|
||||
}
|
||||
|
||||
bool File::is_device(String const& filename)
|
||||
bool File::is_device(DeprecatedString const& filename)
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(filename.characters(), &st) < 0)
|
||||
|
@ -125,7 +125,7 @@ bool File::is_block_device() const
|
|||
return S_ISBLK(stat.st_mode);
|
||||
}
|
||||
|
||||
bool File::is_block_device(String const& filename)
|
||||
bool File::is_block_device(DeprecatedString const& filename)
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(filename.characters(), &st) < 0)
|
||||
|
@ -141,7 +141,7 @@ bool File::is_char_device() const
|
|||
return S_ISCHR(stat.st_mode);
|
||||
}
|
||||
|
||||
bool File::is_char_device(String const& filename)
|
||||
bool File::is_char_device(DeprecatedString const& filename)
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(filename.characters(), &st) < 0)
|
||||
|
@ -157,7 +157,7 @@ bool File::is_directory() const
|
|||
return S_ISDIR(stat.st_mode);
|
||||
}
|
||||
|
||||
bool File::is_directory(String const& filename)
|
||||
bool File::is_directory(DeprecatedString const& filename)
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(filename.characters(), &st) < 0)
|
||||
|
@ -173,7 +173,7 @@ bool File::is_link() const
|
|||
return S_ISLNK(stat.st_mode);
|
||||
}
|
||||
|
||||
bool File::is_link(String const& filename)
|
||||
bool File::is_link(DeprecatedString const& filename)
|
||||
{
|
||||
struct stat st;
|
||||
if (lstat(filename.characters(), &st) < 0)
|
||||
|
@ -186,18 +186,18 @@ bool File::looks_like_shared_library() const
|
|||
return File::looks_like_shared_library(m_filename);
|
||||
}
|
||||
|
||||
bool File::looks_like_shared_library(String const& filename)
|
||||
bool File::looks_like_shared_library(DeprecatedString const& filename)
|
||||
{
|
||||
return filename.ends_with(".so"sv) || filename.contains(".so."sv);
|
||||
}
|
||||
|
||||
bool File::exists(String const& filename)
|
||||
bool File::exists(DeprecatedString const& filename)
|
||||
{
|
||||
struct stat st;
|
||||
return stat(filename.characters(), &st) == 0;
|
||||
}
|
||||
|
||||
ErrorOr<size_t> File::size(String const& filename)
|
||||
ErrorOr<size_t> File::size(DeprecatedString const& filename)
|
||||
{
|
||||
struct stat st;
|
||||
if (stat(filename.characters(), &st) < 0)
|
||||
|
@ -205,17 +205,17 @@ ErrorOr<size_t> File::size(String const& filename)
|
|||
return st.st_size;
|
||||
}
|
||||
|
||||
String File::real_path_for(String const& filename)
|
||||
DeprecatedString File::real_path_for(DeprecatedString const& filename)
|
||||
{
|
||||
if (filename.is_null())
|
||||
return {};
|
||||
auto* path = realpath(filename.characters(), nullptr);
|
||||
String real_path(path);
|
||||
DeprecatedString real_path(path);
|
||||
free(path);
|
||||
return real_path;
|
||||
}
|
||||
|
||||
String File::current_working_directory()
|
||||
DeprecatedString File::current_working_directory()
|
||||
{
|
||||
char* cwd = getcwd(nullptr, 0);
|
||||
if (!cwd) {
|
||||
|
@ -223,13 +223,13 @@ String File::current_working_directory()
|
|||
return {};
|
||||
}
|
||||
|
||||
auto cwd_as_string = String(cwd);
|
||||
auto cwd_as_string = DeprecatedString(cwd);
|
||||
free(cwd);
|
||||
|
||||
return cwd_as_string;
|
||||
}
|
||||
|
||||
String File::absolute_path(String const& path)
|
||||
DeprecatedString File::absolute_path(DeprecatedString const& path)
|
||||
{
|
||||
if (File::exists(path))
|
||||
return File::real_path_for(path);
|
||||
|
@ -245,7 +245,7 @@ String File::absolute_path(String const& path)
|
|||
|
||||
#ifdef AK_OS_SERENITY
|
||||
|
||||
ErrorOr<String> File::read_link(String const& link_path)
|
||||
ErrorOr<DeprecatedString> File::read_link(DeprecatedString const& link_path)
|
||||
{
|
||||
// First, try using a 64-byte buffer, that ought to be enough for anybody.
|
||||
char small_buffer[64];
|
||||
|
@ -259,7 +259,7 @@ ErrorOr<String> File::read_link(String const& link_path)
|
|||
// returns the full size of the link. Let's see if our small buffer
|
||||
// was enough to read the whole link.
|
||||
if (size <= sizeof(small_buffer))
|
||||
return String { small_buffer, size };
|
||||
return DeprecatedString { small_buffer, size };
|
||||
// Nope, but at least now we know the right size.
|
||||
char* large_buffer_ptr;
|
||||
auto large_buffer = StringImpl::create_uninitialized(size, large_buffer_ptr);
|
||||
|
@ -275,7 +275,7 @@ ErrorOr<String> File::read_link(String const& link_path)
|
|||
// If we're here, the symlink has changed while we were looking at it.
|
||||
// If it became shorter, our buffer is valid, we just have to trim it a bit.
|
||||
if (new_size < size)
|
||||
return String { large_buffer_ptr, new_size };
|
||||
return DeprecatedString { large_buffer_ptr, new_size };
|
||||
// Otherwise, here's not much we can do, unless we want to loop endlessly
|
||||
// in this case. Let's leave it up to the caller whether to loop.
|
||||
errno = EAGAIN;
|
||||
|
@ -286,7 +286,7 @@ ErrorOr<String> File::read_link(String const& link_path)
|
|||
|
||||
// This is a sad version for other systems. It has to always make a copy of the
|
||||
// link path, and to always make two syscalls to get the right size first.
|
||||
ErrorOr<String> File::read_link(String const& link_path)
|
||||
ErrorOr<DeprecatedString> File::read_link(DeprecatedString const& link_path)
|
||||
{
|
||||
struct stat statbuf = {};
|
||||
int rc = lstat(link_path.characters(), &statbuf);
|
||||
|
@ -299,7 +299,7 @@ ErrorOr<String> File::read_link(String const& link_path)
|
|||
// (See above.)
|
||||
if (rc == statbuf.st_size)
|
||||
return { *buffer };
|
||||
return String { buffer_ptr, (size_t)rc };
|
||||
return DeprecatedString { buffer_ptr, (size_t)rc };
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -335,7 +335,7 @@ NonnullRefPtr<File> File::standard_error()
|
|||
return *stderr_file;
|
||||
}
|
||||
|
||||
static String get_duplicate_name(String const& path, int duplicate_count)
|
||||
static DeprecatedString get_duplicate_name(DeprecatedString const& path, int duplicate_count)
|
||||
{
|
||||
if (duplicate_count == 0) {
|
||||
return path;
|
||||
|
@ -347,7 +347,7 @@ static String get_duplicate_name(String const& path, int duplicate_count)
|
|||
for (size_t i = 0; i < parts.size() - 1; ++i) {
|
||||
duplicated_name.appendff("{}/", parts[i]);
|
||||
}
|
||||
auto prev_duplicate_tag = String::formatted("({})", duplicate_count);
|
||||
auto prev_duplicate_tag = DeprecatedString::formatted("({})", duplicate_count);
|
||||
auto title = lexical_path.title();
|
||||
if (title.ends_with(prev_duplicate_tag)) {
|
||||
// remove the previous duplicate tag "(n)" so we can add a new tag.
|
||||
|
@ -360,7 +360,7 @@ static String get_duplicate_name(String const& path, int duplicate_count)
|
|||
return duplicated_name.build();
|
||||
}
|
||||
|
||||
ErrorOr<void, File::CopyError> File::copy_file_or_directory(String const& dst_path, String const& src_path, RecursionMode recursion_mode, LinkMode link_mode, AddDuplicateFileMarker add_duplicate_file_marker, PreserveMode preserve_mode)
|
||||
ErrorOr<void, File::CopyError> File::copy_file_or_directory(DeprecatedString const& dst_path, DeprecatedString const& src_path, RecursionMode recursion_mode, LinkMode link_mode, AddDuplicateFileMarker add_duplicate_file_marker, PreserveMode preserve_mode)
|
||||
{
|
||||
if (add_duplicate_file_marker == AddDuplicateFileMarker::Yes) {
|
||||
int duplicate_count = 0;
|
||||
|
@ -398,14 +398,14 @@ ErrorOr<void, File::CopyError> File::copy_file_or_directory(String const& dst_pa
|
|||
return copy_file(dst_path, src_stat, source, preserve_mode);
|
||||
}
|
||||
|
||||
ErrorOr<void, File::CopyError> File::copy_file(String const& dst_path, struct stat const& src_stat, File& source, PreserveMode preserve_mode)
|
||||
ErrorOr<void, File::CopyError> File::copy_file(DeprecatedString const& dst_path, struct stat const& src_stat, File& source, PreserveMode preserve_mode)
|
||||
{
|
||||
int dst_fd = creat(dst_path.characters(), 0666);
|
||||
if (dst_fd < 0) {
|
||||
if (errno != EISDIR)
|
||||
return CopyError { errno, false };
|
||||
|
||||
auto dst_dir_path = String::formatted("{}/{}", dst_path, LexicalPath::basename(source.filename()));
|
||||
auto dst_dir_path = DeprecatedString::formatted("{}/{}", dst_path, LexicalPath::basename(source.filename()));
|
||||
dst_fd = creat(dst_dir_path.characters(), 0666);
|
||||
if (dst_fd < 0)
|
||||
return CopyError { errno, false };
|
||||
|
@ -470,15 +470,15 @@ ErrorOr<void, File::CopyError> File::copy_file(String const& dst_path, struct st
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void, File::CopyError> File::copy_directory(String const& dst_path, String const& src_path, struct stat const& src_stat, LinkMode link, PreserveMode preserve_mode)
|
||||
ErrorOr<void, File::CopyError> File::copy_directory(DeprecatedString const& dst_path, DeprecatedString const& src_path, struct stat const& src_stat, LinkMode link, PreserveMode preserve_mode)
|
||||
{
|
||||
if (mkdir(dst_path.characters(), 0755) < 0)
|
||||
return CopyError { errno, false };
|
||||
|
||||
String src_rp = File::real_path_for(src_path);
|
||||
src_rp = String::formatted("{}/", src_rp);
|
||||
String dst_rp = File::real_path_for(dst_path);
|
||||
dst_rp = String::formatted("{}/", dst_rp);
|
||||
DeprecatedString src_rp = File::real_path_for(src_path);
|
||||
src_rp = DeprecatedString::formatted("{}/", src_rp);
|
||||
DeprecatedString dst_rp = File::real_path_for(dst_path);
|
||||
dst_rp = DeprecatedString::formatted("{}/", dst_rp);
|
||||
|
||||
if (!dst_rp.is_empty() && dst_rp.starts_with(src_rp))
|
||||
return CopyError { errno, false };
|
||||
|
@ -488,10 +488,10 @@ ErrorOr<void, File::CopyError> File::copy_directory(String const& dst_path, Stri
|
|||
return CopyError { errno, false };
|
||||
|
||||
while (di.has_next()) {
|
||||
String filename = di.next_path();
|
||||
DeprecatedString filename = di.next_path();
|
||||
auto result = copy_file_or_directory(
|
||||
String::formatted("{}/{}", dst_path, filename),
|
||||
String::formatted("{}/{}", src_path, filename),
|
||||
DeprecatedString::formatted("{}/{}", dst_path, filename),
|
||||
DeprecatedString::formatted("{}/{}", src_path, filename),
|
||||
RecursionMode::Allowed, link, AddDuplicateFileMarker::Yes, preserve_mode);
|
||||
if (result.is_error())
|
||||
return result.error();
|
||||
|
@ -525,7 +525,7 @@ ErrorOr<void, File::CopyError> File::copy_directory(String const& dst_path, Stri
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void> File::link_file(String const& dst_path, String const& src_path)
|
||||
ErrorOr<void> File::link_file(DeprecatedString const& dst_path, DeprecatedString const& src_path)
|
||||
{
|
||||
int duplicate_count = 0;
|
||||
while (access(get_duplicate_name(dst_path, duplicate_count).characters(), F_OK) == 0) {
|
||||
|
@ -539,7 +539,7 @@ ErrorOr<void> File::link_file(String const& dst_path, String const& src_path)
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<void, File::RemoveError> File::remove(String const& path, RecursionMode mode, bool force)
|
||||
ErrorOr<void, File::RemoveError> File::remove(DeprecatedString const& path, RecursionMode mode, bool force)
|
||||
{
|
||||
struct stat path_stat;
|
||||
if (lstat(path.characters(), &path_stat) < 0) {
|
||||
|
@ -569,14 +569,14 @@ ErrorOr<void, File::RemoveError> File::remove(String const& path, RecursionMode
|
|||
return {};
|
||||
}
|
||||
|
||||
Optional<String> File::resolve_executable_from_environment(StringView filename)
|
||||
Optional<DeprecatedString> File::resolve_executable_from_environment(StringView filename)
|
||||
{
|
||||
if (filename.is_empty())
|
||||
return {};
|
||||
|
||||
// Paths that aren't just a file name generally count as already resolved.
|
||||
if (filename.contains('/')) {
|
||||
if (access(String { filename }.characters(), X_OK) != 0)
|
||||
if (access(DeprecatedString { filename }.characters(), X_OK) != 0)
|
||||
return {};
|
||||
|
||||
return filename;
|
||||
|
@ -592,7 +592,7 @@ Optional<String> File::resolve_executable_from_environment(StringView filename)
|
|||
auto directories = path.split_view(':');
|
||||
|
||||
for (auto directory : directories) {
|
||||
auto file = String::formatted("{}/{}", directory, filename);
|
||||
auto file = DeprecatedString::formatted("{}/{}", directory, filename);
|
||||
|
||||
if (access(file.characters(), X_OK) == 0)
|
||||
return file;
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/IODevice.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
|
@ -26,31 +26,31 @@ class File final : public IODevice {
|
|||
public:
|
||||
virtual ~File() override;
|
||||
|
||||
static ErrorOr<NonnullRefPtr<File>> open(String filename, OpenMode, mode_t = 0644);
|
||||
static ErrorOr<NonnullRefPtr<File>> open(DeprecatedString filename, OpenMode, mode_t = 0644);
|
||||
|
||||
String filename() const { return m_filename; }
|
||||
void set_filename(const String filename) { m_filename = move(filename); }
|
||||
DeprecatedString filename() const { return m_filename; }
|
||||
void set_filename(const DeprecatedString filename) { m_filename = move(filename); }
|
||||
|
||||
bool is_directory() const;
|
||||
static bool is_directory(String const& filename);
|
||||
static bool is_directory(DeprecatedString const& filename);
|
||||
|
||||
bool is_device() const;
|
||||
static bool is_device(String const& filename);
|
||||
static bool is_device(DeprecatedString const& filename);
|
||||
bool is_block_device() const;
|
||||
static bool is_block_device(String const& filename);
|
||||
static bool is_block_device(DeprecatedString const& filename);
|
||||
bool is_char_device() const;
|
||||
static bool is_char_device(String const& filename);
|
||||
static bool is_char_device(DeprecatedString const& filename);
|
||||
|
||||
bool is_link() const;
|
||||
static bool is_link(String const& filename);
|
||||
static bool is_link(DeprecatedString const& filename);
|
||||
|
||||
bool looks_like_shared_library() const;
|
||||
static bool looks_like_shared_library(String const& filename);
|
||||
static bool looks_like_shared_library(DeprecatedString const& filename);
|
||||
|
||||
static bool exists(String const& filename);
|
||||
static ErrorOr<size_t> size(String const& filename);
|
||||
static String current_working_directory();
|
||||
static String absolute_path(String const& path);
|
||||
static bool exists(DeprecatedString const& filename);
|
||||
static ErrorOr<size_t> size(DeprecatedString const& filename);
|
||||
static DeprecatedString current_working_directory();
|
||||
static DeprecatedString absolute_path(DeprecatedString const& path);
|
||||
|
||||
enum class RecursionMode {
|
||||
Allowed,
|
||||
|
@ -83,23 +83,23 @@ public:
|
|||
bool tried_recursing;
|
||||
};
|
||||
|
||||
static ErrorOr<void, CopyError> copy_file(String const& dst_path, struct stat const& src_stat, File& source, PreserveMode = PreserveMode::Nothing);
|
||||
static ErrorOr<void, CopyError> copy_directory(String const& dst_path, String const& src_path, struct stat const& src_stat, LinkMode = LinkMode::Disallowed, PreserveMode = PreserveMode::Nothing);
|
||||
static ErrorOr<void, CopyError> copy_file_or_directory(String const& dst_path, String const& src_path, RecursionMode = RecursionMode::Allowed, LinkMode = LinkMode::Disallowed, AddDuplicateFileMarker = AddDuplicateFileMarker::Yes, PreserveMode = PreserveMode::Nothing);
|
||||
static ErrorOr<void, CopyError> copy_file(DeprecatedString const& dst_path, struct stat const& src_stat, File& source, PreserveMode = PreserveMode::Nothing);
|
||||
static ErrorOr<void, CopyError> copy_directory(DeprecatedString const& dst_path, DeprecatedString const& src_path, struct stat const& src_stat, LinkMode = LinkMode::Disallowed, PreserveMode = PreserveMode::Nothing);
|
||||
static ErrorOr<void, CopyError> copy_file_or_directory(DeprecatedString const& dst_path, DeprecatedString const& src_path, RecursionMode = RecursionMode::Allowed, LinkMode = LinkMode::Disallowed, AddDuplicateFileMarker = AddDuplicateFileMarker::Yes, PreserveMode = PreserveMode::Nothing);
|
||||
|
||||
static String real_path_for(String const& filename);
|
||||
static ErrorOr<String> read_link(String const& link_path);
|
||||
static ErrorOr<void> link_file(String const& dst_path, String const& src_path);
|
||||
static DeprecatedString real_path_for(DeprecatedString const& filename);
|
||||
static ErrorOr<DeprecatedString> read_link(DeprecatedString const& link_path);
|
||||
static ErrorOr<void> link_file(DeprecatedString const& dst_path, DeprecatedString const& src_path);
|
||||
|
||||
struct RemoveError : public Error {
|
||||
RemoveError(String f, int error_code)
|
||||
RemoveError(DeprecatedString f, int error_code)
|
||||
: Error(error_code)
|
||||
, file(move(f))
|
||||
{
|
||||
}
|
||||
String file;
|
||||
DeprecatedString file;
|
||||
};
|
||||
static ErrorOr<void, RemoveError> remove(String const& path, RecursionMode, bool force);
|
||||
static ErrorOr<void, RemoveError> remove(DeprecatedString const& path, RecursionMode, bool force);
|
||||
|
||||
virtual bool open(OpenMode) override;
|
||||
|
||||
|
@ -114,18 +114,18 @@ public:
|
|||
static NonnullRefPtr<File> standard_output();
|
||||
static NonnullRefPtr<File> standard_error();
|
||||
|
||||
static Optional<String> resolve_executable_from_environment(StringView filename);
|
||||
static Optional<DeprecatedString> resolve_executable_from_environment(StringView filename);
|
||||
|
||||
private:
|
||||
File(Object* parent = nullptr)
|
||||
: IODevice(parent)
|
||||
{
|
||||
}
|
||||
explicit File(String filename, Object* parent = nullptr);
|
||||
explicit File(DeprecatedString filename, Object* parent = nullptr);
|
||||
|
||||
bool open_impl(OpenMode, mode_t);
|
||||
|
||||
String m_filename;
|
||||
DeprecatedString m_filename;
|
||||
ShouldCloseFileDescriptor m_should_close_file_descriptor { ShouldCloseFileDescriptor::Yes };
|
||||
};
|
||||
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
namespace Core {
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
|
||||
#include "FileWatcher.h"
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <Kernel/API/InodeWatcherEvent.h>
|
||||
#include <Kernel/API/InodeWatcherFlags.h>
|
||||
#include <LibCore/Notifier.h>
|
||||
|
@ -23,7 +23,7 @@ namespace Core {
|
|||
// Only supported in serenity mode because we use InodeWatcher syscalls
|
||||
#ifdef AK_OS_SERENITY
|
||||
|
||||
static Optional<FileWatcherEvent> get_event_from_fd(int fd, HashMap<unsigned, String> const& wd_to_path)
|
||||
static Optional<FileWatcherEvent> get_event_from_fd(int fd, HashMap<unsigned, DeprecatedString> const& wd_to_path)
|
||||
{
|
||||
u8 buffer[MAXIMUM_EVENT_SIZE];
|
||||
int rc = read(fd, &buffer, MAXIMUM_EVENT_SIZE);
|
||||
|
@ -42,7 +42,7 @@ static Optional<FileWatcherEvent> get_event_from_fd(int fd, HashMap<unsigned, St
|
|||
dbgln_if(FILE_WATCHER_DEBUG, "get_event_from_fd: Got an event for a non-existent wd {}?!", event->watch_descriptor);
|
||||
return {};
|
||||
}
|
||||
String const& path = it->value;
|
||||
DeprecatedString const& path = it->value;
|
||||
|
||||
switch (event->type) {
|
||||
case InodeWatcherEvent::Type::ChildCreated:
|
||||
|
@ -67,7 +67,7 @@ static Optional<FileWatcherEvent> get_event_from_fd(int fd, HashMap<unsigned, St
|
|||
|
||||
// We trust that the kernel only sends the name when appropriate.
|
||||
if (event->name_length > 0) {
|
||||
String child_name { event->name, event->name_length - 1 };
|
||||
DeprecatedString child_name { event->name, event->name_length - 1 };
|
||||
result.event_path = LexicalPath::join(path, child_name).string();
|
||||
} else {
|
||||
result.event_path = path;
|
||||
|
@ -77,7 +77,7 @@ static Optional<FileWatcherEvent> get_event_from_fd(int fd, HashMap<unsigned, St
|
|||
return result;
|
||||
}
|
||||
|
||||
static String canonicalize_path(String path)
|
||||
static DeprecatedString canonicalize_path(DeprecatedString path)
|
||||
{
|
||||
if (!path.is_empty() && path[0] == '/')
|
||||
return LexicalPath::canonicalized_path(move(path));
|
||||
|
@ -86,9 +86,9 @@ static String canonicalize_path(String path)
|
|||
return LexicalPath::join({ cwd, strlen(cwd) }, move(path)).string();
|
||||
}
|
||||
|
||||
ErrorOr<bool> FileWatcherBase::add_watch(String path, FileWatcherEvent::Type event_mask)
|
||||
ErrorOr<bool> FileWatcherBase::add_watch(DeprecatedString path, FileWatcherEvent::Type event_mask)
|
||||
{
|
||||
String canonical_path = canonicalize_path(move(path));
|
||||
DeprecatedString 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);
|
||||
|
@ -118,9 +118,9 @@ ErrorOr<bool> FileWatcherBase::add_watch(String path, FileWatcherEvent::Type eve
|
|||
return true;
|
||||
}
|
||||
|
||||
ErrorOr<bool> FileWatcherBase::remove_watch(String path)
|
||||
ErrorOr<bool> FileWatcherBase::remove_watch(DeprecatedString path)
|
||||
{
|
||||
String canonical_path = canonicalize_path(move(path));
|
||||
DeprecatedString canonical_path = canonicalize_path(move(path));
|
||||
|
||||
auto it = m_path_to_wd.find(canonical_path);
|
||||
if (it == m_path_to_wd.end()) {
|
||||
|
@ -220,12 +220,12 @@ ErrorOr<NonnullRefPtr<FileWatcher>> FileWatcher::create(InodeWatcherFlags)
|
|||
return Error::from_errno(ENOTSUP);
|
||||
}
|
||||
|
||||
ErrorOr<bool> FileWatcherBase::add_watch(String, FileWatcherEvent::Type)
|
||||
ErrorOr<bool> FileWatcherBase::add_watch(DeprecatedString, FileWatcherEvent::Type)
|
||||
{
|
||||
return Error::from_errno(ENOTSUP);
|
||||
}
|
||||
|
||||
ErrorOr<bool> FileWatcherBase::remove_watch(String)
|
||||
ErrorOr<bool> FileWatcherBase::remove_watch(DeprecatedString)
|
||||
{
|
||||
return Error::from_errno(ENOTSUP);
|
||||
}
|
||||
|
|
|
@ -7,12 +7,12 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/EnumBits.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/Noncopyable.h>
|
||||
#include <AK/NonnullRefPtr.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/String.h>
|
||||
#include <Kernel/API/InodeWatcherEvent.h>
|
||||
#include <Kernel/API/InodeWatcherFlags.h>
|
||||
#include <LibCore/Notifier.h>
|
||||
|
@ -29,7 +29,7 @@ struct FileWatcherEvent {
|
|||
ChildDeleted = 1 << 4,
|
||||
};
|
||||
Type type;
|
||||
String event_path;
|
||||
DeprecatedString event_path;
|
||||
};
|
||||
|
||||
AK_ENUM_BITWISE_OPERATORS(FileWatcherEvent::Type);
|
||||
|
@ -38,9 +38,9 @@ class FileWatcherBase {
|
|||
public:
|
||||
virtual ~FileWatcherBase() = default;
|
||||
|
||||
ErrorOr<bool> add_watch(String path, FileWatcherEvent::Type event_mask);
|
||||
ErrorOr<bool> remove_watch(String path);
|
||||
bool is_watching(String const& path) const { return m_path_to_wd.find(path) != m_path_to_wd.end(); }
|
||||
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(); }
|
||||
|
||||
protected:
|
||||
FileWatcherBase(int watcher_fd)
|
||||
|
@ -49,8 +49,8 @@ protected:
|
|||
}
|
||||
|
||||
int m_watcher_fd { -1 };
|
||||
HashMap<String, unsigned> m_path_to_wd;
|
||||
HashMap<unsigned, String> m_wd_to_path;
|
||||
HashMap<DeprecatedString, unsigned> m_path_to_wd;
|
||||
HashMap<unsigned, DeprecatedString> m_wd_to_path;
|
||||
};
|
||||
|
||||
class BlockingFileWatcher final : public FileWatcherBase {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
ErrorOr<String> Group::generate_group_file() const
|
||||
ErrorOr<DeprecatedString> Group::generate_group_file() const
|
||||
{
|
||||
StringBuilder builder;
|
||||
|
||||
|
@ -32,13 +32,13 @@ ErrorOr<String> Group::generate_group_file() const
|
|||
for (auto const* gr = getgrent(); gr; gr = getgrent()) {
|
||||
#endif
|
||||
if (gr->gr_name == m_name)
|
||||
builder.appendff("{}:x:{}:{}\n", m_name, m_id, String::join(',', m_members));
|
||||
builder.appendff("{}:x:{}:{}\n", m_name, m_id, DeprecatedString::join(',', m_members));
|
||||
else {
|
||||
Vector<String> members;
|
||||
Vector<DeprecatedString> members;
|
||||
for (size_t i = 0; gr->gr_mem[i]; ++i)
|
||||
members.append(gr->gr_mem[i]);
|
||||
|
||||
builder.appendff("{}:x:{}:{}\n", gr->gr_name, gr->gr_gid, String::join(',', members));
|
||||
builder.appendff("{}:x:{}:{}\n", gr->gr_name, gr->gr_gid, DeprecatedString::join(',', members));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -135,7 +135,7 @@ ErrorOr<Vector<Group>> Group::all()
|
|||
#else
|
||||
for (auto const* gr = getgrent(); gr; gr = getgrent()) {
|
||||
#endif
|
||||
Vector<String> members;
|
||||
Vector<DeprecatedString> members;
|
||||
for (size_t i = 0; gr->gr_mem[i]; ++i)
|
||||
members.append(gr->gr_mem[i]);
|
||||
|
||||
|
@ -148,7 +148,7 @@ ErrorOr<Vector<Group>> Group::all()
|
|||
return groups;
|
||||
}
|
||||
|
||||
Group::Group(String name, gid_t id, Vector<String> members)
|
||||
Group::Group(DeprecatedString name, gid_t id, Vector<DeprecatedString> members)
|
||||
: m_name(move(name))
|
||||
, m_id(id)
|
||||
, m_members(move(members))
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <grp.h>
|
||||
|
||||
|
@ -22,17 +22,17 @@ public:
|
|||
static ErrorOr<Vector<Group>> all();
|
||||
|
||||
Group() = default;
|
||||
Group(String name, gid_t id = 0, Vector<String> members = {});
|
||||
Group(DeprecatedString name, gid_t id = 0, Vector<DeprecatedString> members = {});
|
||||
|
||||
~Group() = default;
|
||||
|
||||
String const& name() const { return m_name; }
|
||||
void set_name(String const& name) { m_name = name; }
|
||||
DeprecatedString const& name() const { return m_name; }
|
||||
void set_name(DeprecatedString const& name) { m_name = name; }
|
||||
|
||||
gid_t id() const { return m_id; }
|
||||
void set_group_id(gid_t const id) { m_id = id; }
|
||||
|
||||
Vector<String>& members() { return m_members; }
|
||||
Vector<DeprecatedString>& 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<String> generate_group_file() const;
|
||||
ErrorOr<DeprecatedString> generate_group_file() const;
|
||||
|
||||
String m_name;
|
||||
DeprecatedString m_name;
|
||||
gid_t m_id { 0 };
|
||||
Vector<String> m_members;
|
||||
Vector<DeprecatedString> m_members;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -153,7 +153,7 @@ ByteBuffer IODevice::read_all()
|
|||
return {};
|
||||
}
|
||||
|
||||
String IODevice::read_line(size_t max_size)
|
||||
DeprecatedString IODevice::read_line(size_t max_size)
|
||||
{
|
||||
if (m_fd < 0)
|
||||
return {};
|
||||
|
@ -166,7 +166,7 @@ String IODevice::read_line(size_t max_size)
|
|||
dbgln("IODevice::read_line: At EOF but there's more than max_size({}) buffered", max_size);
|
||||
return {};
|
||||
}
|
||||
auto line = String((char const*)m_buffered_data.data(), m_buffered_data.size(), Chomp);
|
||||
auto line = DeprecatedString((char const*)m_buffered_data.data(), m_buffered_data.size(), Chomp);
|
||||
m_buffered_data.clear();
|
||||
return line;
|
||||
}
|
||||
|
@ -185,7 +185,7 @@ String IODevice::read_line(size_t max_size)
|
|||
new_buffered_data.append(m_buffered_data.data() + line_index, m_buffered_data.size() - line_index);
|
||||
m_buffered_data = move(new_buffered_data);
|
||||
line.resize(line_index);
|
||||
return String::copy(line, Chomp);
|
||||
return DeprecatedString::copy(line, Chomp);
|
||||
}
|
||||
}
|
||||
return {};
|
||||
|
|
|
@ -34,7 +34,7 @@ public:
|
|||
private:
|
||||
NonnullRefPtr<IODevice> m_device;
|
||||
bool m_is_end { false };
|
||||
String m_buffer;
|
||||
DeprecatedString m_buffer;
|
||||
};
|
||||
|
||||
class LineRange {
|
||||
|
@ -89,7 +89,7 @@ public:
|
|||
|
||||
ByteBuffer read(size_t max_size);
|
||||
ByteBuffer read_all();
|
||||
String read_line(size_t max_size = 16384);
|
||||
DeprecatedString read_line(size_t max_size = 16384);
|
||||
|
||||
bool write(u8 const*, int size);
|
||||
bool write(StringView);
|
||||
|
|
|
@ -33,7 +33,7 @@ LocalServer::~LocalServer()
|
|||
::close(m_fd);
|
||||
}
|
||||
|
||||
ErrorOr<void> LocalServer::take_over_from_system_server(String const& socket_path)
|
||||
ErrorOr<void> LocalServer::take_over_from_system_server(DeprecatedString 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(String const& address)
|
||||
bool LocalServer::listen(DeprecatedString const& address)
|
||||
{
|
||||
if (m_listening)
|
||||
return false;
|
||||
|
|
|
@ -17,9 +17,9 @@ class LocalServer : public Object {
|
|||
public:
|
||||
virtual ~LocalServer() override;
|
||||
|
||||
ErrorOr<void> take_over_from_system_server(String const& path = String());
|
||||
ErrorOr<void> take_over_from_system_server(DeprecatedString const& path = DeprecatedString());
|
||||
bool is_listening() const { return m_listening; }
|
||||
bool listen(String const& address);
|
||||
bool listen(DeprecatedString const& address);
|
||||
|
||||
ErrorOr<NonnullOwnPtr<Stream::LocalSocket>> accept();
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/ScopeGuard.h>
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/MappedFile.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <fcntl.h>
|
||||
|
|
|
@ -10,9 +10,9 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
Vector<String> MimeData::formats() const
|
||||
Vector<DeprecatedString> MimeData::formats() const
|
||||
{
|
||||
Vector<String> mime_types;
|
||||
Vector<DeprecatedString> mime_types;
|
||||
mime_types.ensure_capacity(m_data.size());
|
||||
for (auto& it : m_data)
|
||||
mime_types.unchecked_append(it.key);
|
||||
|
@ -41,17 +41,17 @@ void MimeData::set_urls(Vector<URL> const& urls)
|
|||
set_data("text/uri-list", builder.to_byte_buffer());
|
||||
}
|
||||
|
||||
String MimeData::text() const
|
||||
DeprecatedString MimeData::text() const
|
||||
{
|
||||
return String::copy(m_data.get("text/plain").value_or({}));
|
||||
return DeprecatedString::copy(m_data.get("text/plain").value_or({}));
|
||||
}
|
||||
|
||||
void MimeData::set_text(String const& text)
|
||||
void MimeData::set_text(DeprecatedString const& text)
|
||||
{
|
||||
set_data("text/plain", text.to_byte_buffer());
|
||||
}
|
||||
|
||||
String guess_mime_type_based_on_filename(StringView path)
|
||||
DeprecatedString guess_mime_type_based_on_filename(StringView path)
|
||||
{
|
||||
if (path.ends_with(".pbm"sv, CaseSensitivity::CaseInsensitive))
|
||||
return "image/x‑portable‑bitmap";
|
||||
|
@ -164,7 +164,7 @@ String guess_mime_type_based_on_filename(StringView path)
|
|||
ENUMERATE_HEADER_CONTENTS
|
||||
#undef __ENUMERATE_MIME_TYPE_HEADER
|
||||
|
||||
Optional<String> guess_mime_type_based_on_sniffed_bytes(ReadonlyBytes bytes)
|
||||
Optional<DeprecatedString> guess_mime_type_based_on_sniffed_bytes(ReadonlyBytes bytes)
|
||||
{
|
||||
#define __ENUMERATE_MIME_TYPE_HEADER(var_name, mime_type, pattern_offset, pattern_size, ...) \
|
||||
if (static_cast<ssize_t>(bytes.size()) >= pattern_offset && bytes.slice(pattern_offset).starts_with(var_name)) \
|
||||
|
|
|
@ -20,36 +20,36 @@ class MimeData : public Object {
|
|||
public:
|
||||
virtual ~MimeData() = default;
|
||||
|
||||
ByteBuffer data(String const& mime_type) const { return m_data.get(mime_type).value_or({}); }
|
||||
void set_data(String const& mime_type, ByteBuffer&& data) { m_data.set(mime_type, move(data)); }
|
||||
ByteBuffer data(DeprecatedString const& mime_type) const { return m_data.get(mime_type).value_or({}); }
|
||||
void set_data(DeprecatedString const& mime_type, ByteBuffer&& data) { m_data.set(mime_type, move(data)); }
|
||||
|
||||
bool has_format(String const& mime_type) const { return m_data.contains(mime_type); }
|
||||
Vector<String> formats() const;
|
||||
bool has_format(DeprecatedString const& mime_type) const { return m_data.contains(mime_type); }
|
||||
Vector<DeprecatedString> formats() const;
|
||||
|
||||
// Convenience helpers for "text/plain"
|
||||
bool has_text() const { return has_format("text/plain"); }
|
||||
String text() const;
|
||||
void set_text(String const&);
|
||||
DeprecatedString text() const;
|
||||
void set_text(DeprecatedString const&);
|
||||
|
||||
// Convenience helpers for "text/uri-list"
|
||||
bool has_urls() const { return has_format("text/uri-list"); }
|
||||
Vector<URL> urls() const;
|
||||
void set_urls(Vector<URL> const&);
|
||||
|
||||
HashMap<String, ByteBuffer> const& all_data() const { return m_data; }
|
||||
HashMap<DeprecatedString, ByteBuffer> const& all_data() const { return m_data; }
|
||||
|
||||
private:
|
||||
MimeData() = default;
|
||||
explicit MimeData(HashMap<String, ByteBuffer> const& data)
|
||||
explicit MimeData(HashMap<DeprecatedString, ByteBuffer> const& data)
|
||||
: m_data(data)
|
||||
{
|
||||
}
|
||||
|
||||
HashMap<String, ByteBuffer> m_data;
|
||||
HashMap<DeprecatedString, ByteBuffer> m_data;
|
||||
};
|
||||
|
||||
String guess_mime_type_based_on_filename(StringView);
|
||||
DeprecatedString guess_mime_type_based_on_filename(StringView);
|
||||
|
||||
Optional<String> guess_mime_type_based_on_sniffed_bytes(ReadonlyBytes);
|
||||
Optional<DeprecatedString> guess_mime_type_based_on_sniffed_bytes(ReadonlyBytes);
|
||||
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
virtual ~NetworkJob() override = default;
|
||||
|
||||
// Could fire twice, after Headers and after Trailers!
|
||||
Function<void(HashMap<String, String, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code)> on_headers_received;
|
||||
Function<void(HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> const& response_headers, Optional<u32> response_code)> on_headers_received;
|
||||
Function<void(bool success)> on_finish;
|
||||
Function<void(Optional<u32>, u32)> on_progress;
|
||||
|
||||
|
|
|
@ -182,7 +182,7 @@ void Object::save_to(JsonObject& json)
|
|||
}
|
||||
}
|
||||
|
||||
JsonValue Object::property(String const& name) const
|
||||
JsonValue Object::property(DeprecatedString const& name) const
|
||||
{
|
||||
auto it = m_properties.find(name);
|
||||
if (it == m_properties.end())
|
||||
|
@ -190,7 +190,7 @@ JsonValue Object::property(String const& name) const
|
|||
return it->value->get();
|
||||
}
|
||||
|
||||
bool Object::set_property(String const& name, JsonValue const& value)
|
||||
bool Object::set_property(DeprecatedString const& name, JsonValue const& value)
|
||||
{
|
||||
auto it = m_properties.find(name);
|
||||
if (it == m_properties.end())
|
||||
|
@ -247,7 +247,7 @@ void Object::decrement_inspector_count(Badge<InspectorServerConnection>)
|
|||
did_end_inspection();
|
||||
}
|
||||
|
||||
void Object::register_property(String const& name, Function<JsonValue()> getter, Function<bool(JsonValue const&)> setter)
|
||||
void Object::register_property(DeprecatedString const& name, Function<JsonValue()> getter, Function<bool(JsonValue const&)> setter)
|
||||
{
|
||||
m_properties.set(name, make<Property>(name, move(getter), move(setter)));
|
||||
}
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <AK/HashMap.h>
|
||||
#include <AK/IntrusiveList.h>
|
||||
#include <AK/Noncopyable.h>
|
||||
#include <AK/NonnullRefPtrVector.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <AK/Weakable.h>
|
||||
|
@ -109,8 +109,8 @@ public:
|
|||
|
||||
virtual bool is_widget() const { return false; }
|
||||
|
||||
String const& name() const { return m_name; }
|
||||
void set_name(String name) { m_name = move(name); }
|
||||
DeprecatedString const& name() const { return m_name; }
|
||||
void set_name(DeprecatedString name) { m_name = move(name); }
|
||||
|
||||
NonnullRefPtrVector<Object>& children() { return m_children; }
|
||||
NonnullRefPtrVector<Object> const& children() const { return m_children; }
|
||||
|
@ -129,11 +129,11 @@ public:
|
|||
requires IsBaseOf<Object, T>;
|
||||
|
||||
template<typename T>
|
||||
T* find_child_of_type_named(String const&)
|
||||
T* find_child_of_type_named(DeprecatedString const&)
|
||||
requires IsBaseOf<Object, T>;
|
||||
|
||||
template<typename T>
|
||||
T* find_descendant_of_type_named(String const&)
|
||||
T* find_descendant_of_type_named(DeprecatedString const&)
|
||||
requires IsBaseOf<Object, T>;
|
||||
|
||||
bool is_ancestor_of(Object const&) const;
|
||||
|
@ -160,9 +160,9 @@ public:
|
|||
|
||||
void save_to(JsonObject&);
|
||||
|
||||
bool set_property(String const& name, JsonValue const& value);
|
||||
JsonValue property(String const& name) const;
|
||||
HashMap<String, NonnullOwnPtr<Property>> const& properties() const { return m_properties; }
|
||||
bool set_property(DeprecatedString const& name, JsonValue const& value);
|
||||
JsonValue property(DeprecatedString const& name) const;
|
||||
HashMap<DeprecatedString, NonnullOwnPtr<Property>> const& properties() const { return m_properties; }
|
||||
|
||||
static IntrusiveList<&Object::m_all_objects_list_node>& all_objects();
|
||||
|
||||
|
@ -200,7 +200,7 @@ public:
|
|||
protected:
|
||||
explicit Object(Object* parent = nullptr);
|
||||
|
||||
void register_property(String const& name, Function<JsonValue()> getter, Function<bool(JsonValue const&)> setter = nullptr);
|
||||
void register_property(DeprecatedString const& name, Function<JsonValue()> getter, Function<bool(JsonValue const&)> setter = nullptr);
|
||||
|
||||
virtual void event(Core::Event&);
|
||||
|
||||
|
@ -215,10 +215,10 @@ protected:
|
|||
|
||||
private:
|
||||
Object* m_parent { nullptr };
|
||||
String m_name;
|
||||
DeprecatedString m_name;
|
||||
int m_timer_id { 0 };
|
||||
unsigned m_inspector_count { 0 };
|
||||
HashMap<String, NonnullOwnPtr<Property>> m_properties;
|
||||
HashMap<DeprecatedString, NonnullOwnPtr<Property>> m_properties;
|
||||
NonnullRefPtrVector<Object> m_children;
|
||||
Function<bool(Core::Event&)> m_event_filter;
|
||||
};
|
||||
|
@ -246,7 +246,7 @@ requires IsBaseOf<Object, T>
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
T* Object::find_child_of_type_named(String const& name)
|
||||
T* Object::find_child_of_type_named(DeprecatedString const& name)
|
||||
requires IsBaseOf<Object, T>
|
||||
{
|
||||
T* found_child = nullptr;
|
||||
|
@ -262,7 +262,7 @@ requires IsBaseOf<Object, T>
|
|||
}
|
||||
|
||||
template<typename T>
|
||||
T* Object::find_descendant_of_type_named(String const& name)
|
||||
T* Object::find_descendant_of_type_named(DeprecatedString const& name)
|
||||
requires IsBaseOf<Object, T>
|
||||
{
|
||||
if (is<T>(*this) && this->name() == name) {
|
||||
|
@ -381,7 +381,7 @@ requires IsBaseOf<Object, T>
|
|||
[this]() -> JsonValue { \
|
||||
struct { \
|
||||
EnumType enum_value; \
|
||||
String string_value; \
|
||||
DeprecatedString string_value; \
|
||||
} options[] = { __VA_ARGS__ }; \
|
||||
auto enum_value = getter(); \
|
||||
for (size_t i = 0; i < array_size(options); ++i) { \
|
||||
|
@ -394,7 +394,7 @@ requires IsBaseOf<Object, T>
|
|||
[this](auto& value) { \
|
||||
struct { \
|
||||
EnumType enum_value; \
|
||||
String string_value; \
|
||||
DeprecatedString string_value; \
|
||||
} options[] = { __VA_ARGS__ }; \
|
||||
if (!value.is_string()) \
|
||||
return false; \
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/Process.h>
|
||||
#include <LibCore/System.h>
|
||||
|
@ -21,11 +21,11 @@ extern char** environ;
|
|||
namespace Core {
|
||||
|
||||
struct ArgvList {
|
||||
String m_path;
|
||||
String m_working_directory;
|
||||
DeprecatedString m_path;
|
||||
DeprecatedString m_working_directory;
|
||||
Vector<char const*, 10> m_argv;
|
||||
|
||||
ArgvList(String path, size_t size)
|
||||
ArgvList(DeprecatedString path, size_t size)
|
||||
: m_path { path }
|
||||
{
|
||||
m_argv.ensure_capacity(size + 2);
|
||||
|
@ -44,7 +44,7 @@ struct ArgvList {
|
|||
return m_argv;
|
||||
}
|
||||
|
||||
void set_working_directory(String const& working_directory)
|
||||
void set_working_directory(DeprecatedString const& working_directory)
|
||||
{
|
||||
m_working_directory = working_directory;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ struct ArgvList {
|
|||
}
|
||||
};
|
||||
|
||||
ErrorOr<pid_t> Process::spawn(StringView path, Span<String const> arguments, String working_directory)
|
||||
ErrorOr<pid_t> Process::spawn(StringView path, Span<DeprecatedString const> arguments, DeprecatedString working_directory)
|
||||
{
|
||||
ArgvList argv { path, arguments.size() };
|
||||
for (auto const& arg : arguments)
|
||||
|
@ -75,9 +75,9 @@ ErrorOr<pid_t> Process::spawn(StringView path, Span<String const> arguments, Str
|
|||
return argv.spawn();
|
||||
}
|
||||
|
||||
ErrorOr<pid_t> Process::spawn(StringView path, Span<StringView const> arguments, String working_directory)
|
||||
ErrorOr<pid_t> Process::spawn(StringView path, Span<StringView const> arguments, DeprecatedString working_directory)
|
||||
{
|
||||
Vector<String> backing_strings;
|
||||
Vector<DeprecatedString> backing_strings;
|
||||
backing_strings.ensure_capacity(arguments.size());
|
||||
ArgvList argv { path, arguments.size() };
|
||||
for (auto const& arg : arguments) {
|
||||
|
@ -88,7 +88,7 @@ ErrorOr<pid_t> Process::spawn(StringView path, Span<StringView const> arguments,
|
|||
return argv.spawn();
|
||||
}
|
||||
|
||||
ErrorOr<pid_t> Process::spawn(StringView path, Span<char const* const> arguments, String working_directory)
|
||||
ErrorOr<pid_t> Process::spawn(StringView path, Span<char const* const> arguments, DeprecatedString working_directory)
|
||||
{
|
||||
ArgvList argv { path, arguments.size() };
|
||||
for (auto arg : arguments)
|
||||
|
|
|
@ -14,9 +14,9 @@ namespace Core {
|
|||
|
||||
class Process {
|
||||
public:
|
||||
static ErrorOr<pid_t> spawn(StringView path, Span<String const> arguments, String working_directory = {});
|
||||
static ErrorOr<pid_t> spawn(StringView path, Span<StringView const> arguments, String working_directory = {});
|
||||
static ErrorOr<pid_t> spawn(StringView path, Span<char const* const> arguments = {}, String working_directory = {});
|
||||
static ErrorOr<pid_t> spawn(StringView path, Span<DeprecatedString const> arguments, DeprecatedString working_directory = {});
|
||||
static ErrorOr<pid_t> spawn(StringView path, Span<StringView const> arguments, DeprecatedString working_directory = {});
|
||||
static ErrorOr<pid_t> spawn(StringView path, Span<char const* const> arguments = {}, DeprecatedString working_directory = {});
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
HashMap<uid_t, String> ProcessStatisticsReader::s_usernames;
|
||||
HashMap<uid_t, DeprecatedString> ProcessStatisticsReader::s_usernames;
|
||||
|
||||
Optional<AllProcessesStatistics> ProcessStatisticsReader::get_all(RefPtr<Core::File>& proc_all_file, bool include_usernames)
|
||||
{
|
||||
|
@ -110,7 +110,7 @@ Optional<AllProcessesStatistics> ProcessStatisticsReader::get_all(bool include_u
|
|||
return get_all(proc_all_file, include_usernames);
|
||||
}
|
||||
|
||||
String ProcessStatisticsReader::username_from_uid(uid_t uid)
|
||||
DeprecatedString ProcessStatisticsReader::username_from_uid(uid_t uid)
|
||||
{
|
||||
if (s_usernames.is_empty()) {
|
||||
setpwent();
|
||||
|
@ -122,6 +122,6 @@ String ProcessStatisticsReader::username_from_uid(uid_t uid)
|
|||
auto it = s_usernames.find(uid);
|
||||
if (it != s_usernames.end())
|
||||
return (*it).value;
|
||||
return String::number(uid);
|
||||
return DeprecatedString::number(uid);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <unistd.h>
|
||||
|
||||
|
@ -27,10 +27,10 @@ struct ThreadStatistics {
|
|||
unsigned ipv4_socket_write_bytes;
|
||||
unsigned file_read_bytes;
|
||||
unsigned file_write_bytes;
|
||||
String state;
|
||||
DeprecatedString state;
|
||||
u32 cpu;
|
||||
u32 priority;
|
||||
String name;
|
||||
DeprecatedString name;
|
||||
};
|
||||
|
||||
struct ProcessStatistics {
|
||||
|
@ -45,11 +45,11 @@ struct ProcessStatistics {
|
|||
pid_t ppid;
|
||||
unsigned nfds;
|
||||
bool kernel;
|
||||
String name;
|
||||
String executable;
|
||||
String tty;
|
||||
String pledge;
|
||||
String veil;
|
||||
DeprecatedString name;
|
||||
DeprecatedString executable;
|
||||
DeprecatedString tty;
|
||||
DeprecatedString pledge;
|
||||
DeprecatedString veil;
|
||||
size_t amount_virtual;
|
||||
size_t amount_resident;
|
||||
size_t amount_shared;
|
||||
|
@ -61,7 +61,7 @@ struct ProcessStatistics {
|
|||
Vector<Core::ThreadStatistics> threads;
|
||||
|
||||
// synthetic
|
||||
String username;
|
||||
DeprecatedString username;
|
||||
};
|
||||
|
||||
struct AllProcessesStatistics {
|
||||
|
@ -76,8 +76,8 @@ public:
|
|||
static Optional<AllProcessesStatistics> get_all(bool include_usernames = true);
|
||||
|
||||
private:
|
||||
static String username_from_uid(uid_t);
|
||||
static HashMap<uid_t, String> s_usernames;
|
||||
static DeprecatedString username_from_uid(uid_t);
|
||||
static HashMap<uid_t, DeprecatedString> s_usernames;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
Property::Property(String name, Function<JsonValue()> getter, Function<bool(JsonValue const&)> setter)
|
||||
Property::Property(DeprecatedString name, Function<JsonValue()> getter, Function<bool(JsonValue const&)> setter)
|
||||
: m_name(move(name))
|
||||
, m_getter(move(getter))
|
||||
, m_setter(move(setter))
|
||||
|
|
|
@ -16,7 +16,7 @@ class Property {
|
|||
AK_MAKE_NONCOPYABLE(Property);
|
||||
|
||||
public:
|
||||
Property(String name, Function<JsonValue()> getter, Function<bool(JsonValue const&)> setter = nullptr);
|
||||
Property(DeprecatedString name, Function<JsonValue()> getter, Function<bool(JsonValue const&)> setter = nullptr);
|
||||
~Property() = default;
|
||||
|
||||
bool set(JsonValue const& value)
|
||||
|
@ -28,11 +28,11 @@ public:
|
|||
|
||||
JsonValue get() const { return m_getter(); }
|
||||
|
||||
String const& name() const { return m_name; }
|
||||
DeprecatedString const& name() const { return m_name; }
|
||||
bool is_readonly() const { return !m_setter; }
|
||||
|
||||
private:
|
||||
String m_name;
|
||||
DeprecatedString m_name;
|
||||
Function<JsonValue()> m_getter;
|
||||
Function<bool(JsonValue const&)> m_setter;
|
||||
};
|
||||
|
|
|
@ -138,7 +138,7 @@ ErrorOr<Reply> send_connect_request_message(Core::Stream::Socket& socket, Core::
|
|||
return Error::from_string_literal("SOCKS negotiation failed: Failed to send connect request header");
|
||||
|
||||
TRY(target.visit(
|
||||
[&](String const& hostname) -> ErrorOr<void> {
|
||||
[&](DeprecatedString const& hostname) -> ErrorOr<void> {
|
||||
u8 address_data[2];
|
||||
address_data[0] = to_underlying(AddressType::DomainName);
|
||||
address_data[1] = hostname.length();
|
||||
|
@ -312,7 +312,7 @@ ErrorOr<NonnullOwnPtr<SOCKSProxyClient>> SOCKSProxyClient::connect(HostOrIPV4 co
|
|||
[&](u32 ipv4) {
|
||||
return Core::Stream::TCPSocket::connect({ IPv4Address(ipv4), static_cast<u16>(server_port) });
|
||||
},
|
||||
[&](String const& hostname) {
|
||||
[&](DeprecatedString const& hostname) {
|
||||
return Core::Stream::TCPSocket::connect(hostname, static_cast<u16>(server_port));
|
||||
}));
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ public:
|
|||
};
|
||||
|
||||
struct UsernamePasswordAuthenticationData {
|
||||
String username;
|
||||
String password;
|
||||
DeprecatedString username;
|
||||
DeprecatedString password;
|
||||
};
|
||||
|
||||
enum class Command : u8 {
|
||||
|
@ -29,7 +29,7 @@ public:
|
|||
UDPAssociate = 0x03,
|
||||
};
|
||||
|
||||
using HostOrIPV4 = Variant<String, u32>;
|
||||
using HostOrIPV4 = Variant<DeprecatedString, 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);
|
||||
|
|
|
@ -47,19 +47,19 @@ ErrorOr<void> logout(Optional<pid_t> force_sid)
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<String> parse_path_with_sid(StringView general_path, Optional<pid_t> force_sid)
|
||||
ErrorOr<DeprecatedString> 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, String::number(sid), ReplaceMode::All);
|
||||
return general_path.replace("%sid"sv, DeprecatedString::number(sid), ReplaceMode::All);
|
||||
}
|
||||
return String(general_path);
|
||||
return DeprecatedString(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 = String::formatted("/tmp/session/{}", sid);
|
||||
auto const temporary_directory = DeprecatedString::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<String> parse_path_with_sid(StringView general_path, Optional<pid_t> force_sid = {});
|
||||
ErrorOr<DeprecatedString> 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 = {});
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <AK/Atomic.h>
|
||||
#include <AK/BuiltinWrappers.h>
|
||||
#include <AK/Debug.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Error.h>
|
||||
#include <AK/Format.h>
|
||||
#include <AK/Function.h>
|
||||
|
@ -18,7 +19,6 @@
|
|||
#include <AK/Platform.h>
|
||||
#include <AK/RefCounted.h>
|
||||
#include <AK/RefPtr.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Types.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <AK/Weakable.h>
|
||||
|
@ -200,7 +200,7 @@ private:
|
|||
|
||||
static ErrorOr<SharedSingleProducerCircularQueue<T, Size>> try_create_internal(int fd, bool is_new)
|
||||
{
|
||||
auto name = String::formatted("SharedSingleProducerCircularQueue@{:x}", fd);
|
||||
auto name = DeprecatedString::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(String name, RefPtr<RefCountedSharedMemorySPCQ> queue)
|
||||
SharedSingleProducerCircularQueue(DeprecatedString name, RefPtr<RefCountedSharedMemorySPCQ> queue)
|
||||
: m_queue(queue)
|
||||
, m_name(move(name))
|
||||
{
|
||||
|
@ -220,7 +220,7 @@ private:
|
|||
|
||||
RefPtr<RefCountedSharedMemorySPCQ> m_queue;
|
||||
|
||||
String m_name {};
|
||||
DeprecatedString m_name {};
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
static SocketAddress local(String const& address)
|
||||
static SocketAddress local(DeprecatedString 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; }
|
||||
|
||||
String to_string() const
|
||||
DeprecatedString to_string() const
|
||||
{
|
||||
switch (m_type) {
|
||||
case Type::IPv4:
|
||||
return String::formatted("{}:{}", m_ipv4_address, m_port);
|
||||
return DeprecatedString::formatted("{}:{}", m_ipv4_address, m_port);
|
||||
case Type::Local:
|
||||
return m_local_address;
|
||||
default:
|
||||
|
@ -88,15 +88,15 @@ private:
|
|||
Type m_type { Type::Invalid };
|
||||
IPv4Address m_ipv4_address;
|
||||
u16 m_port { 0 };
|
||||
String m_local_address;
|
||||
DeprecatedString m_local_address;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
template<>
|
||||
struct AK::Formatter<Core::SocketAddress> : Formatter<String> {
|
||||
struct AK::Formatter<Core::SocketAddress> : Formatter<DeprecatedString> {
|
||||
ErrorOr<void> format(FormatBuilder& builder, Core::SocketAddress const& value)
|
||||
{
|
||||
return Formatter<String>::format(builder, value.to_string());
|
||||
return Formatter<DeprecatedString>::format(builder, value.to_string());
|
||||
}
|
||||
};
|
||||
|
|
|
@ -4,8 +4,8 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/StringBuilder.h>
|
||||
#include <LibCore/StandardPaths.h>
|
||||
#include <pwd.h>
|
||||
|
@ -14,18 +14,18 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
String StandardPaths::home_directory()
|
||||
DeprecatedString StandardPaths::home_directory()
|
||||
{
|
||||
if (auto* home_env = getenv("HOME"))
|
||||
return LexicalPath::canonicalized_path(home_env);
|
||||
|
||||
auto* pwd = getpwuid(getuid());
|
||||
String path = pwd ? pwd->pw_dir : "/";
|
||||
DeprecatedString path = pwd ? pwd->pw_dir : "/";
|
||||
endpwent();
|
||||
return LexicalPath::canonicalized_path(path);
|
||||
}
|
||||
|
||||
String StandardPaths::desktop_directory()
|
||||
DeprecatedString StandardPaths::desktop_directory()
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(home_directory());
|
||||
|
@ -33,7 +33,7 @@ String StandardPaths::desktop_directory()
|
|||
return LexicalPath::canonicalized_path(builder.to_string());
|
||||
}
|
||||
|
||||
String StandardPaths::documents_directory()
|
||||
DeprecatedString StandardPaths::documents_directory()
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(home_directory());
|
||||
|
@ -41,7 +41,7 @@ String StandardPaths::documents_directory()
|
|||
return LexicalPath::canonicalized_path(builder.to_string());
|
||||
}
|
||||
|
||||
String StandardPaths::downloads_directory()
|
||||
DeprecatedString StandardPaths::downloads_directory()
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(home_directory());
|
||||
|
@ -49,7 +49,7 @@ String StandardPaths::downloads_directory()
|
|||
return LexicalPath::canonicalized_path(builder.to_string());
|
||||
}
|
||||
|
||||
String StandardPaths::config_directory()
|
||||
DeprecatedString StandardPaths::config_directory()
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.append(home_directory());
|
||||
|
@ -57,7 +57,7 @@ String StandardPaths::config_directory()
|
|||
return LexicalPath::canonicalized_path(builder.to_string());
|
||||
}
|
||||
|
||||
String StandardPaths::tempfile_directory()
|
||||
DeprecatedString StandardPaths::tempfile_directory()
|
||||
{
|
||||
return "/tmp";
|
||||
}
|
||||
|
|
|
@ -12,12 +12,12 @@ namespace Core {
|
|||
|
||||
class StandardPaths {
|
||||
public:
|
||||
static String home_directory();
|
||||
static String desktop_directory();
|
||||
static String documents_directory();
|
||||
static String downloads_directory();
|
||||
static String tempfile_directory();
|
||||
static String config_directory();
|
||||
static DeprecatedString home_directory();
|
||||
static DeprecatedString desktop_directory();
|
||||
static DeprecatedString documents_directory();
|
||||
static DeprecatedString downloads_directory();
|
||||
static DeprecatedString tempfile_directory();
|
||||
static DeprecatedString config_directory();
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -353,7 +353,7 @@ ErrorOr<int> Socket::create_fd(SocketDomain domain, SocketType type)
|
|||
#endif
|
||||
}
|
||||
|
||||
ErrorOr<IPv4Address> Socket::resolve_host(String const& host, SocketType type)
|
||||
ErrorOr<IPv4Address> Socket::resolve_host(DeprecatedString const& host, SocketType type)
|
||||
{
|
||||
int socket_type;
|
||||
switch (type) {
|
||||
|
@ -398,7 +398,7 @@ ErrorOr<IPv4Address> Socket::resolve_host(String const& host, SocketType type)
|
|||
return Error::from_string_literal("Could not resolve to IPv4 address");
|
||||
}
|
||||
|
||||
ErrorOr<void> Socket::connect_local(int fd, String const& path)
|
||||
ErrorOr<void> Socket::connect_local(int fd, DeprecatedString const& path)
|
||||
{
|
||||
auto address = SocketAddress::local(path);
|
||||
auto maybe_sockaddr = address.to_sockaddr_un();
|
||||
|
@ -510,7 +510,7 @@ void PosixSocketHelper::setup_notifier()
|
|||
m_notifier = Core::Notifier::construct(m_fd, Core::Notifier::Read);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullOwnPtr<TCPSocket>> TCPSocket::connect(String const& host, u16 port)
|
||||
ErrorOr<NonnullOwnPtr<TCPSocket>> TCPSocket::connect(DeprecatedString const& host, u16 port)
|
||||
{
|
||||
auto ip_address = TRY(resolve_host(host, SocketType::Stream));
|
||||
return connect(SocketAddress { ip_address, port });
|
||||
|
@ -552,7 +552,7 @@ ErrorOr<size_t> PosixSocketHelper::pending_bytes() const
|
|||
return static_cast<size_t>(value);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullOwnPtr<UDPSocket>> UDPSocket::connect(String const& host, u16 port, Optional<Time> timeout)
|
||||
ErrorOr<NonnullOwnPtr<UDPSocket>> UDPSocket::connect(DeprecatedString const& host, u16 port, Optional<Time> timeout)
|
||||
{
|
||||
auto ip_address = TRY(resolve_host(host, SocketType::Datagram));
|
||||
return connect(SocketAddress { ip_address, port }, timeout);
|
||||
|
@ -574,7 +574,7 @@ ErrorOr<NonnullOwnPtr<UDPSocket>> UDPSocket::connect(SocketAddress const& addres
|
|||
return socket;
|
||||
}
|
||||
|
||||
ErrorOr<NonnullOwnPtr<LocalSocket>> LocalSocket::connect(String const& path, PreventSIGPIPE prevent_sigpipe)
|
||||
ErrorOr<NonnullOwnPtr<LocalSocket>> LocalSocket::connect(DeprecatedString const& path, PreventSIGPIPE prevent_sigpipe)
|
||||
{
|
||||
auto socket = TRY(adopt_nonnull_own_or_enomem(new (nothrow) LocalSocket(prevent_sigpipe)));
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/EnumBits.h>
|
||||
#include <AK/Function.h>
|
||||
#include <AK/IPv4Address.h>
|
||||
|
@ -14,7 +15,6 @@
|
|||
#include <AK/Noncopyable.h>
|
||||
#include <AK/Result.h>
|
||||
#include <AK/Span.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Time.h>
|
||||
#include <AK/Variant.h>
|
||||
#include <LibCore/Notifier.h>
|
||||
|
@ -162,9 +162,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(String const&, SocketType);
|
||||
static ErrorOr<IPv4Address> resolve_host(DeprecatedString const&, SocketType);
|
||||
|
||||
static ErrorOr<void> connect_local(int fd, String const& path);
|
||||
static ErrorOr<void> connect_local(int fd, DeprecatedString const& path);
|
||||
static ErrorOr<void> connect_inet(int fd, SocketAddress const&);
|
||||
|
||||
int default_flags() const
|
||||
|
@ -187,7 +187,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(String const& host, u16 port) = 0;
|
||||
virtual ErrorOr<void> reconnect(DeprecatedString 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;
|
||||
|
@ -325,7 +325,7 @@ private:
|
|||
|
||||
class TCPSocket final : public Socket {
|
||||
public:
|
||||
static ErrorOr<NonnullOwnPtr<TCPSocket>> connect(String const& host, u16 port);
|
||||
static ErrorOr<NonnullOwnPtr<TCPSocket>> connect(DeprecatedString const& host, u16 port);
|
||||
static ErrorOr<NonnullOwnPtr<TCPSocket>> connect(SocketAddress const& address);
|
||||
static ErrorOr<NonnullOwnPtr<TCPSocket>> adopt_fd(int fd);
|
||||
|
||||
|
@ -388,7 +388,7 @@ private:
|
|||
|
||||
class UDPSocket final : public Socket {
|
||||
public:
|
||||
static ErrorOr<NonnullOwnPtr<UDPSocket>> connect(String const& host, u16 port, Optional<Time> timeout = {});
|
||||
static ErrorOr<NonnullOwnPtr<UDPSocket>> connect(DeprecatedString const& host, u16 port, Optional<Time> timeout = {});
|
||||
static ErrorOr<NonnullOwnPtr<UDPSocket>> connect(SocketAddress const& address, Optional<Time> timeout = {});
|
||||
|
||||
UDPSocket(UDPSocket&& other)
|
||||
|
@ -464,7 +464,7 @@ private:
|
|||
|
||||
class LocalSocket final : public Socket {
|
||||
public:
|
||||
static ErrorOr<NonnullOwnPtr<LocalSocket>> connect(String const& path, PreventSIGPIPE = PreventSIGPIPE::No);
|
||||
static ErrorOr<NonnullOwnPtr<LocalSocket>> connect(DeprecatedString const& path, PreventSIGPIPE = PreventSIGPIPE::No);
|
||||
static ErrorOr<NonnullOwnPtr<LocalSocket>> adopt_fd(int fd, PreventSIGPIPE = PreventSIGPIPE::No);
|
||||
|
||||
LocalSocket(LocalSocket&& other)
|
||||
|
@ -945,7 +945,7 @@ using BufferedLocalSocket = BufferedSocket<LocalSocket>;
|
|||
template<SocketLike T>
|
||||
class BasicReusableSocket final : public ReusableSocket {
|
||||
public:
|
||||
static ErrorOr<NonnullOwnPtr<BasicReusableSocket<T>>> connect(String const& host, u16 port)
|
||||
static ErrorOr<NonnullOwnPtr<BasicReusableSocket<T>>> connect(DeprecatedString const& host, u16 port)
|
||||
{
|
||||
return make<BasicReusableSocket<T>>(TRY(T::connect(host, port)));
|
||||
}
|
||||
|
@ -960,7 +960,7 @@ public:
|
|||
return m_socket.is_open();
|
||||
}
|
||||
|
||||
virtual ErrorOr<void> reconnect(String const& host, u16 port) override
|
||||
virtual ErrorOr<void> reconnect(DeprecatedString const& host, u16 port) override
|
||||
{
|
||||
if (is_connected())
|
||||
return Error::from_errno(EALREADY);
|
||||
|
|
|
@ -7,10 +7,10 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/FixedArray.h>
|
||||
#include <AK/ScopedValueRollback.h>
|
||||
#include <AK/StdLibExtras.h>
|
||||
#include <AK/String.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/SessionManagement.h>
|
||||
|
@ -338,7 +338,7 @@ ErrorOr<int> anon_create([[maybe_unused]] size_t size, [[maybe_unused]] int opti
|
|||
#elif defined(AK_OS_MACOS) || defined(AK_OS_EMSCRIPTEN)
|
||||
struct timespec time;
|
||||
clock_gettime(CLOCK_REALTIME, &time);
|
||||
auto name = String::formatted("/shm-{}{}", (unsigned long)time.tv_sec, (unsigned long)time.tv_nsec);
|
||||
auto name = DeprecatedString::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) {
|
||||
|
@ -383,7 +383,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.
|
||||
String path_string = path;
|
||||
DeprecatedString path_string = path;
|
||||
int rc = ::openat(fd, path_string.characters(), options, mode);
|
||||
if (rc < 0)
|
||||
return Error::from_syscall("open"sv, -errno);
|
||||
|
@ -416,7 +416,7 @@ ErrorOr<struct stat> stat(StringView path)
|
|||
int rc = syscall(SC_stat, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("stat", rc, st);
|
||||
#else
|
||||
String path_string = path;
|
||||
DeprecatedString path_string = path;
|
||||
if (::stat(path_string.characters(), &st) < 0)
|
||||
return Error::from_syscall("stat"sv, -errno);
|
||||
return st;
|
||||
|
@ -434,7 +434,7 @@ ErrorOr<struct stat> lstat(StringView path)
|
|||
int rc = syscall(SC_stat, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("lstat", rc, st);
|
||||
#else
|
||||
String path_string = path;
|
||||
DeprecatedString path_string = path;
|
||||
if (::stat(path_string.characters(), &st) < 0)
|
||||
return Error::from_syscall("lstat"sv, -errno);
|
||||
return st;
|
||||
|
@ -487,21 +487,21 @@ ErrorOr<int> dup2(int source_fd, int destination_fd)
|
|||
return fd;
|
||||
}
|
||||
|
||||
ErrorOr<String> ptsname(int fd)
|
||||
ErrorOr<DeprecatedString> ptsname(int fd)
|
||||
{
|
||||
auto* name = ::ptsname(fd);
|
||||
if (!name)
|
||||
return Error::from_syscall("ptsname"sv, -errno);
|
||||
return String(name);
|
||||
return DeprecatedString(name);
|
||||
}
|
||||
|
||||
ErrorOr<String> gethostname()
|
||||
ErrorOr<DeprecatedString> gethostname()
|
||||
{
|
||||
char hostname[HOST_NAME_MAX];
|
||||
int rc = ::gethostname(hostname, sizeof(hostname));
|
||||
if (rc < 0)
|
||||
return Error::from_syscall("gethostname"sv, -errno);
|
||||
return String(&hostname[0]);
|
||||
return DeprecatedString(&hostname[0]);
|
||||
}
|
||||
|
||||
ErrorOr<void> sethostname(StringView hostname)
|
||||
|
@ -512,13 +512,13 @@ ErrorOr<void> sethostname(StringView hostname)
|
|||
return {};
|
||||
}
|
||||
|
||||
ErrorOr<String> getcwd()
|
||||
ErrorOr<DeprecatedString> getcwd()
|
||||
{
|
||||
auto* cwd = ::getcwd(nullptr, 0);
|
||||
if (!cwd)
|
||||
return Error::from_syscall("getcwd"sv, -errno);
|
||||
|
||||
String string_cwd(cwd);
|
||||
DeprecatedString string_cwd(cwd);
|
||||
free(cwd);
|
||||
return string_cwd;
|
||||
}
|
||||
|
@ -572,7 +572,7 @@ ErrorOr<void> chmod(StringView pathname, mode_t mode)
|
|||
int rc = syscall(SC_chmod, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("chmod", rc, {});
|
||||
#else
|
||||
String path = pathname;
|
||||
DeprecatedString path = pathname;
|
||||
if (::chmod(path.characters(), mode) < 0)
|
||||
return Error::from_syscall("chmod"sv, -errno);
|
||||
return {};
|
||||
|
@ -603,7 +603,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
|
||||
String path = pathname;
|
||||
DeprecatedString path = pathname;
|
||||
if (::chown(path.characters(), uid, gid) < 0)
|
||||
return Error::from_syscall("chown"sv, -errno);
|
||||
return {};
|
||||
|
@ -620,7 +620,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
|
||||
String path = pathname;
|
||||
DeprecatedString path = pathname;
|
||||
if (::lchown(path.characters(), uid, gid) < 0)
|
||||
return Error::from_syscall("lchown"sv, -errno);
|
||||
return {};
|
||||
|
@ -825,8 +825,8 @@ ErrorOr<void> link(StringView old_path, StringView new_path)
|
|||
int rc = syscall(SC_link, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("link", rc, {});
|
||||
#else
|
||||
String old_path_string = old_path;
|
||||
String new_path_string = new_path;
|
||||
DeprecatedString old_path_string = old_path;
|
||||
DeprecatedString new_path_string = new_path;
|
||||
if (::link(old_path_string.characters(), new_path_string.characters()) < 0)
|
||||
return Error::from_syscall("link"sv, -errno);
|
||||
return {};
|
||||
|
@ -843,8 +843,8 @@ ErrorOr<void> symlink(StringView target, StringView link_path)
|
|||
int rc = syscall(SC_symlink, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("symlink", rc, {});
|
||||
#else
|
||||
String target_string = target;
|
||||
String link_path_string = link_path;
|
||||
DeprecatedString target_string = target;
|
||||
DeprecatedString link_path_string = link_path;
|
||||
if (::symlink(target_string.characters(), link_path_string.characters()) < 0)
|
||||
return Error::from_syscall("symlink"sv, -errno);
|
||||
return {};
|
||||
|
@ -859,7 +859,7 @@ ErrorOr<void> mkdir(StringView path, mode_t mode)
|
|||
int rc = syscall(SC_mkdir, path.characters_without_null_termination(), path.length(), mode);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("mkdir", rc, {});
|
||||
#else
|
||||
String path_string = path;
|
||||
DeprecatedString path_string = path;
|
||||
if (::mkdir(path_string.characters(), mode) < 0)
|
||||
return Error::from_syscall("mkdir"sv, -errno);
|
||||
return {};
|
||||
|
@ -874,7 +874,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
|
||||
String path_string = path;
|
||||
DeprecatedString path_string = path;
|
||||
if (::chdir(path_string.characters()) < 0)
|
||||
return Error::from_syscall("chdir"sv, -errno);
|
||||
return {};
|
||||
|
@ -889,7 +889,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
|
||||
String path_string = path;
|
||||
DeprecatedString path_string = path;
|
||||
if (::rmdir(path_string.characters()) < 0)
|
||||
return Error::from_syscall("rmdir"sv, -errno);
|
||||
return {};
|
||||
|
@ -925,8 +925,8 @@ ErrorOr<void> rename(StringView old_path, StringView new_path)
|
|||
int rc = syscall(SC_rename, ¶ms);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("rename", rc, {});
|
||||
#else
|
||||
String old_path_string = old_path;
|
||||
String new_path_string = new_path;
|
||||
DeprecatedString old_path_string = old_path;
|
||||
DeprecatedString new_path_string = new_path;
|
||||
if (::rename(old_path_string.characters(), new_path_string.characters()) < 0)
|
||||
return Error::from_syscall("rename"sv, -errno);
|
||||
return {};
|
||||
|
@ -942,7 +942,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
|
||||
String path_string = path;
|
||||
DeprecatedString path_string = path;
|
||||
if (::unlink(path_string.characters()) < 0)
|
||||
return Error::from_syscall("unlink"sv, -errno);
|
||||
return {};
|
||||
|
@ -961,7 +961,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
|
||||
String path_string = path;
|
||||
DeprecatedString path_string = path;
|
||||
if (::utime(path_string.characters(), buf) < 0)
|
||||
return Error::from_syscall("utime"sv, -errno);
|
||||
return {};
|
||||
|
@ -1072,7 +1072,7 @@ ErrorOr<void> exec(StringView filename, Span<StringView> arguments, SearchInPath
|
|||
return {};
|
||||
};
|
||||
|
||||
String exec_filename;
|
||||
DeprecatedString exec_filename;
|
||||
|
||||
if (search_in_path == SearchInPath::Yes) {
|
||||
auto maybe_executable = Core::File::resolve_executable_from_environment(filename);
|
||||
|
@ -1089,9 +1089,9 @@ ErrorOr<void> exec(StringView filename, Span<StringView> arguments, SearchInPath
|
|||
TRY(run_exec(params));
|
||||
VERIFY_NOT_REACHED();
|
||||
#else
|
||||
String filename_string { filename };
|
||||
DeprecatedString filename_string { filename };
|
||||
|
||||
auto argument_strings = TRY(FixedArray<String>::try_create(arguments.size()));
|
||||
auto argument_strings = TRY(FixedArray<DeprecatedString>::try_create(arguments.size()));
|
||||
auto argv = TRY(FixedArray<char*>::try_create(arguments.size() + 1));
|
||||
for (size_t i = 0; i < arguments.size(); ++i) {
|
||||
argument_strings[i] = arguments[i].to_string();
|
||||
|
@ -1101,7 +1101,7 @@ ErrorOr<void> exec(StringView filename, Span<StringView> arguments, SearchInPath
|
|||
|
||||
int rc = 0;
|
||||
if (environment.has_value()) {
|
||||
auto environment_strings = TRY(FixedArray<String>::try_create(environment->size()));
|
||||
auto environment_strings = TRY(FixedArray<DeprecatedString>::try_create(environment->size()));
|
||||
auto envp = TRY(FixedArray<char*>::try_create(environment->size() + 1));
|
||||
for (size_t i = 0; i < environment->size(); ++i) {
|
||||
environment_strings[i] = environment->at(i).to_string();
|
||||
|
@ -1313,7 +1313,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
|
||||
String path_string = pathname;
|
||||
DeprecatedString path_string = pathname;
|
||||
if (::mknod(path_string.characters(), mode, dev) < 0)
|
||||
return Error::from_syscall("mknod"sv, -errno);
|
||||
return {};
|
||||
|
@ -1330,8 +1330,8 @@ ErrorOr<void> setenv(StringView name, StringView value, bool overwrite)
|
|||
#ifdef AK_OS_SERENITY
|
||||
auto const rc = ::serenity_setenv(name.characters_without_null_termination(), name.length(), value.characters_without_null_termination(), value.length(), overwrite);
|
||||
#else
|
||||
String name_string = name;
|
||||
String value_string = value;
|
||||
DeprecatedString name_string = name;
|
||||
DeprecatedString value_string = value;
|
||||
auto const rc = ::setenv(name_string.characters(), value_string.characters(), overwrite);
|
||||
#endif
|
||||
if (rc < 0)
|
||||
|
@ -1372,14 +1372,14 @@ ErrorOr<void> access(StringView pathname, int mode)
|
|||
int rc = ::syscall(Syscall::SC_access, pathname.characters_without_null_termination(), pathname.length(), mode);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("access", rc, {});
|
||||
#else
|
||||
String path_string = pathname;
|
||||
DeprecatedString path_string = pathname;
|
||||
if (::access(path_string.characters(), mode) < 0)
|
||||
return Error::from_syscall("access"sv, -errno);
|
||||
return {};
|
||||
#endif
|
||||
}
|
||||
|
||||
ErrorOr<String> readlink(StringView pathname)
|
||||
ErrorOr<DeprecatedString> readlink(StringView pathname)
|
||||
{
|
||||
// FIXME: Try again with a larger buffer.
|
||||
char data[PATH_MAX];
|
||||
|
@ -1389,14 +1389,14 @@ ErrorOr<String> readlink(StringView pathname)
|
|||
{ data, sizeof(data) }
|
||||
};
|
||||
int rc = syscall(SC_readlink, &small_params);
|
||||
HANDLE_SYSCALL_RETURN_VALUE("readlink", rc, String(data, rc));
|
||||
HANDLE_SYSCALL_RETURN_VALUE("readlink", rc, DeprecatedString(data, rc));
|
||||
#else
|
||||
String path_string = pathname;
|
||||
DeprecatedString path_string = pathname;
|
||||
int rc = ::readlink(path_string.characters(), data, sizeof(data));
|
||||
if (rc == -1)
|
||||
return Error::from_syscall("readlink"sv, -errno);
|
||||
|
||||
return String(data, rc);
|
||||
return DeprecatedString(data, rc);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -110,10 +110,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<String> ptsname(int fd);
|
||||
ErrorOr<String> gethostname();
|
||||
ErrorOr<DeprecatedString> ptsname(int fd);
|
||||
ErrorOr<DeprecatedString> gethostname();
|
||||
ErrorOr<void> sethostname(StringView);
|
||||
ErrorOr<String> getcwd();
|
||||
ErrorOr<DeprecatedString> 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&);
|
||||
|
@ -204,7 +204,7 @@ ErrorOr<int> posix_openpt(int flags);
|
|||
ErrorOr<void> grantpt(int fildes);
|
||||
ErrorOr<void> unlockpt(int fildes);
|
||||
ErrorOr<void> access(StringView pathname, int mode);
|
||||
ErrorOr<String> readlink(StringView pathname);
|
||||
ErrorOr<DeprecatedString> readlink(StringView pathname);
|
||||
|
||||
#ifdef AK_OS_SERENITY
|
||||
ErrorOr<void> posix_fallocate(int fd, off_t offset, off_t length);
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
HashMap<String, int> s_overtaken_sockets {};
|
||||
HashMap<DeprecatedString, int> s_overtaken_sockets {};
|
||||
bool s_overtaken_sockets_parsed { false };
|
||||
|
||||
static void parse_sockets_from_system_server()
|
||||
|
@ -34,7 +34,7 @@ static void parse_sockets_from_system_server()
|
|||
unsetenv(socket_takeover);
|
||||
}
|
||||
|
||||
ErrorOr<NonnullOwnPtr<Core::Stream::LocalSocket>> take_over_socket_from_system_server(String const& socket_path)
|
||||
ErrorOr<NonnullOwnPtr<Core::Stream::LocalSocket>> take_over_socket_from_system_server(DeprecatedString const& socket_path)
|
||||
{
|
||||
if (!s_overtaken_sockets_parsed)
|
||||
parse_sockets_from_system_server();
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
ErrorOr<NonnullOwnPtr<Core::Stream::LocalSocket>> take_over_socket_from_system_server(String const& socket_path = {});
|
||||
ErrorOr<NonnullOwnPtr<Core::Stream::LocalSocket>> take_over_socket_from_system_server(DeprecatedString const& socket_path = {});
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ NonnullOwnPtr<TempFile> TempFile::create(Type type)
|
|||
return adopt_own(*new TempFile(type));
|
||||
}
|
||||
|
||||
String TempFile::create_temp(Type type)
|
||||
DeprecatedString TempFile::create_temp(Type type)
|
||||
{
|
||||
char name_template[] = "/tmp/tmp.XXXXXX";
|
||||
switch (type) {
|
||||
|
@ -34,7 +34,7 @@ String TempFile::create_temp(Type type)
|
|||
break;
|
||||
}
|
||||
}
|
||||
return String { name_template };
|
||||
return DeprecatedString { name_template };
|
||||
}
|
||||
|
||||
TempFile::TempFile(Type type)
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <AK/Noncopyable.h>
|
||||
#include <AK/String.h>
|
||||
|
||||
namespace Core {
|
||||
|
||||
|
@ -24,14 +24,14 @@ public:
|
|||
static NonnullOwnPtr<TempFile> create(Type = Type::File);
|
||||
~TempFile();
|
||||
|
||||
String path() const { return m_path; }
|
||||
DeprecatedString path() const { return m_path; }
|
||||
|
||||
private:
|
||||
TempFile(Type);
|
||||
static String create_temp(Type);
|
||||
static DeprecatedString create_temp(Type);
|
||||
|
||||
Type m_type { Type::File };
|
||||
String m_path;
|
||||
DeprecatedString m_path;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <AK/DeprecatedString.h>
|
||||
#include <LibCore/System.h>
|
||||
#include <LibCore/Version.h>
|
||||
|
||||
namespace Core::Version {
|
||||
|
||||
String read_long_version_string()
|
||||
DeprecatedString read_long_version_string()
|
||||
{
|
||||
auto result = Core::System::uname();
|
||||
if (result.is_error())
|
||||
|
@ -19,7 +19,7 @@ String read_long_version_string()
|
|||
auto version = result.value().release;
|
||||
auto git_hash = result.value().version;
|
||||
|
||||
return String::formatted("Version {} revision {}", version, git_hash);
|
||||
return DeprecatedString::formatted("Version {} revision {}", version, git_hash);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,6 +10,6 @@
|
|||
|
||||
namespace Core::Version {
|
||||
|
||||
String read_long_version_string();
|
||||
DeprecatedString read_long_version_string();
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue