1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 19:17:44 +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:
Linus Groh 2022-12-04 18:02:33 +00:00 committed by Andreas Kling
parent f74251606d
commit 6e19ab2bbc
2006 changed files with 11635 additions and 11636 deletions

View file

@ -27,7 +27,7 @@ unsigned TarFileHeader::expected_checksum() const
void TarFileHeader::calculate_checksum()
{
memset(m_checksum, ' ', sizeof(m_checksum));
VERIFY(String::formatted("{:06o}", expected_checksum()).copy_characters_to_buffer(m_checksum, sizeof(m_checksum)));
VERIFY(DeprecatedString::formatted("{:06o}", expected_checksum()).copy_characters_to_buffer(m_checksum, sizeof(m_checksum)));
}
bool TarFileHeader::is_zero_block() const

View file

@ -8,7 +8,7 @@
#pragma once
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/StringView.h>
#include <string.h>
#include <sys/types.h>
@ -84,7 +84,7 @@ static void set_field(char (&field)[N], TSource&& source)
template<class TSource, size_t N>
static void set_octal_field(char (&field)[N], TSource&& source)
{
set_field(field, String::formatted("{:o}", forward<TSource>(source)));
set_field(field, DeprecatedString::formatted("{:o}", forward<TSource>(source)));
}
class [[gnu::packed]] TarFileHeader {

View file

@ -142,12 +142,12 @@ TarOutputStream::TarOutputStream(OutputStream& stream)
{
}
void TarOutputStream::add_directory(String const& path, mode_t mode)
void TarOutputStream::add_directory(DeprecatedString const& path, mode_t mode)
{
VERIFY(!m_finished);
TarFileHeader header {};
header.set_size(0);
header.set_filename_and_prefix(String::formatted("{}/", path)); // Old tar implementations assume directory names end with a /
header.set_filename_and_prefix(DeprecatedString::formatted("{}/", path)); // Old tar implementations assume directory names end with a /
header.set_type_flag(TarFileType::Directory);
header.set_mode(mode);
header.set_magic(gnu_magic);
@ -158,7 +158,7 @@ void TarOutputStream::add_directory(String const& path, mode_t mode)
VERIFY(m_stream.write_or_error(Bytes { &padding, block_size - sizeof(header) }));
}
void TarOutputStream::add_file(String const& path, mode_t mode, ReadonlyBytes bytes)
void TarOutputStream::add_file(DeprecatedString const& path, mode_t mode, ReadonlyBytes bytes)
{
VERIFY(!m_finished);
TarFileHeader header {};
@ -179,7 +179,7 @@ void TarOutputStream::add_file(String const& path, mode_t mode, ReadonlyBytes by
VERIFY(m_stream.write_or_error(ReadonlyBytes { &padding, block_size - (n_written % block_size) }));
}
void TarOutputStream::add_link(String const& path, mode_t mode, StringView link_name)
void TarOutputStream::add_link(DeprecatedString const& path, mode_t mode, StringView link_name)
{
VERIFY(!m_finished);
TarFileHeader header {};

View file

@ -59,9 +59,9 @@ private:
class TarOutputStream {
public:
TarOutputStream(OutputStream&);
void add_file(String const& path, mode_t, ReadonlyBytes);
void add_link(String const& path, mode_t, StringView);
void add_directory(String const& path, mode_t);
void add_file(DeprecatedString const& path, mode_t, ReadonlyBytes);
void add_link(DeprecatedString const& path, mode_t, StringView);
void add_directory(DeprecatedString const& path, mode_t);
void finish();
private:

View file

@ -93,7 +93,7 @@ bool Zip::for_each_member(Function<IterationDecision(ZipMember const&)> callback
char null_terminated_name[central_directory_record.name_length + 1];
memcpy(null_terminated_name, central_directory_record.name, central_directory_record.name_length);
null_terminated_name[central_directory_record.name_length] = 0;
member.name = String { null_terminated_name };
member.name = DeprecatedString { null_terminated_name };
member.compressed_data = { local_file_header.compressed_data, central_directory_record.compressed_size };
member.compression_method = central_directory_record.compression_method;
member.uncompressed_size = central_directory_record.uncompressed_size;

View file

@ -8,10 +8,10 @@
#pragma once
#include <AK/Array.h>
#include <AK/DeprecatedString.h>
#include <AK/Function.h>
#include <AK/IterationDecision.h>
#include <AK/Stream.h>
#include <AK/String.h>
#include <AK/Vector.h>
#include <string.h>
@ -225,7 +225,7 @@ struct [[gnu::packed]] LocalFileHeader {
};
struct ZipMember {
String name;
DeprecatedString name;
ReadonlyBytes compressed_data; // TODO: maybe the decompression/compression should be handled by LibArchive instead of the user?
ZipCompressionMethod compression_method;
u32 uncompressed_size;

View file

@ -5,6 +5,7 @@
*/
#include <AK/Debug.h>
#include <AK/DeprecatedString.h>
#include <AK/FixedArray.h>
#include <AK/FlyString.h>
#include <AK/Format.h>
@ -12,7 +13,6 @@
#include <AK/Math.h>
#include <AK/ScopeGuard.h>
#include <AK/StdLibExtras.h>
#include <AK/String.h>
#include <AK/Try.h>
#include <AK/TypedTransfer.h>
#include <AK/UFixedBigInt.h>
@ -63,11 +63,11 @@ MaybeLoaderError FlacLoaderPlugin::parse_header()
auto bit_input = LOADER_TRY(BigEndianInputBitStream::construct(*m_stream));
// A mixture of VERIFY and the non-crashing TRY().
#define FLAC_VERIFY(check, category, msg) \
do { \
if (!(check)) { \
return LoaderError { category, static_cast<size_t>(m_data_start_location), String::formatted("FLAC header: {}", msg) }; \
} \
#define FLAC_VERIFY(check, category, msg) \
do { \
if (!(check)) { \
return LoaderError { category, static_cast<size_t>(m_data_start_location), DeprecatedString::formatted("FLAC header: {}", msg) }; \
} \
} while (0)
// Magic number
@ -280,7 +280,7 @@ MaybeLoaderError FlacLoaderPlugin::seek(int int_sample_index)
dbgln_if(AFLACLOADER_DEBUG, "Seeking to seektable: sample index {}, byte offset {}, sample count {}", target_seekpoint.sample_index, target_seekpoint.byte_offset, target_seekpoint.num_samples);
auto position = target_seekpoint.byte_offset + m_data_start_location;
if (m_stream->seek(static_cast<i64>(position), Core::Stream::SeekMode::SetPosition).is_error())
return LoaderError { LoaderError::Category::IO, m_loaded_samples, String::formatted("Invalid seek position {}", position) };
return LoaderError { LoaderError::Category::IO, m_loaded_samples, DeprecatedString::formatted("Invalid seek position {}", position) };
auto remaining_samples_after_seekpoint = sample_index - m_data_start_location;
if (remaining_samples_after_seekpoint > 0)
@ -326,11 +326,11 @@ LoaderSamples FlacLoaderPlugin::get_more_samples(size_t max_bytes_to_read_from_i
// 11.21. FRAME
MaybeLoaderError FlacLoaderPlugin::next_frame(Span<Sample> target_vector)
{
#define FLAC_VERIFY(check, category, msg) \
do { \
if (!(check)) { \
return LoaderError { category, static_cast<size_t>(m_current_sample_or_frame), String::formatted("FLAC header: {}", msg) }; \
} \
#define FLAC_VERIFY(check, category, msg) \
do { \
if (!(check)) { \
return LoaderError { category, static_cast<size_t>(m_current_sample_or_frame), DeprecatedString::formatted("FLAC header: {}", msg) }; \
} \
} while (0)
auto bit_stream = LOADER_TRY(BigEndianInputBitStream::construct(*m_stream));
@ -561,7 +561,7 @@ ErrorOr<PcmSampleFormat, LoaderError> FlacLoaderPlugin::convert_bit_depth_code(u
case 7:
return LoaderError { LoaderError::Category::Format, static_cast<size_t>(m_current_sample_or_frame), "Reserved sample size" };
default:
return LoaderError { LoaderError::Category::Format, static_cast<size_t>(m_current_sample_or_frame), String::formatted("Unsupported sample size {}", bit_depth_code) };
return LoaderError { LoaderError::Category::Format, static_cast<size_t>(m_current_sample_or_frame), DeprecatedString::formatted("Unsupported sample size {}", bit_depth_code) };
}
}
@ -818,7 +818,7 @@ ErrorOr<Vector<i32>, LoaderError> FlacLoaderPlugin::decode_fixed_lpc(FlacSubfram
decoded[i] += 4 * decoded[i - 1] - 6 * decoded[i - 2] + 4 * decoded[i - 3] - decoded[i - 4];
break;
default:
return LoaderError { LoaderError::Category::Format, static_cast<size_t>(m_current_sample_or_frame), String::formatted("Unrecognized predictor order {}", subframe.order) };
return LoaderError { LoaderError::Category::Format, static_cast<size_t>(m_current_sample_or_frame), DeprecatedString::formatted("Unrecognized predictor order {}", subframe.order) };
}
return decoded;
}

View file

@ -62,7 +62,7 @@ public:
virtual int total_samples() override { return static_cast<int>(m_total_samples); }
virtual u32 sample_rate() override { return m_sample_rate; }
virtual u16 num_channels() override { return m_num_channels; }
virtual String format_name() override { return "FLAC (.flac)"; }
virtual DeprecatedString format_name() override { return "FLAC (.flac)"; }
virtual PcmSampleFormat pcm_format() override { return m_sample_format; }
bool is_fixed_blocksize_stream() const { return m_min_block_size == m_max_block_size; }

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/Vector.h>
namespace Audio {
@ -40,7 +40,7 @@ enum class ID3PictureType : u32 {
// Note: This was first implemented for Flac but is compatible with ID3v2
struct PictureData {
ID3PictureType type {};
String mime_string {};
DeprecatedString mime_string {};
Vector<u32> description_string {};
u32 width {};

View file

@ -52,7 +52,7 @@ public:
virtual u16 num_channels() = 0;
// Human-readable name of the file format, of the form <full abbreviation> (.<ending>)
virtual String format_name() = 0;
virtual DeprecatedString format_name() = 0;
virtual PcmSampleFormat pcm_format() = 0;
Vector<PictureData> const& pictures() const { return m_pictures; };
@ -77,7 +77,7 @@ public:
int total_samples() const { return m_plugin->total_samples(); }
u32 sample_rate() const { return m_plugin->sample_rate(); }
u16 num_channels() const { return m_plugin->num_channels(); }
String format_name() const { return m_plugin->format_name(); }
DeprecatedString format_name() const { return m_plugin->format_name(); }
u16 bits_per_sample() const { return pcm_bits_per_sample(m_plugin->pcm_format()); }
Vector<PictureData> const& pictures() const { return m_plugin->pictures(); };

View file

@ -28,7 +28,7 @@ struct LoaderError {
Category category { Category::Unknown };
// Binary index: where in the file the error occurred.
size_t index { 0 };
FlyString description { String::empty() };
FlyString description { DeprecatedString::empty() };
constexpr LoaderError() = default;
LoaderError(Category category, size_t index, FlyString description)
@ -54,7 +54,7 @@ struct LoaderError {
{
if (error.is_errno()) {
auto code = error.code();
description = String::formatted("{} ({})", strerror(code), code);
description = DeprecatedString::formatted("{} ({})", strerror(code), code);
if (code == EBADF || code == EBUSY || code == EEXIST || code == EIO || code == EISDIR || code == ENOENT || code == ENOMEM || code == EPIPE)
category = Category::IO;
} else {

View file

@ -39,7 +39,7 @@ public:
virtual u32 sample_rate() override { return m_sample_rate; }
virtual u16 num_channels() override { return m_num_channels; }
virtual PcmSampleFormat pcm_format() override { return m_sample_format; }
virtual String format_name() override { return "MP3 (.mp3)"; }
virtual DeprecatedString format_name() override { return "MP3 (.mp3)"; }
private:
MaybeLoaderError initialize();

View file

@ -27,10 +27,10 @@ u16 pcm_bits_per_sample(PcmSampleFormat format)
}
}
String sample_format_name(PcmSampleFormat format)
DeprecatedString sample_format_name(PcmSampleFormat format)
{
bool is_float = format == PcmSampleFormat::Float32 || format == PcmSampleFormat::Float64;
return String::formatted("PCM {}bit {}", pcm_bits_per_sample(format), is_float ? "Float" : "LE");
return DeprecatedString::formatted("PCM {}bit {}", pcm_bits_per_sample(format), is_float ? "Float" : "LE");
}
}

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/Types.h>
namespace Audio {
@ -23,5 +23,5 @@ enum class PcmSampleFormat : u8 {
// Most of the read code only cares about how many bits to read or write
u16 pcm_bits_per_sample(PcmSampleFormat format);
String sample_format_name(PcmSampleFormat format);
DeprecatedString sample_format_name(PcmSampleFormat format);
}

View file

@ -210,10 +210,10 @@ MaybeLoaderError WavLoaderPlugin::parse_header()
return value;
};
#define CHECK_OK(category, msg) \
do { \
if (!ok) \
return LoaderError { category, String::formatted("Parsing failed: {}", msg) }; \
#define CHECK_OK(category, msg) \
do { \
if (!ok) \
return LoaderError { category, DeprecatedString::formatted("Parsing failed: {}", msg) }; \
} while (0)
u32 riff = TRY(read_u32());

View file

@ -7,11 +7,11 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/FixedArray.h>
#include <AK/OwnPtr.h>
#include <AK/RefPtr.h>
#include <AK/Span.h>
#include <AK/String.h>
#include <AK/StringView.h>
#include <LibAudio/Loader.h>
#include <LibCore/File.h>
@ -45,7 +45,7 @@ public:
virtual int total_samples() override { return static_cast<int>(m_total_samples); }
virtual u32 sample_rate() override { return m_sample_rate; }
virtual u16 num_channels() override { return m_num_channels; }
virtual String format_name() override { return "RIFF WAVE (.wav)"; }
virtual DeprecatedString format_name() override { return "RIFF WAVE (.wav)"; }
virtual PcmSampleFormat pcm_format() override { return m_sample_format; }
private:

View file

@ -33,7 +33,7 @@ void WavWriter::set_file(StringView path)
{
m_file = Core::File::construct(path);
if (!m_file->open(Core::OpenMode::ReadWrite)) {
m_error_string = String::formatted("Can't open file: {}", m_file->error_string());
m_error_string = DeprecatedString::formatted("Can't open file: {}", m_file->error_string());
return;
}
m_file->seek(44);

View file

@ -38,12 +38,12 @@ public:
void set_sample_rate(int sample_rate) { m_sample_rate = sample_rate; }
void set_bits_per_sample(int bits_per_sample) { m_bits_per_sample = bits_per_sample; }
void clear_error() { m_error_string = String(); }
void clear_error() { m_error_string = DeprecatedString(); }
private:
void write_header();
RefPtr<Core::File> m_file;
String m_error_string;
DeprecatedString m_error_string;
bool m_finalized { false };
u32 m_sample_rate;

View file

@ -7,11 +7,11 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/Result.h>
#include <AK/String.h>
struct DlErrorMessage {
DlErrorMessage(String&& other)
DlErrorMessage(DeprecatedString&& other)
: text(move(other))
{
}
@ -21,7 +21,7 @@ struct DlErrorMessage {
// from the one in libc.so
virtual ~DlErrorMessage() = default;
String text;
DeprecatedString text;
};
struct __Dl_info;

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/Types.h>
#include <bits/dlfcn_integration.h>
#include <dlfcn.h>
@ -25,7 +25,7 @@ __thread char* s_dlerror_text = NULL;
__thread bool s_dlerror_retrieved = false;
#endif
static void store_error(String const& error)
static void store_error(DeprecatedString const& error)
{
free(s_dlerror_text);
s_dlerror_text = strdup(error.characters());

View file

@ -5,8 +5,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ScopeGuard.h>
#include <AK/String.h>
#include <AK/Vector.h>
#include <errno.h>
#include <errno_codes.h>

View file

@ -6,8 +6,8 @@
#include <AK/Assertions.h>
#include <AK/ByteBuffer.h>
#include <AK/DeprecatedString.h>
#include <AK/ScopeGuard.h>
#include <AK/String.h>
#include <Kernel/Net/IPv4.h>
#include <arpa/inet.h>
#include <errno.h>
@ -47,8 +47,8 @@ static char const* services_path = "/etc/services";
static bool fill_getserv_buffers(char const* line, ssize_t read);
static servent __getserv_buffer;
static String __getserv_name_buffer;
static String __getserv_protocol_buffer;
static DeprecatedString __getserv_name_buffer;
static DeprecatedString __getserv_protocol_buffer;
static int __getserv_port_buffer;
static Vector<ByteBuffer> __getserv_alias_list_buffer;
static Vector<char*> __getserv_alias_list;
@ -61,7 +61,7 @@ static char const* protocols_path = "/etc/protocols";
static bool fill_getproto_buffers(char const* line, ssize_t read);
static protoent __getproto_buffer;
static String __getproto_name_buffer;
static DeprecatedString __getproto_name_buffer;
static Vector<ByteBuffer> __getproto_alias_list_buffer;
static Vector<char*> __getproto_alias_list;
static int __getproto_protocol_buffer;
@ -89,7 +89,7 @@ static int connect_to_lookup_server()
return fd;
}
static String gethostbyname_name_buffer;
static DeprecatedString gethostbyname_name_buffer;
hostent* gethostbyname(char const* name)
{
@ -211,7 +211,7 @@ hostent* gethostbyname(char const* name)
return &__gethostbyname_buffer;
}
static String gethostbyaddr_name_buffer;
static DeprecatedString gethostbyaddr_name_buffer;
hostent* gethostbyaddr(void const* addr, socklen_t addr_size, int type)
{
@ -467,7 +467,7 @@ static bool fill_getserv_buffers(char const* line, ssize_t read)
}
__getserv_name_buffer = split_line[0];
auto port_protocol_split = String(split_line[1]).split('/');
auto port_protocol_split = DeprecatedString(split_line[1]).split('/');
if (port_protocol_split.size() < 2) {
warnln("getservent(): malformed services file");
return false;
@ -634,7 +634,7 @@ void endprotoent()
static bool fill_getproto_buffers(char const* line, ssize_t read)
{
String string_line = String(line, read);
DeprecatedString string_line = DeprecatedString(line, read);
auto split_line = string_line.replace(" "sv, "\t"sv, ReplaceMode::All).split('\t');
// This indicates an incorrect file format. Protocols file entries should

View file

@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ScopeGuard.h>
#include <AK/String.h>
#include <AK/TemporaryChange.h>
#include <AK/Vector.h>
#include <errno.h>

View file

@ -8,9 +8,9 @@
#include <AK/Assertions.h>
#include <AK/Atomic.h>
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
#include <AK/ScopeGuard.h>
#include <AK/String.h>
#include <AK/Types.h>
#include <bits/pthread_cancel.h>
#include <errno.h>
@ -31,7 +31,7 @@ static constexpr u32 POST_WAKES = 1 << 31;
static constexpr auto sem_path_prefix = "/tmp/semaphore/"sv;
static constexpr auto SEM_NAME_MAX = PATH_MAX - sem_path_prefix.length();
static ErrorOr<String> sem_name_to_path(char const* name)
static ErrorOr<DeprecatedString> sem_name_to_path(char const* name)
{
if (name[0] != '/')
return EINVAL;
@ -58,7 +58,7 @@ struct NamedSemaphore {
sem_t* sem { nullptr };
};
static HashMap<String, NamedSemaphore> s_named_semaphores;
static HashMap<DeprecatedString, NamedSemaphore> s_named_semaphores;
static pthread_mutex_t s_sem_mutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_once_t s_sem_once = PTHREAD_ONCE_INIT;

View file

@ -5,7 +5,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/TemporaryChange.h>
#include <AK/Vector.h>
#include <errno.h>
@ -21,8 +21,8 @@ static FILE* s_stream = nullptr;
static unsigned s_line_number = 0;
static struct spwd s_shadow_entry;
static String s_name;
static String s_pwdp;
static DeprecatedString s_name;
static DeprecatedString s_pwdp;
void setspent()
{
@ -62,7 +62,7 @@ struct spwd* getspnam(char const* name)
return nullptr;
}
static bool parse_shadow_entry(String const& line)
static bool parse_shadow_entry(DeprecatedString const& line)
{
auto parts = line.split_view(':', SplitBehavior::KeepEmpty);
if (parts.size() != 9) {
@ -169,7 +169,7 @@ struct spwd* getspent()
if ((!s || !s[0]) && feof(s_stream))
return nullptr;
String line(s, Chomp);
DeprecatedString line(s, Chomp);
if (parse_shadow_entry(line))
return &s_shadow_entry;
// Otherwise, proceed to the next line.

View file

@ -6,11 +6,11 @@
*/
#include <AK/BuiltinWrappers.h>
#include <AK/DeprecatedString.h>
#include <AK/Format.h>
#include <AK/PrintfImplementation.h>
#include <AK/ScopedValueRollback.h>
#include <AK/StdLibExtras.h>
#include <AK/String.h>
#include <LibC/bits/mutex_locker.h>
#include <LibC/bits/stdio_file_implementation.h>
#include <assert.h>

View file

@ -7,7 +7,7 @@
// Has to be defined before including due to legacy Unices
#define SYSLOG_NAMES 1
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/StringBuilder.h>
#include <stdio.h>
#include <string.h>
@ -124,7 +124,7 @@ void vsyslog_r(int priority, struct syslog_data* data, char const* message, va_l
combined.appendff("{}: ", get_syslog_ident(data));
combined.appendvf(message, args);
String combined_string = combined.build();
DeprecatedString combined_string = combined.build();
if (data->logopt & LOG_CONS)
dbgputstr(combined_string.characters(), combined_string.length());

View file

@ -5,8 +5,8 @@
*/
#include <AK/Debug.h>
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
#include <AK/String.h>
#include <AK/Vector.h>
#include <assert.h>
#include <string.h>
@ -27,13 +27,13 @@ int __attribute__((weak)) tgetent([[maybe_unused]] char* bp, [[maybe_unused]] ch
return 1;
}
static HashMap<String, char const*>* caps = nullptr;
static HashMap<DeprecatedString, char const*>* caps = nullptr;
static void ensure_caps()
{
if (caps)
return;
caps = new HashMap<String, char const*>;
caps = new HashMap<DeprecatedString, char const*>;
caps->set("DC", "\033[%p1%dP");
caps->set("IC", "\033[%p1%d@");
caps->set("ce", "\033[K");
@ -114,7 +114,7 @@ int __attribute__((weak)) tgetnum(char const* id)
static Vector<char> s_tgoto_buffer;
char* __attribute__((weak)) tgoto([[maybe_unused]] char const* cap, [[maybe_unused]] int col, [[maybe_unused]] int row)
{
auto cap_str = StringView { cap, strlen(cap) }.replace("%p1%d"sv, String::number(col), ReplaceMode::FirstOnly).replace("%p2%d"sv, String::number(row), ReplaceMode::FirstOnly);
auto cap_str = StringView { cap, strlen(cap) }.replace("%p1%d"sv, DeprecatedString::number(col), ReplaceMode::FirstOnly).replace("%p2%d"sv, DeprecatedString::number(row), ReplaceMode::FirstOnly);
s_tgoto_buffer.clear_with_capacity();
s_tgoto_buffer.ensure_capacity(cap_str.length());

View file

@ -5,7 +5,7 @@
*/
#include <AK/DateConstants.h>
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/StringBuilder.h>
#include <AK/Time.h>
#include <Kernel/API/TimePage.h>

View file

@ -4,9 +4,9 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ScopeGuard.h>
#include <AK/ScopedValueRollback.h>
#include <AK/String.h>
#include <AK/Vector.h>
#include <Kernel/API/Unveil.h>
#include <LibCore/File.h>
@ -189,12 +189,12 @@ int execvpe(char const* filename, char* const argv[], char* const envp[])
ScopedValueRollback errno_rollback(errno);
// TODO: Make this use the PATH search implementation from Core::File.
String path = getenv("PATH");
DeprecatedString path = getenv("PATH");
if (path.is_empty())
path = DEFAULT_PATH;
auto parts = path.split(':');
for (auto& part : parts) {
auto candidate = String::formatted("{}/{}", part, filename);
auto candidate = DeprecatedString::formatted("{}/{}", part, filename);
int rc = execve(candidate.characters(), argv, envp);
if (rc < 0 && errno != ENOENT) {
errno_rollback.set_override_rollback_value(errno);
@ -854,13 +854,13 @@ void sync()
syscall(SC_sync);
}
static String getlogin_buffer;
static DeprecatedString getlogin_buffer;
char* getlogin()
{
if (getlogin_buffer.is_null()) {
if (auto* passwd = getpwuid(getuid())) {
getlogin_buffer = String(passwd->pw_name);
getlogin_buffer = DeprecatedString(passwd->pw_name);
}
endpwent();
}

View file

@ -100,7 +100,7 @@ void CardGame::dump_layout() const
dbgln("{}", stack);
}
void CardGame::config_string_did_change(String const& domain, String const& group, String const& key, String const& value)
void CardGame::config_string_did_change(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value)
{
if (domain == "Games" && group == "Cards") {
if (key == "BackgroundColor") {

View file

@ -43,7 +43,7 @@ protected:
CardGame();
private:
virtual void config_string_did_change(String const& domain, String const& group, String const& key, String const& value) override;
virtual void config_string_did_change(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value) override;
NonnullRefPtrVector<CardStack> m_stacks;

View file

@ -128,7 +128,7 @@ NonnullRefPtr<Gfx::Bitmap> CardPainter::card_back_inverted()
return *m_card_back_inverted;
}
void CardPainter::set_background_image_path(String path)
void CardPainter::set_background_image_path(DeprecatedString path)
{
if (m_background_image_path == path)
return;

View file

@ -21,7 +21,7 @@ public:
NonnullRefPtr<Gfx::Bitmap> card_front_inverted(Suit, Rank);
NonnullRefPtr<Gfx::Bitmap> card_back_inverted();
void set_background_image_path(String path);
void set_background_image_path(DeprecatedString path);
private:
CardPainter();
@ -35,7 +35,7 @@ private:
RefPtr<Gfx::Bitmap> m_card_back;
RefPtr<Gfx::Bitmap> m_card_back_inverted;
String m_background_image_path;
DeprecatedString m_background_image_path;
};
}

View file

@ -5,7 +5,7 @@
*/
#include <AK/Assertions.h>
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/StringBuilder.h>
#include <AK/Vector.h>
#include <LibChess/Chess.h>
@ -13,7 +13,7 @@
namespace Chess {
String char_for_piece(Chess::Type type)
DeprecatedString char_for_piece(Chess::Type type)
{
switch (type) {
case Type::Knight:
@ -34,7 +34,7 @@ String char_for_piece(Chess::Type type)
Chess::Type piece_for_char_promotion(StringView str)
{
String string = String(str).to_lowercase();
DeprecatedString string = DeprecatedString(str).to_lowercase();
if (string == "")
return Type::None;
if (string == "n")
@ -77,7 +77,7 @@ Square::Square(StringView name)
}
}
String Square::to_algebraic() const
DeprecatedString Square::to_algebraic() const
{
StringBuilder builder;
builder.append(file + 'a');
@ -92,7 +92,7 @@ Move::Move(StringView long_algebraic)
{
}
String Move::to_long_algebraic() const
DeprecatedString Move::to_long_algebraic() const
{
StringBuilder builder;
builder.append(from.to_algebraic());
@ -103,7 +103,7 @@ String Move::to_long_algebraic() const
Move Move::from_algebraic(StringView algebraic, const Color turn, Board const& board)
{
String move_string = algebraic;
DeprecatedString move_string = algebraic;
Move move({ 50, 50 }, { 50, 50 });
if (move_string.contains('-')) {
@ -176,7 +176,7 @@ Move Move::from_algebraic(StringView algebraic, const Color turn, Board const& b
return move;
}
String Move::to_algebraic() const
DeprecatedString Move::to_algebraic() const
{
if (piece.type == Type::King && from.file == 4) {
if (to.file == 2)
@ -269,7 +269,7 @@ Board Board::clone_without_history() const
return result;
}
String Board::to_fen() const
DeprecatedString Board::to_fen() const
{
StringBuilder builder;
@ -283,17 +283,17 @@ String Board::to_fen() const
continue;
}
if (empty > 0) {
builder.append(String::number(empty));
builder.append(DeprecatedString::number(empty));
empty = 0;
}
String piece = char_for_piece(p.type);
DeprecatedString piece = char_for_piece(p.type);
if (piece == "")
piece = "P";
builder.append(p.color == Color::Black ? piece.to_lowercase() : piece);
}
if (empty > 0) {
builder.append(String::number(empty));
builder.append(DeprecatedString::number(empty));
empty = 0;
}
if (rank < 7)
@ -327,11 +327,11 @@ String Board::to_fen() const
builder.append(' ');
// 5. Halfmove clock
builder.append(String::number(min(m_moves_since_capture, m_moves_since_pawn_advance)));
builder.append(DeprecatedString::number(min(m_moves_since_capture, m_moves_since_pawn_advance)));
builder.append(' ');
// 6. Fullmove number
builder.append(String::number(1 + m_moves.size() / 2));
builder.append(DeprecatedString::number(1 + m_moves.size() / 2));
return builder.to_string();
}
@ -886,7 +886,7 @@ void Board::set_resigned(Chess::Color c)
m_resigned = c;
}
String Board::result_to_string(Result result, Color turn)
DeprecatedString Board::result_to_string(Result result, Color turn)
{
switch (result) {
case Result::CheckMate:
@ -915,7 +915,7 @@ String Board::result_to_string(Result result, Color turn)
}
}
String Board::result_to_points(Result result, Color turn)
DeprecatedString Board::result_to_points(Result result, Color turn)
{
switch (result) {
case Result::CheckMate:

View file

@ -25,7 +25,7 @@ enum class Type : u8 {
None,
};
String char_for_piece(Type type);
DeprecatedString char_for_piece(Type type);
Chess::Type piece_for_char_promotion(StringView str);
enum class Color : u8 {
@ -85,7 +85,7 @@ struct Square {
bool in_bounds() const { return rank >= 0 && file >= 0 && rank < 8 && file < 8; }
bool is_light() const { return (rank % 2) != (file % 2); }
String to_algebraic() const;
DeprecatedString to_algebraic() const;
};
class Board;
@ -110,8 +110,8 @@ struct Move {
bool operator==(Move const& other) const { return from == other.from && to == other.to && promote_to == other.promote_to; }
static Move from_algebraic(StringView algebraic, const Color turn, Board const& board);
String to_long_algebraic() const;
String to_algebraic() const;
DeprecatedString to_long_algebraic() const;
DeprecatedString to_algebraic() const;
};
class Board {
@ -130,7 +130,7 @@ public:
bool apply_move(Move const&, Color color = Color::None);
Optional<Move> const& last_move() const { return m_last_move; }
String to_fen() const;
DeprecatedString to_fen() const;
enum class Result {
CheckMate,
@ -145,8 +145,8 @@ public:
NotFinished,
};
static String result_to_string(Result, Color turn);
static String result_to_points(Result, Color turn);
static DeprecatedString result_to_string(Result, Color turn);
static DeprecatedString result_to_points(Result, Color turn);
template<typename Callback>
void generate_moves(Callback callback, Color color = Color::None) const;

View file

@ -17,7 +17,7 @@ UCICommand UCICommand::from_string(StringView command)
return UCICommand();
}
String UCICommand::to_string() const
DeprecatedString UCICommand::to_string() const
{
return "uci\n";
}
@ -35,7 +35,7 @@ DebugCommand DebugCommand::from_string(StringView command)
VERIFY_NOT_REACHED();
}
String DebugCommand::to_string() const
DeprecatedString DebugCommand::to_string() const
{
if (flag() == Flag::On) {
return "debug on\n";
@ -52,7 +52,7 @@ IsReadyCommand IsReadyCommand::from_string(StringView command)
return IsReadyCommand();
}
String IsReadyCommand::to_string() const
DeprecatedString IsReadyCommand::to_string() const
{
return "isready\n";
}
@ -95,7 +95,7 @@ SetOptionCommand SetOptionCommand::from_string(StringView command)
return SetOptionCommand(name.to_string().trim_whitespace(), value.to_string().trim_whitespace());
}
String SetOptionCommand::to_string() const
DeprecatedString SetOptionCommand::to_string() const
{
StringBuilder builder;
builder.append("setoption name "sv);
@ -115,7 +115,7 @@ PositionCommand PositionCommand::from_string(StringView command)
VERIFY(tokens[0] == "position");
VERIFY(tokens[2] == "moves");
Optional<String> fen;
Optional<DeprecatedString> fen;
if (tokens[1] != "startpos")
fen = tokens[1];
@ -126,7 +126,7 @@ PositionCommand PositionCommand::from_string(StringView command)
return PositionCommand(fen, moves);
}
String PositionCommand::to_string() const
DeprecatedString PositionCommand::to_string() const
{
StringBuilder builder;
builder.append("position "sv);
@ -190,7 +190,7 @@ GoCommand GoCommand::from_string(StringView command)
return go_command;
}
String GoCommand::to_string() const
DeprecatedString GoCommand::to_string() const
{
StringBuilder builder;
builder.append("go"sv);
@ -238,7 +238,7 @@ StopCommand StopCommand::from_string(StringView command)
return StopCommand();
}
String StopCommand::to_string() const
DeprecatedString StopCommand::to_string() const
{
return "stop\n";
}
@ -263,7 +263,7 @@ IdCommand IdCommand::from_string(StringView command)
VERIFY_NOT_REACHED();
}
String IdCommand::to_string() const
DeprecatedString IdCommand::to_string() const
{
StringBuilder builder;
builder.append("id "sv);
@ -285,7 +285,7 @@ UCIOkCommand UCIOkCommand::from_string(StringView command)
return UCIOkCommand();
}
String UCIOkCommand::to_string() const
DeprecatedString UCIOkCommand::to_string() const
{
return "uciok\n";
}
@ -298,7 +298,7 @@ ReadyOkCommand ReadyOkCommand::from_string(StringView command)
return ReadyOkCommand();
}
String ReadyOkCommand::to_string() const
DeprecatedString ReadyOkCommand::to_string() const
{
return "readyok\n";
}
@ -311,7 +311,7 @@ BestMoveCommand BestMoveCommand::from_string(StringView command)
return BestMoveCommand(Move(tokens[1]));
}
String BestMoveCommand::to_string() const
DeprecatedString BestMoveCommand::to_string() const
{
StringBuilder builder;
builder.append("bestmove "sv);
@ -326,7 +326,7 @@ InfoCommand InfoCommand::from_string([[maybe_unused]] StringView command)
VERIFY_NOT_REACHED();
}
String InfoCommand::to_string() const
DeprecatedString InfoCommand::to_string() const
{
// FIXME: Implement this.
VERIFY_NOT_REACHED();

View file

@ -6,8 +6,8 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/Optional.h>
#include <AK/String.h>
#include <LibChess/Chess.h>
#include <LibCore/Event.h>
@ -44,7 +44,7 @@ public:
{
}
virtual String to_string() const = 0;
virtual DeprecatedString to_string() const = 0;
virtual ~Command() = default;
};
@ -58,7 +58,7 @@ public:
static UCICommand from_string(StringView command);
virtual String to_string() const override;
virtual DeprecatedString to_string() const override;
};
class DebugCommand : public Command {
@ -76,7 +76,7 @@ public:
static DebugCommand from_string(StringView command);
virtual String to_string() const override;
virtual DeprecatedString to_string() const override;
Flag flag() const { return m_flag; }
@ -93,12 +93,12 @@ public:
static IsReadyCommand from_string(StringView command);
virtual String to_string() const override;
virtual DeprecatedString to_string() const override;
};
class SetOptionCommand : public Command {
public:
explicit SetOptionCommand(StringView name, Optional<String> value = {})
explicit SetOptionCommand(StringView name, Optional<DeprecatedString> value = {})
: Command(Command::Type::SetOption)
, m_name(name)
, m_value(value)
@ -107,19 +107,19 @@ public:
static SetOptionCommand from_string(StringView command);
virtual String to_string() const override;
virtual DeprecatedString to_string() const override;
String const& name() const { return m_name; }
Optional<String> const& value() const { return m_value; }
DeprecatedString const& name() const { return m_name; }
Optional<DeprecatedString> const& value() const { return m_value; }
private:
String m_name;
Optional<String> m_value;
DeprecatedString m_name;
Optional<DeprecatedString> m_value;
};
class PositionCommand : public Command {
public:
explicit PositionCommand(Optional<String> const& fen, Vector<Chess::Move> const& moves)
explicit PositionCommand(Optional<DeprecatedString> const& fen, Vector<Chess::Move> const& moves)
: Command(Command::Type::Position)
, m_fen(fen)
, m_moves(moves)
@ -128,13 +128,13 @@ public:
static PositionCommand from_string(StringView command);
virtual String to_string() const override;
virtual DeprecatedString to_string() const override;
Optional<String> const& fen() const { return m_fen; }
Optional<DeprecatedString> const& fen() const { return m_fen; }
Vector<Chess::Move> const& moves() const { return m_moves; }
private:
Optional<String> m_fen;
Optional<DeprecatedString> m_fen;
Vector<Chess::Move> m_moves;
};
@ -147,7 +147,7 @@ public:
static GoCommand from_string(StringView command);
virtual String to_string() const override;
virtual DeprecatedString to_string() const override;
Optional<Vector<Chess::Move>> searchmoves;
bool ponder { false };
@ -172,7 +172,7 @@ public:
static StopCommand from_string(StringView command);
virtual String to_string() const override;
virtual DeprecatedString to_string() const override;
};
class IdCommand : public Command {
@ -191,14 +191,14 @@ public:
static IdCommand from_string(StringView command);
virtual String to_string() const override;
virtual DeprecatedString to_string() const override;
Type field_type() const { return m_field_type; }
String const& value() const { return m_value; }
DeprecatedString const& value() const { return m_value; }
private:
Type m_field_type;
String m_value;
DeprecatedString m_value;
};
class UCIOkCommand : public Command {
@ -210,7 +210,7 @@ public:
static UCIOkCommand from_string(StringView command);
virtual String to_string() const override;
virtual DeprecatedString to_string() const override;
};
class ReadyOkCommand : public Command {
@ -222,7 +222,7 @@ public:
static ReadyOkCommand from_string(StringView command);
virtual String to_string() const override;
virtual DeprecatedString to_string() const override;
};
class BestMoveCommand : public Command {
@ -235,7 +235,7 @@ public:
static BestMoveCommand from_string(StringView command);
virtual String to_string() const override;
virtual DeprecatedString to_string() const override;
Chess::Move move() const { return m_move; }
@ -252,7 +252,7 @@ public:
static InfoCommand from_string(StringView command);
virtual String to_string() const override;
virtual DeprecatedString to_string() const override;
Optional<int> depth;
Optional<int> seldepth;

View file

@ -7,7 +7,7 @@
#include "UCIEndpoint.h"
#include <AK/ByteBuffer.h>
#include <AK/Debug.h>
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <LibCore/EventLoop.h>
#include <LibCore/File.h>
@ -23,7 +23,7 @@ Endpoint::Endpoint(NonnullRefPtr<Core::IODevice> in, NonnullRefPtr<Core::IODevic
void Endpoint::send_command(Command const& command)
{
dbgln_if(UCI_DEBUG, "{} Sent UCI Command: {}", class_name(), String(command.to_string().characters(), Chomp));
dbgln_if(UCI_DEBUG, "{} Sent UCI Command: {}", class_name(), DeprecatedString(command.to_string().characters(), Chomp));
m_out->write(command.to_string());
}
@ -70,7 +70,7 @@ void Endpoint::set_in_notifier()
NonnullOwnPtr<Command> Endpoint::read_command()
{
String line(ReadonlyBytes(m_in->read_line(4096).bytes()), Chomp);
DeprecatedString line(ReadonlyBytes(m_in->read_line(4096).bytes()), Chomp);
dbgln_if(UCI_DEBUG, "{} Received UCI Command: {}", class_name(), line);

View file

@ -15,7 +15,7 @@ CodeComprehensionEngine::CodeComprehensionEngine(FileDB const& filedb, bool shou
{
}
void CodeComprehensionEngine::set_declarations_of_document(String const& filename, Vector<Declaration>&& declarations)
void CodeComprehensionEngine::set_declarations_of_document(DeprecatedString const& filename, Vector<Declaration>&& declarations)
{
// Callback may not be configured if we're running tests
if (!set_declarations_of_document_callback)
@ -31,7 +31,7 @@ void CodeComprehensionEngine::set_declarations_of_document(String const& filenam
set_declarations_of_document_callback(filename, move(declarations));
}
void CodeComprehensionEngine::set_todo_entries_of_document(String const& filename, Vector<TodoEntry>&& todo_entries)
void CodeComprehensionEngine::set_todo_entries_of_document(DeprecatedString const& filename, Vector<TodoEntry>&& todo_entries)
{
// Callback may not be configured if we're running tests
if (!set_todo_entries_of_document_callback)

View file

@ -24,33 +24,33 @@ public:
CodeComprehensionEngine(FileDB const& filedb, bool store_all_declarations = false);
virtual ~CodeComprehensionEngine() = default;
virtual Vector<AutocompleteResultEntry> get_suggestions(String const& file, GUI::TextPosition const& autocomplete_position) = 0;
virtual Vector<AutocompleteResultEntry> get_suggestions(DeprecatedString const& file, GUI::TextPosition const& autocomplete_position) = 0;
// TODO: In the future we can pass the range that was edited and only re-parse what we have to.
virtual void on_edit([[maybe_unused]] String const& file) {};
virtual void file_opened([[maybe_unused]] String const& file) {};
virtual void on_edit([[maybe_unused]] DeprecatedString const& file) {};
virtual void file_opened([[maybe_unused]] DeprecatedString const& file) {};
virtual Optional<ProjectLocation> find_declaration_of(String const&, GUI::TextPosition const&) { return {}; }
virtual Optional<ProjectLocation> find_declaration_of(DeprecatedString const&, GUI::TextPosition const&) { return {}; }
struct FunctionParamsHint {
Vector<String> params;
Vector<DeprecatedString> params;
size_t current_index { 0 };
};
virtual Optional<FunctionParamsHint> get_function_params_hint(String const&, GUI::TextPosition const&) { return {}; }
virtual Optional<FunctionParamsHint> get_function_params_hint(DeprecatedString const&, GUI::TextPosition const&) { return {}; }
virtual Vector<TokenInfo> get_tokens_info(String const&) { return {}; }
virtual Vector<TokenInfo> get_tokens_info(DeprecatedString const&) { return {}; }
Function<void(String const&, Vector<Declaration>&&)> set_declarations_of_document_callback;
Function<void(String const&, Vector<TodoEntry>&&)> set_todo_entries_of_document_callback;
Function<void(DeprecatedString const&, Vector<Declaration>&&)> set_declarations_of_document_callback;
Function<void(DeprecatedString const&, Vector<TodoEntry>&&)> set_todo_entries_of_document_callback;
protected:
FileDB const& filedb() const { return m_filedb; }
void set_declarations_of_document(String const&, Vector<Declaration>&&);
void set_todo_entries_of_document(String const&, Vector<TodoEntry>&&);
HashMap<String, Vector<Declaration>> const& all_declarations() const { return m_all_declarations; }
void set_declarations_of_document(DeprecatedString const&, Vector<Declaration>&&);
void set_todo_entries_of_document(DeprecatedString const&, Vector<TodoEntry>&&);
HashMap<DeprecatedString, Vector<Declaration>> const& all_declarations() const { return m_all_declarations; }
private:
HashMap<String, Vector<Declaration>> m_all_declarations;
HashMap<DeprecatedString, Vector<Declaration>> m_all_declarations;
FileDB const& m_filedb;
bool m_store_all_declarations { false };
};

View file

@ -19,10 +19,10 @@ private:
: LanguageServers::ConnectionFromClient(move(socket))
{
m_autocomplete_engine = make<CodeComprehension::Cpp::CppComprehensionEngine>(m_filedb);
m_autocomplete_engine->set_declarations_of_document_callback = [this](String const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
m_autocomplete_engine->set_declarations_of_document_callback = [this](DeprecatedString const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
async_declarations_in_document(filename, move(declarations));
};
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](String const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](DeprecatedString const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
async_todo_entries_in_document(filename, move(todo_entries));
};
}

View file

@ -25,7 +25,7 @@ CppComprehensionEngine::CppComprehensionEngine(FileDB const& filedb)
{
}
CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_or_create_document_data(String const& file)
CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_or_create_document_data(DeprecatedString const& file)
{
auto absolute_path = filedb().to_absolute_path(file);
if (!m_documents.contains(absolute_path)) {
@ -34,7 +34,7 @@ CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_or_creat
return get_document_data(absolute_path);
}
CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_document_data(String const& file) const
CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_document_data(DeprecatedString const& file) const
{
auto absolute_path = filedb().to_absolute_path(file);
auto document_data = m_documents.get(absolute_path);
@ -43,7 +43,7 @@ CppComprehensionEngine::DocumentData const* CppComprehensionEngine::get_document
return document_data.value();
}
OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_document_data_for(String const& file)
OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_document_data_for(DeprecatedString const& file)
{
if (m_unfinished_documents.contains(file)) {
return {};
@ -56,12 +56,12 @@ OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_docu
return create_document_data(move(document.value()), file);
}
void CppComprehensionEngine::set_document_data(String const& file, OwnPtr<DocumentData>&& data)
void CppComprehensionEngine::set_document_data(DeprecatedString const& file, OwnPtr<DocumentData>&& data)
{
m_documents.set(filedb().to_absolute_path(file), move(data));
}
Vector<CodeComprehension::AutocompleteResultEntry> CppComprehensionEngine::get_suggestions(String const& file, const GUI::TextPosition& autocomplete_position)
Vector<CodeComprehension::AutocompleteResultEntry> CppComprehensionEngine::get_suggestions(DeprecatedString const& file, const GUI::TextPosition& autocomplete_position)
{
Cpp::Position position { autocomplete_position.line(), autocomplete_position.column() > 0 ? autocomplete_position.column() - 1 : 0 };
@ -104,7 +104,7 @@ Vector<CodeComprehension::AutocompleteResultEntry> CppComprehensionEngine::get_s
Optional<Vector<CodeComprehension::AutocompleteResultEntry>> CppComprehensionEngine::try_autocomplete_name(DocumentData const& document, ASTNode const& node, Optional<Token> containing_token) const
{
auto partial_text = String::empty();
auto partial_text = DeprecatedString::empty();
if (containing_token.has_value() && containing_token.value().type() != Token::Type::ColonColon) {
partial_text = containing_token.value().text();
}
@ -121,7 +121,7 @@ Optional<Vector<CodeComprehension::AutocompleteResultEntry>> CppComprehensionEng
auto const& parent = static_cast<MemberExpression const&>(*node.parent());
auto partial_text = String::empty();
auto partial_text = DeprecatedString::empty();
if (containing_token.value().type() != Token::Type::Dot) {
if (&node != parent.property())
return {};
@ -131,7 +131,7 @@ Optional<Vector<CodeComprehension::AutocompleteResultEntry>> CppComprehensionEng
return autocomplete_property(document, parent, partial_text);
}
Vector<CodeComprehension::AutocompleteResultEntry> CppComprehensionEngine::autocomplete_name(DocumentData const& document, ASTNode const& node, String const& partial_text) const
Vector<CodeComprehension::AutocompleteResultEntry> CppComprehensionEngine::autocomplete_name(DocumentData const& document, ASTNode const& node, DeprecatedString const& partial_text) const
{
auto reference_scope = scope_of_reference_to_symbol(node);
auto current_scope = scope_of_node(node);
@ -206,7 +206,7 @@ Vector<StringView> CppComprehensionEngine::scope_of_reference_to_symbol(ASTNode
return scope_parts;
}
Vector<CodeComprehension::AutocompleteResultEntry> CppComprehensionEngine::autocomplete_property(DocumentData const& document, MemberExpression const& parent, const String partial_text) const
Vector<CodeComprehension::AutocompleteResultEntry> CppComprehensionEngine::autocomplete_property(DocumentData const& document, MemberExpression const& parent, const DeprecatedString partial_text) const
{
VERIFY(parent.object());
auto type = type_of(document, *parent.object());
@ -233,7 +233,7 @@ bool CppComprehensionEngine::is_property(ASTNode const& node) const
return parent.property() == &node;
}
String CppComprehensionEngine::type_of_property(DocumentData const& document, Identifier const& identifier) const
DeprecatedString CppComprehensionEngine::type_of_property(DocumentData const& document, Identifier const& identifier) const
{
auto& parent = verify_cast<MemberExpression>(*identifier.parent());
VERIFY(parent.object());
@ -253,12 +253,12 @@ String CppComprehensionEngine::type_of_property(DocumentData const& document, Id
VERIFY(verify_cast<NamedType>(*type).name());
if (verify_cast<NamedType>(*type).name())
return verify_cast<NamedType>(*type).name()->full_name();
return String::empty();
return DeprecatedString::empty();
}
return {};
}
String CppComprehensionEngine::type_of_variable(Identifier const& identifier) const
DeprecatedString CppComprehensionEngine::type_of_variable(Identifier const& identifier) const
{
ASTNode const* current = &identifier;
while (current) {
@ -269,7 +269,7 @@ String CppComprehensionEngine::type_of_variable(Identifier const& identifier) co
VERIFY(verify_cast<NamedType>(*var_or_param.type()).name());
if (verify_cast<NamedType>(*var_or_param.type()).name())
return verify_cast<NamedType>(*var_or_param.type()).name()->full_name();
return String::empty();
return DeprecatedString::empty();
}
}
}
@ -278,7 +278,7 @@ String CppComprehensionEngine::type_of_variable(Identifier const& identifier) co
return {};
}
String CppComprehensionEngine::type_of(DocumentData const& document, Expression const& expression) const
DeprecatedString CppComprehensionEngine::type_of(DocumentData const& document, Expression const& expression) const
{
if (expression.is_member_expression()) {
auto& member_expression = verify_cast<MemberExpression>(expression);
@ -304,7 +304,7 @@ String CppComprehensionEngine::type_of(DocumentData const& document, Expression
return type_of_variable(*identifier);
}
Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::properties_of_type(DocumentData const& document, String const& type) const
Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::properties_of_type(DocumentData const& document, DeprecatedString const& type) const
{
auto type_symbol = SymbolName::create(type);
auto decl = find_declaration_of(document, type_symbol);
@ -362,21 +362,21 @@ Vector<CppComprehensionEngine::Symbol> CppComprehensionEngine::get_child_symbols
return symbols;
}
String CppComprehensionEngine::document_path_from_include_path(StringView include_path) const
DeprecatedString CppComprehensionEngine::document_path_from_include_path(StringView include_path) const
{
static Regex<PosixExtended> library_include("<(.+)>");
static Regex<PosixExtended> user_defined_include("\"(.+)\"");
auto document_path_for_library_include = [&](StringView include_path) -> String {
auto document_path_for_library_include = [&](StringView include_path) -> DeprecatedString {
RegexResult result;
if (!library_include.search(include_path, result))
return {};
auto path = result.capture_group_matches.at(0).at(0).view.string_view();
return String::formatted("/usr/include/{}", path);
return DeprecatedString::formatted("/usr/include/{}", path);
};
auto document_path_for_user_defined_include = [&](StringView include_path) -> String {
auto document_path_for_user_defined_include = [&](StringView include_path) -> DeprecatedString {
RegexResult result;
if (!user_defined_include.search(include_path, result))
return {};
@ -391,17 +391,17 @@ String CppComprehensionEngine::document_path_from_include_path(StringView includ
return result;
}
void CppComprehensionEngine::on_edit(String const& file)
void CppComprehensionEngine::on_edit(DeprecatedString const& file)
{
set_document_data(file, create_document_data_for(file));
}
void CppComprehensionEngine::file_opened([[maybe_unused]] String const& file)
void CppComprehensionEngine::file_opened([[maybe_unused]] DeprecatedString const& file)
{
get_or_create_document_data(file);
}
Optional<CodeComprehension::ProjectLocation> CppComprehensionEngine::find_declaration_of(String const& filename, const GUI::TextPosition& identifier_position)
Optional<CodeComprehension::ProjectLocation> CppComprehensionEngine::find_declaration_of(DeprecatedString const& filename, const GUI::TextPosition& identifier_position)
{
auto const* document_ptr = get_or_create_document_data(filename);
if (!document_ptr)
@ -456,10 +456,10 @@ struct TargetDeclaration {
Property,
Scope
} type;
String name;
DeprecatedString name;
};
static Optional<TargetDeclaration> get_target_declaration(ASTNode const& node, String name);
static Optional<TargetDeclaration> get_target_declaration(ASTNode const& node, DeprecatedString name);
static Optional<TargetDeclaration> get_target_declaration(ASTNode const& node)
{
if (node.is_identifier()) {
@ -478,7 +478,7 @@ static Optional<TargetDeclaration> get_target_declaration(ASTNode const& node)
return {};
}
static Optional<TargetDeclaration> get_target_declaration(ASTNode const& node, String name)
static Optional<TargetDeclaration> get_target_declaration(ASTNode const& node, DeprecatedString name)
{
if (node.parent() && node.parent()->is_name()) {
auto& name_node = *verify_cast<Name>(node.parent());
@ -612,7 +612,7 @@ CodeComprehension::DeclarationType CppComprehensionEngine::type_of_declaration(C
return CodeComprehension::DeclarationType::Variable;
}
OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_document_data(String text, String const& filename)
OwnPtr<CppComprehensionEngine::DocumentData> CppComprehensionEngine::create_document_data(DeprecatedString text, DeprecatedString const& filename)
{
auto document_data = make<DocumentData>();
document_data->m_filename = filename;
@ -693,7 +693,7 @@ Optional<Vector<CodeComprehension::AutocompleteResultEntry>> CppComprehensionEng
System,
} include_type { Project };
String include_root;
DeprecatedString include_root;
bool already_has_suffix = false;
if (partial_include.starts_with('<')) {
include_root = "/usr/include/";
@ -716,7 +716,7 @@ Optional<Vector<CodeComprehension::AutocompleteResultEntry>> CppComprehensionEng
return {};
auto last_slash = partial_include.find_last('/');
auto include_dir = String::empty();
auto include_dir = DeprecatedString::empty();
auto partial_basename = partial_include.substring_view((last_slash.has_value() ? last_slash.value() : 0) + 1);
if (last_slash.has_value()) {
include_dir = partial_include.substring_view(1, last_slash.value());
@ -738,12 +738,12 @@ Optional<Vector<CodeComprehension::AutocompleteResultEntry>> CppComprehensionEng
if (Core::File::is_directory(LexicalPath::join(full_dir, path).string())) {
// FIXME: Don't dismiss the autocomplete when filling these suggestions.
auto completion = String::formatted("{}{}{}/", prefix, include_dir, path);
auto completion = DeprecatedString::formatted("{}{}{}/", prefix, include_dir, path);
options.empend(completion, include_dir.length() + partial_basename.length() + 1, CodeComprehension::Language::Cpp, path, CodeComprehension::AutocompleteResultEntry::HideAutocompleteAfterApplying::No);
} else if (path.ends_with(".h"sv)) {
// FIXME: Place the cursor after the trailing > or ", even if it was
// already typed.
auto completion = String::formatted("{}{}{}{}", prefix, include_dir, path, already_has_suffix ? "" : suffix);
auto completion = DeprecatedString::formatted("{}{}{}{}", prefix, include_dir, path, already_has_suffix ? "" : suffix);
options.empend(completion, include_dir.length() + partial_basename.length() + 1, CodeComprehension::Language::Cpp, path);
}
}
@ -764,10 +764,10 @@ RefPtr<Cpp::Declaration> CppComprehensionEngine::find_declaration_of(CppComprehe
return target_declaration;
}
String CppComprehensionEngine::SymbolName::scope_as_string() const
DeprecatedString CppComprehensionEngine::SymbolName::scope_as_string() const
{
if (scope.is_empty())
return String::empty();
return DeprecatedString::empty();
StringBuilder builder;
for (size_t i = 0; i < scope.size() - 1; ++i) {
@ -790,11 +790,11 @@ CppComprehensionEngine::SymbolName CppComprehensionEngine::SymbolName::create(St
return SymbolName::create(name, move(parts));
}
String CppComprehensionEngine::SymbolName::to_string() const
DeprecatedString CppComprehensionEngine::SymbolName::to_string() const
{
if (scope.is_empty())
return name;
return String::formatted("{}::{}", scope_as_string(), name);
return DeprecatedString::formatted("{}::{}", scope_as_string(), name);
}
bool CppComprehensionEngine::is_symbol_available(Symbol const& symbol, Vector<StringView> const& current_scope, Vector<StringView> const& reference_scope)
@ -818,7 +818,7 @@ bool CppComprehensionEngine::is_symbol_available(Symbol const& symbol, Vector<St
return true;
}
Optional<CodeComprehensionEngine::FunctionParamsHint> CppComprehensionEngine::get_function_params_hint(String const& filename, const GUI::TextPosition& identifier_position)
Optional<CodeComprehensionEngine::FunctionParamsHint> CppComprehensionEngine::get_function_params_hint(DeprecatedString const& filename, const GUI::TextPosition& identifier_position)
{
auto const* document_ptr = get_or_create_document_data(filename);
if (!document_ptr)
@ -923,13 +923,13 @@ Optional<CppComprehensionEngine::FunctionParamsHint> CppComprehensionEngine::get
for (auto token : document_of_declaration->parser().tokens_in_range(arg.start(), arg.end())) {
tokens_text.append(token.text());
}
hint.params.append(String::join(' ', tokens_text));
hint.params.append(DeprecatedString::join(' ', tokens_text));
}
return hint;
}
Vector<CodeComprehension::TokenInfo> CppComprehensionEngine::get_tokens_info(String const& filename)
Vector<CodeComprehension::TokenInfo> CppComprehensionEngine::get_tokens_info(DeprecatedString const& filename)
{
dbgln_if(CPP_LANGUAGE_SERVER_DEBUG, "CppComprehensionEngine::get_tokens_info: {}", filename);

View file

@ -6,8 +6,8 @@
#pragma once
#include <AK/DeprecatedString.h>
#include <AK/Function.h>
#include <AK/String.h>
#include <AK/Vector.h>
#include <DevTools/HackStudio/AutoCompleteResponse.h>
#include <DevTools/HackStudio/LanguageServers/FileDB.h>
@ -25,12 +25,12 @@ class CppComprehensionEngine : public CodeComprehensionEngine {
public:
CppComprehensionEngine(FileDB const& filedb);
virtual Vector<CodeComprehension::AutocompleteResultEntry> get_suggestions(String const& file, GUI::TextPosition const& autocomplete_position) override;
virtual void on_edit(String const& file) override;
virtual void file_opened([[maybe_unused]] String const& file) override;
virtual Optional<CodeComprehension::ProjectLocation> find_declaration_of(String const& filename, GUI::TextPosition const& identifier_position) override;
virtual Optional<FunctionParamsHint> get_function_params_hint(String const&, GUI::TextPosition const&) override;
virtual Vector<CodeComprehension::TokenInfo> get_tokens_info(String const& filename) override;
virtual Vector<CodeComprehension::AutocompleteResultEntry> get_suggestions(DeprecatedString const& file, GUI::TextPosition const& autocomplete_position) override;
virtual void on_edit(DeprecatedString const& file) override;
virtual void file_opened([[maybe_unused]] DeprecatedString const& file) override;
virtual Optional<CodeComprehension::ProjectLocation> find_declaration_of(DeprecatedString const& filename, GUI::TextPosition const& identifier_position) override;
virtual Optional<FunctionParamsHint> get_function_params_hint(DeprecatedString const&, GUI::TextPosition const&) override;
virtual Vector<CodeComprehension::TokenInfo> get_tokens_info(DeprecatedString const& filename) override;
private:
struct SymbolName {
@ -39,8 +39,8 @@ private:
static SymbolName create(StringView, Vector<StringView>&&);
static SymbolName create(StringView);
String scope_as_string() const;
String to_string() const;
DeprecatedString scope_as_string() const;
DeprecatedString to_string() const;
bool operator==(SymbolName const&) const = default;
};
@ -63,8 +63,8 @@ private:
friend Traits<SymbolName>;
struct DocumentData {
String const& filename() const { return m_filename; }
String const& text() const { return m_text; }
DeprecatedString const& filename() const { return m_filename; }
DeprecatedString const& text() const { return m_text; }
Preprocessor const& preprocessor() const
{
VERIFY(m_preprocessor);
@ -86,20 +86,20 @@ private:
return *m_parser;
}
String m_filename;
String m_text;
DeprecatedString m_filename;
DeprecatedString m_text;
OwnPtr<Preprocessor> m_preprocessor;
OwnPtr<Parser> m_parser;
HashMap<SymbolName, Symbol> m_symbols;
HashTable<String> m_available_headers;
HashTable<DeprecatedString> m_available_headers;
};
Vector<CodeComprehension::AutocompleteResultEntry> autocomplete_property(DocumentData const&, MemberExpression const&, const String partial_text) const;
Vector<AutocompleteResultEntry> autocomplete_name(DocumentData const&, ASTNode const&, String const& partial_text) const;
String type_of(DocumentData const&, Expression const&) const;
String type_of_property(DocumentData const&, Identifier const&) const;
String type_of_variable(Identifier const&) const;
Vector<CodeComprehension::AutocompleteResultEntry> autocomplete_property(DocumentData const&, MemberExpression const&, const DeprecatedString partial_text) const;
Vector<AutocompleteResultEntry> autocomplete_name(DocumentData const&, ASTNode const&, DeprecatedString const& partial_text) const;
DeprecatedString type_of(DocumentData const&, Expression const&) const;
DeprecatedString type_of_property(DocumentData const&, Identifier const&) const;
DeprecatedString type_of_variable(Identifier const&) const;
bool is_property(ASTNode const&) const;
RefPtr<Cpp::Declaration> find_declaration_of(DocumentData const&, ASTNode const&) const;
RefPtr<Cpp::Declaration> find_declaration_of(DocumentData const&, SymbolName const&) const;
@ -110,16 +110,16 @@ private:
Yes
};
Vector<Symbol> properties_of_type(DocumentData const& document, String const& type) const;
Vector<Symbol> properties_of_type(DocumentData const& document, DeprecatedString const& type) const;
Vector<Symbol> get_child_symbols(ASTNode const&) const;
Vector<Symbol> get_child_symbols(ASTNode const&, Vector<StringView> const& scope, Symbol::IsLocal) const;
DocumentData const* get_document_data(String const& file) const;
DocumentData const* get_or_create_document_data(String const& file);
void set_document_data(String const& file, OwnPtr<DocumentData>&& data);
DocumentData const* get_document_data(DeprecatedString const& file) const;
DocumentData const* get_or_create_document_data(DeprecatedString const& file);
void set_document_data(DeprecatedString const& file, OwnPtr<DocumentData>&& data);
OwnPtr<DocumentData> create_document_data_for(String const& file);
String document_path_from_include_path(StringView include_path) const;
OwnPtr<DocumentData> create_document_data_for(DeprecatedString const& file);
DeprecatedString document_path_from_include_path(StringView include_path) const;
void update_declared_symbols(DocumentData&);
void update_todo_entries(DocumentData&);
CodeComprehension::DeclarationType type_of_declaration(Cpp::Declaration const&);
@ -129,7 +129,7 @@ private:
Optional<CodeComprehension::ProjectLocation> find_preprocessor_definition(DocumentData const&, const GUI::TextPosition&);
Optional<Cpp::Preprocessor::Substitution> find_preprocessor_substitution(DocumentData const&, Cpp::Position const&);
OwnPtr<DocumentData> create_document_data(String text, String const& filename);
OwnPtr<DocumentData> create_document_data(DeprecatedString text, DeprecatedString const& filename);
Optional<Vector<CodeComprehension::AutocompleteResultEntry>> try_autocomplete_property(DocumentData const&, ASTNode const&, Optional<Token> containing_token) const;
Optional<Vector<CodeComprehension::AutocompleteResultEntry>> try_autocomplete_name(DocumentData const&, ASTNode const&, Optional<Token> containing_token) const;
Optional<Vector<CodeComprehension::AutocompleteResultEntry>> try_autocomplete_include(DocumentData const&, Token include_path_token, Cpp::Position const& cursor_position) const;
@ -145,12 +145,12 @@ private:
CodeComprehension::TokenInfo::SemanticType get_token_semantic_type(DocumentData const&, Token const&);
CodeComprehension::TokenInfo::SemanticType get_semantic_type_for_identifier(DocumentData const&, Position);
HashMap<String, OwnPtr<DocumentData>> m_documents;
HashMap<DeprecatedString, OwnPtr<DocumentData>> m_documents;
// A document's path will be in this set if we're currently processing it.
// A document is added to this set when we start processing it (e.g because it was #included) and removed when we're done.
// We use this to prevent circular #includes from looping indefinitely.
HashTable<String> m_unfinished_documents;
HashTable<DeprecatedString> m_unfinished_documents;
};
template<typename Func>

View file

@ -39,14 +39,14 @@ class FileDB : public CodeComprehension::FileDB {
public:
FileDB() = default;
void add(String filename, String content)
void add(DeprecatedString filename, DeprecatedString content)
{
m_map.set(filename, content);
}
virtual Optional<String> get_or_read_from_filesystem(StringView filename) const override
virtual Optional<DeprecatedString> get_or_read_from_filesystem(StringView filename) const override
{
String target_filename = filename;
DeprecatedString target_filename = filename;
if (!project_root().is_null() && filename.starts_with(project_root())) {
target_filename = LexicalPath::relative_path(filename, project_root());
}
@ -54,7 +54,7 @@ public:
}
private:
HashMap<String, String> m_map;
HashMap<DeprecatedString, DeprecatedString> m_map;
};
static void test_complete_local_args();
@ -75,11 +75,11 @@ int run_tests()
return s_some_test_failed ? 1 : 0;
}
static void add_file(FileDB& filedb, String const& name)
static void add_file(FileDB& filedb, DeprecatedString const& name)
{
auto file = Core::File::open(LexicalPath::join(TESTS_ROOT_DIR, name).string(), Core::OpenMode::ReadOnly);
VERIFY(!file.is_error());
filedb.add(name, String::copy(file.value()->read_all()));
filedb.add(name, DeprecatedString::copy(file.value()->read_all()));
}
void test_complete_local_args()
@ -182,19 +182,19 @@ void test_parameters_hint()
auto result = engine.get_function_params_hint("parameters_hint1.cpp", { 4, 9 });
if (!result.has_value())
FAIL("failed to get parameters hint (1)");
if (result->params != Vector<String> { "int x", "char y" } || result->current_index != 0)
if (result->params != Vector<DeprecatedString> { "int x", "char y" } || result->current_index != 0)
FAIL("bad result (1)");
result = engine.get_function_params_hint("parameters_hint1.cpp", { 5, 15 });
if (!result.has_value())
FAIL("failed to get parameters hint (2)");
if (result->params != Vector<String> { "int x", "char y" } || result->current_index != 1)
if (result->params != Vector<DeprecatedString> { "int x", "char y" } || result->current_index != 1)
FAIL("bad result (2)");
result = engine.get_function_params_hint("parameters_hint1.cpp", { 6, 8 });
if (!result.has_value())
FAIL("failed to get parameters hint (3)");
if (result->params != Vector<String> { "int x", "char y" } || result->current_index != 0)
if (result->params != Vector<DeprecatedString> { "int x", "char y" } || result->current_index != 0)
FAIL("bad result (3)");
PASS;

View file

@ -9,14 +9,14 @@
namespace CodeComprehension {
String FileDB::to_absolute_path(StringView filename) const
DeprecatedString FileDB::to_absolute_path(StringView filename) const
{
if (LexicalPath { filename }.is_absolute()) {
return filename;
}
if (m_project_root.is_null())
return filename;
return LexicalPath { String::formatted("{}/{}", m_project_root, filename) }.string();
return LexicalPath { DeprecatedString::formatted("{}/{}", m_project_root, filename) }.string();
}
}

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/String.h>
#include <AK/DeprecatedString.h>
#include <AK/StringView.h>
namespace CodeComprehension {
@ -18,16 +18,16 @@ class FileDB {
public:
virtual ~FileDB() = default;
virtual Optional<String> get_or_read_from_filesystem(StringView filename) const = 0;
virtual Optional<DeprecatedString> get_or_read_from_filesystem(StringView filename) const = 0;
void set_project_root(StringView project_root) { m_project_root = project_root; }
String const& project_root() const { return m_project_root; }
String to_absolute_path(StringView filename) const;
DeprecatedString const& project_root() const { return m_project_root; }
DeprecatedString to_absolute_path(StringView filename) const;
protected:
FileDB() = default;
private:
String m_project_root;
DeprecatedString m_project_root;
};
}

View file

@ -20,10 +20,10 @@ private:
: LanguageServers::ConnectionFromClient(move(socket))
{
m_autocomplete_engine = make<CodeComprehension::Shell::ShellComprehensionEngine>(m_filedb);
m_autocomplete_engine->set_declarations_of_document_callback = [this](String const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
m_autocomplete_engine->set_declarations_of_document_callback = [this](DeprecatedString const& filename, Vector<CodeComprehension::Declaration>&& declarations) {
async_declarations_in_document(filename, move(declarations));
};
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](String const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
m_autocomplete_engine->set_todo_entries_of_document_callback = [this](DeprecatedString const& filename, Vector<CodeComprehension::TodoEntry>&& todo_entries) {
async_todo_entries_in_document(filename, move(todo_entries));
};
}

View file

@ -18,7 +18,7 @@ ShellComprehensionEngine::ShellComprehensionEngine(FileDB const& filedb)
{
}
ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_or_create_document_data(String const& file)
ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_or_create_document_data(DeprecatedString const& file)
{
auto absolute_path = filedb().to_absolute_path(file);
if (!m_documents.contains(absolute_path)) {
@ -27,7 +27,7 @@ ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_or_c
return get_document_data(absolute_path);
}
ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_document_data(String const& file) const
ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_document_data(DeprecatedString const& file) const
{
auto absolute_path = filedb().to_absolute_path(file);
auto document_data = m_documents.get(absolute_path);
@ -35,7 +35,7 @@ ShellComprehensionEngine::DocumentData const& ShellComprehensionEngine::get_docu
return *document_data.value();
}
OwnPtr<ShellComprehensionEngine::DocumentData> ShellComprehensionEngine::create_document_data_for(String const& file)
OwnPtr<ShellComprehensionEngine::DocumentData> ShellComprehensionEngine::create_document_data_for(DeprecatedString const& file)
{
auto document = filedb().get_or_read_from_filesystem(file);
if (!document.has_value())
@ -50,19 +50,19 @@ OwnPtr<ShellComprehensionEngine::DocumentData> ShellComprehensionEngine::create_
return document_data;
}
void ShellComprehensionEngine::set_document_data(String const& file, OwnPtr<DocumentData>&& data)
void ShellComprehensionEngine::set_document_data(DeprecatedString const& file, OwnPtr<DocumentData>&& data)
{
m_documents.set(filedb().to_absolute_path(file), move(data));
}
ShellComprehensionEngine::DocumentData::DocumentData(String&& _text, String _filename)
ShellComprehensionEngine::DocumentData::DocumentData(DeprecatedString&& _text, DeprecatedString _filename)
: filename(move(_filename))
, text(move(_text))
, node(parse())
{
}
Vector<String> const& ShellComprehensionEngine::DocumentData::sourced_paths() const
Vector<DeprecatedString> const& ShellComprehensionEngine::DocumentData::sourced_paths() const
{
if (all_sourced_paths.has_value())
return all_sourced_paths.value();
@ -88,12 +88,12 @@ Vector<String> const& ShellComprehensionEngine::DocumentData::sourced_paths() co
::Shell::AST::NodeVisitor::visit(node);
}
HashTable<String> sourced_files;
HashTable<DeprecatedString> sourced_files;
} visitor;
node->visit(visitor);
Vector<String> sourced_paths;
Vector<DeprecatedString> sourced_paths;
for (auto& entry : visitor.sourced_files)
sourced_paths.append(move(entry));
@ -133,7 +133,7 @@ size_t ShellComprehensionEngine::resolve(ShellComprehensionEngine::DocumentData
return offset;
}
Vector<CodeComprehension::AutocompleteResultEntry> ShellComprehensionEngine::get_suggestions(String const& file, const GUI::TextPosition& position)
Vector<CodeComprehension::AutocompleteResultEntry> ShellComprehensionEngine::get_suggestions(DeprecatedString const& file, const GUI::TextPosition& position)
{
dbgln_if(SH_LANGUAGE_SERVER_DEBUG, "ShellComprehensionEngine position {}:{}", position.line(), position.column());
@ -154,17 +154,17 @@ Vector<CodeComprehension::AutocompleteResultEntry> ShellComprehensionEngine::get
return entries;
}
void ShellComprehensionEngine::on_edit(String const& file)
void ShellComprehensionEngine::on_edit(DeprecatedString const& file)
{
set_document_data(file, create_document_data_for(file));
}
void ShellComprehensionEngine::file_opened([[maybe_unused]] String const& file)
void ShellComprehensionEngine::file_opened([[maybe_unused]] DeprecatedString const& file)
{
set_document_data(file, create_document_data_for(file));
}
Optional<CodeComprehension::ProjectLocation> ShellComprehensionEngine::find_declaration_of(String const& filename, const GUI::TextPosition& identifier_position)
Optional<CodeComprehension::ProjectLocation> ShellComprehensionEngine::find_declaration_of(DeprecatedString const& filename, const GUI::TextPosition& identifier_position)
{
dbgln_if(SH_LANGUAGE_SERVER_DEBUG, "find_declaration_of({}, {}:{})", filename, identifier_position.line(), identifier_position.column());
auto const& document = get_or_create_document_data(filename);
@ -195,7 +195,7 @@ Optional<CodeComprehension::ProjectLocation> ShellComprehensionEngine::find_decl
void ShellComprehensionEngine::update_declared_symbols(DocumentData const& document)
{
struct Visitor : public ::Shell::AST::NodeVisitor {
explicit Visitor(String const& filename)
explicit Visitor(DeprecatedString const& filename)
: filename(filename)
{
}
@ -207,7 +207,7 @@ void ShellComprehensionEngine::update_declared_symbols(DocumentData const& docum
if (!literal)
continue;
String name;
DeprecatedString name;
if (literal->is_bareword())
name = static_ptr_cast<::Shell::AST::BarewordLiteral>(literal)->text();
@ -225,7 +225,7 @@ void ShellComprehensionEngine::update_declared_symbols(DocumentData const& docum
declarations.append({ node->name().name, { filename, node->position().start_line.line_number, node->position().start_line.line_column }, CodeComprehension::DeclarationType::Function, {} });
}
String const& filename;
DeprecatedString const& filename;
Vector<CodeComprehension::Declaration> declarations;
} visitor { document.filename };

View file

@ -14,32 +14,32 @@ namespace CodeComprehension::Shell {
class ShellComprehensionEngine : public CodeComprehensionEngine {
public:
ShellComprehensionEngine(FileDB const& filedb);
virtual Vector<CodeComprehension::AutocompleteResultEntry> get_suggestions(String const& file, const GUI::TextPosition& position) override;
virtual void on_edit(String const& file) override;
virtual void file_opened([[maybe_unused]] String const& file) override;
virtual Optional<CodeComprehension::ProjectLocation> find_declaration_of(String const& filename, const GUI::TextPosition& identifier_position) override;
virtual Vector<CodeComprehension::AutocompleteResultEntry> get_suggestions(DeprecatedString const& file, const GUI::TextPosition& position) override;
virtual void on_edit(DeprecatedString const& file) override;
virtual void file_opened([[maybe_unused]] DeprecatedString const& file) override;
virtual Optional<CodeComprehension::ProjectLocation> find_declaration_of(DeprecatedString const& filename, const GUI::TextPosition& identifier_position) override;
private:
struct DocumentData {
DocumentData(String&& text, String filename);
String filename;
String text;
DocumentData(DeprecatedString&& text, DeprecatedString filename);
DeprecatedString filename;
DeprecatedString text;
NonnullRefPtr<::Shell::AST::Node> node;
Vector<String> const& sourced_paths() const;
Vector<DeprecatedString> const& sourced_paths() const;
private:
NonnullRefPtr<::Shell::AST::Node> parse() const;
mutable Optional<Vector<String>> all_sourced_paths {};
mutable Optional<Vector<DeprecatedString>> all_sourced_paths {};
};
DocumentData const& get_document_data(String const& file) const;
DocumentData const& get_or_create_document_data(String const& file);
void set_document_data(String const& file, OwnPtr<DocumentData>&& data);
DocumentData const& get_document_data(DeprecatedString const& file) const;
DocumentData const& get_or_create_document_data(DeprecatedString const& file);
void set_document_data(DeprecatedString const& file, OwnPtr<DocumentData>&& data);
OwnPtr<DocumentData> create_document_data_for(String const& file);
String document_path_from_include_path(StringView include_path) const;
OwnPtr<DocumentData> create_document_data_for(DeprecatedString const& file);
DeprecatedString document_path_from_include_path(StringView include_path) const;
void update_declared_symbols(DocumentData const&);
static size_t resolve(ShellComprehensionEngine::DocumentData const& document, const GUI::TextPosition& position);
@ -52,7 +52,7 @@ private:
return *s_shell;
}
HashMap<String, OwnPtr<DocumentData>> m_documents;
HashMap<DeprecatedString, OwnPtr<DocumentData>> m_documents;
static RefPtr<::Shell::Shell> s_shell;
};
}

View file

@ -6,7 +6,7 @@
#pragma once
#include <AK/String.h>
#include <AK/DeprecatedString.h>
namespace CodeComprehension {
@ -16,11 +16,11 @@ enum class Language {
};
struct AutocompleteResultEntry {
String completion;
DeprecatedString completion;
size_t partial_input_length { 0 };
// TODO: Actually assign the value of this field in more places (when applicable).
Language language { Language::Unspecified };
String display_text {};
DeprecatedString display_text {};
enum class HideAutocompleteAfterApplying {
No,
@ -30,7 +30,7 @@ struct AutocompleteResultEntry {
};
struct ProjectLocation {
String file;
DeprecatedString file;
size_t line { 0 };
size_t column { 0 };
@ -51,10 +51,10 @@ enum class DeclarationType {
};
struct Declaration {
String name;
DeprecatedString name;
ProjectLocation position;
DeclarationType type;
String scope;
DeprecatedString scope;
bool operator==(Declaration const& other) const
{
@ -109,8 +109,8 @@ struct TokenInfo {
};
struct TodoEntry {
String content;
String filename;
DeprecatedString content;
DeprecatedString filename;
size_t line { 0 };
size_t column { 0 };
};

View file

@ -7,8 +7,8 @@
#include <LibCompress/Gzip.h>
#include <AK/DeprecatedString.h>
#include <AK/MemoryStream.h>
#include <AK/String.h>
#include <LibCore/DateTime.h>
namespace Compress {
@ -154,7 +154,7 @@ size_t GzipDecompressor::read(Bytes bytes)
return total_read;
}
Optional<String> GzipDecompressor::describe_header(ReadonlyBytes bytes)
Optional<DeprecatedString> GzipDecompressor::describe_header(ReadonlyBytes bytes)
{
if (bytes.size() < sizeof(BlockHeader))
return {};
@ -164,7 +164,7 @@ Optional<String> GzipDecompressor::describe_header(ReadonlyBytes bytes)
return {};
LittleEndian<u32> original_size = *reinterpret_cast<u32 const*>(bytes.offset(bytes.size() - sizeof(u32)));
return String::formatted("last modified: {}, original size {}", Core::DateTime::from_timestamp(header.modification_time).to_string(), (u32)original_size);
return DeprecatedString::formatted("last modified: {}, original size {}", Core::DateTime::from_timestamp(header.modification_time).to_string(), (u32)original_size);
}
bool GzipDecompressor::read_or_error(Bytes bytes)

View file

@ -50,7 +50,7 @@ public:
bool handle_any_error() override;
static Optional<ByteBuffer> decompress_all(ReadonlyBytes);
static Optional<String> describe_header(ReadonlyBytes);
static Optional<DeprecatedString> describe_header(ReadonlyBytes);
static bool is_likely_compressed(ReadonlyBytes bytes);
private:

View file

@ -20,27 +20,27 @@ Client& Client::the()
return *s_the;
}
void Client::pledge_domains(Vector<String> const& domains)
void Client::pledge_domains(Vector<DeprecatedString> const& domains)
{
async_pledge_domains(domains);
}
void Client::monitor_domain(String const& domain)
void Client::monitor_domain(DeprecatedString const& domain)
{
async_monitor_domain(domain);
}
Vector<String> Client::list_keys(StringView domain, StringView group)
Vector<DeprecatedString> Client::list_keys(StringView domain, StringView group)
{
return list_config_keys(domain, group);
}
Vector<String> Client::list_groups(StringView domain)
Vector<DeprecatedString> Client::list_groups(StringView domain)
{
return list_config_groups(domain);
}
String Client::read_string(StringView domain, StringView group, StringView key, StringView fallback)
DeprecatedString Client::read_string(StringView domain, StringView group, StringView key, StringView fallback)
{
return read_string_value(domain, group, key).value_or(fallback);
}
@ -85,42 +85,42 @@ void Client::add_group(StringView domain, StringView group)
add_group_entry(domain, group);
}
void Client::notify_changed_string_value(String const& domain, String const& group, String const& key, String const& value)
void Client::notify_changed_string_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value)
{
Listener::for_each([&](auto& listener) {
listener.config_string_did_change(domain, group, key, value);
});
}
void Client::notify_changed_i32_value(String const& domain, String const& group, String const& key, i32 value)
void Client::notify_changed_i32_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, i32 value)
{
Listener::for_each([&](auto& listener) {
listener.config_i32_did_change(domain, group, key, value);
});
}
void Client::notify_changed_bool_value(String const& domain, String const& group, String const& key, bool value)
void Client::notify_changed_bool_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, bool value)
{
Listener::for_each([&](auto& listener) {
listener.config_bool_did_change(domain, group, key, value);
});
}
void Client::notify_removed_key(String const& domain, String const& group, String const& key)
void Client::notify_removed_key(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key)
{
Listener::for_each([&](auto& listener) {
listener.config_key_was_removed(domain, group, key);
});
}
void Client::notify_removed_group(String const& domain, String const& group)
void Client::notify_removed_group(DeprecatedString const& domain, DeprecatedString const& group)
{
Listener::for_each([&](auto& listener) {
listener.config_group_was_removed(domain, group);
});
}
void Client::notify_added_group(String const& domain, String const& group)
void Client::notify_added_group(DeprecatedString const& domain, DeprecatedString const& group)
{
Listener::for_each([&](auto& listener) {
listener.config_group_was_added(domain, group);

View file

@ -21,13 +21,13 @@ class Client final
IPC_CLIENT_CONNECTION(Client, "/tmp/session/%sid/portal/config"sv)
public:
void pledge_domains(Vector<String> const&);
void monitor_domain(String const&);
void pledge_domains(Vector<DeprecatedString> const&);
void monitor_domain(DeprecatedString const&);
Vector<String> list_groups(StringView domain);
Vector<String> list_keys(StringView domain, StringView group);
Vector<DeprecatedString> list_groups(StringView domain);
Vector<DeprecatedString> list_keys(StringView domain, StringView group);
String read_string(StringView domain, StringView group, StringView key, StringView fallback);
DeprecatedString read_string(StringView domain, StringView group, StringView key, StringView fallback);
i32 read_i32(StringView domain, StringView group, StringView key, i32 fallback);
bool read_bool(StringView domain, StringView group, StringView key, bool fallback);
@ -46,25 +46,25 @@ private:
{
}
void notify_changed_string_value(String const& domain, String const& group, String const& key, String const& value) override;
void notify_changed_i32_value(String const& domain, String const& group, String const& key, i32 value) override;
void notify_changed_bool_value(String const& domain, String const& group, String const& key, bool value) override;
void notify_removed_key(String const& domain, String const& group, String const& key) override;
void notify_removed_group(String const& domain, String const& group) override;
void notify_added_group(String const& domain, String const& group) override;
void notify_changed_string_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value) override;
void notify_changed_i32_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, i32 value) override;
void notify_changed_bool_value(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, bool value) override;
void notify_removed_key(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key) override;
void notify_removed_group(DeprecatedString const& domain, DeprecatedString const& group) override;
void notify_added_group(DeprecatedString const& domain, DeprecatedString const& group) override;
};
inline Vector<String> list_groups(StringView domain)
inline Vector<DeprecatedString> list_groups(StringView domain)
{
return Client::the().list_groups(domain);
}
inline Vector<String> list_keys(StringView domain, StringView group)
inline Vector<DeprecatedString> list_keys(StringView domain, StringView group)
{
return Client::the().list_keys(domain, group);
}
inline String read_string(StringView domain, StringView group, StringView key, StringView fallback = {})
inline DeprecatedString read_string(StringView domain, StringView group, StringView key, StringView fallback = {})
{
return Client::the().read_string(domain, group, key, fallback);
}
@ -109,17 +109,17 @@ inline void add_group(StringView domain, StringView group)
Client::the().add_group(domain, group);
}
inline void pledge_domains(Vector<String> const& domains)
inline void pledge_domains(Vector<DeprecatedString> const& domains)
{
Client::the().pledge_domains(domains);
}
inline void pledge_domain(String const& domain)
inline void pledge_domain(DeprecatedString const& domain)
{
Client::the().pledge_domains({ domain });
}
inline void monitor_domain(String const& domain)
inline void monitor_domain(DeprecatedString const& domain)
{
Client::the().monitor_domain(domain);
}

View file

@ -4,9 +4,9 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/Function.h>
#include <AK/HashTable.h>
#include <AK/String.h>
#include <LibConfig/Listener.h>
namespace Config {
@ -29,27 +29,27 @@ void Listener::for_each(Function<void(Listener&)> callback)
callback(*listener);
}
void Listener::config_string_did_change(String const&, String const&, String const&, String const&)
void Listener::config_string_did_change(DeprecatedString const&, DeprecatedString const&, DeprecatedString const&, DeprecatedString const&)
{
}
void Listener::config_i32_did_change(String const&, String const&, String const&, i32)
void Listener::config_i32_did_change(DeprecatedString const&, DeprecatedString const&, DeprecatedString const&, i32)
{
}
void Listener::config_bool_did_change(String const&, String const&, String const&, bool)
void Listener::config_bool_did_change(DeprecatedString const&, DeprecatedString const&, DeprecatedString const&, bool)
{
}
void Listener::config_key_was_removed(String const&, String const&, String const&)
void Listener::config_key_was_removed(DeprecatedString const&, DeprecatedString const&, DeprecatedString const&)
{
}
void Listener::config_group_was_removed(String const&, String const&)
void Listener::config_group_was_removed(DeprecatedString const&, DeprecatedString const&)
{
}
void Listener::config_group_was_added(String const&, String const&)
void Listener::config_group_was_added(DeprecatedString const&, DeprecatedString const&)
{
}

View file

@ -16,12 +16,12 @@ public:
static void for_each(Function<void(Listener&)>);
virtual void config_string_did_change(String const& domain, String const& group, String const& key, String const& value);
virtual void config_i32_did_change(String const& domain, String const& group, String const& key, i32 value);
virtual void config_bool_did_change(String const& domain, String const& group, String const& key, bool value);
virtual void config_key_was_removed(String const& domain, String const& group, String const& key);
virtual void config_group_was_removed(String const& domain, String const& group);
virtual void config_group_was_added(String const& domain, String const& group);
virtual void config_string_did_change(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, DeprecatedString const& value);
virtual void config_i32_did_change(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, i32 value);
virtual void config_bool_did_change(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key, bool value);
virtual void config_key_was_removed(DeprecatedString const& domain, DeprecatedString const& group, DeprecatedString const& key);
virtual void config_group_was_removed(DeprecatedString const& domain, DeprecatedString const& group);
virtual void config_group_was_added(DeprecatedString const& domain, DeprecatedString const& group);
protected:
Listener();

View file

@ -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();

View file

@ -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;
};

View file

@ -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);

View file

@ -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:

View file

@ -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);

View file

@ -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);
}

View file

@ -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())

View file

@ -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 };
};

View file

@ -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;

View file

@ -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; }

View file

@ -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);

View file

@ -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();

View file

@ -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);
}

View file

@ -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;

View file

@ -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>

View file

@ -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;

View 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 };
};

View file

@ -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 {

View file

@ -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);
}

View file

@ -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 {

View file

@ -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))

View file

@ -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;
};
}

View file

@ -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 {};

View file

@ -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);

View file

@ -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;

View file

@ -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();

View file

@ -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>

View file

@ -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/xportablebitmap";
@ -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)) \

View file

@ -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);
}

View file

@ -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;

View file

@ -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)));
}

View file

@ -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; \

View file

@ -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)

View file

@ -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 = {});
};
}

View file

@ -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);
}
}

View file

@ -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;
};
}

View file

@ -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))

View file

@ -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;
};

View file

@ -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));
}));

View file

@ -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);

View file

@ -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 {};

View file

@ -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 = {});
}

View file

@ -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 {};
};
}

Some files were not shown because too many files have changed in this diff Show more