1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 04:37:44 +00:00

Everywhere: Rename {Deprecated => Byte}String

This commit un-deprecates DeprecatedString, and repurposes it as a byte
string.
As the null state has already been removed, there are no other
particularly hairy blockers in repurposing this type as a byte string
(what it _really_ is).

This commit is auto-generated:
  $ xs=$(ack -l \bDeprecatedString\b\|deprecated_string AK Userland \
    Meta Ports Ladybird Tests Kernel)
  $ perl -pie 's/\bDeprecatedString\b/ByteString/g;
    s/deprecated_string/byte_string/g' $xs
  $ clang-format --style=file -i \
    $(git diff --name-only | grep \.cpp\|\.h)
  $ gn format $(git ls-files '*.gn' '*.gni')
This commit is contained in:
Ali Mohammad Pur 2023-12-16 17:49:34 +03:30 committed by Ali Mohammad Pur
parent 38d62563b3
commit 5e1499d104
1615 changed files with 10257 additions and 10257 deletions

View file

@ -97,13 +97,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Vector<JsonValue> sorted_regions = json.as_array().values();
quick_sort(sorted_regions, [](auto& a, auto& b) {
return a.as_object().get_deprecated_string("ip_address"sv).value_or({}) < b.as_object().get_deprecated_string("ip_address"sv).value_or({});
return a.as_object().get_byte_string("ip_address"sv).value_or({}) < b.as_object().get_byte_string("ip_address"sv).value_or({});
});
for (auto& value : sorted_regions) {
auto& if_object = value.as_object();
auto ip_address = if_object.get_deprecated_string("ip_address"sv).value_or({});
auto ip_address = if_object.get_byte_string("ip_address"sv).value_or({});
if (!flag_numeric) {
auto from_string = IPv4Address::from_string(ip_address);
@ -116,7 +116,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
}
auto mac_address = if_object.get_deprecated_string("mac_address"sv).value_or({});
auto mac_address = if_object.get_byte_string("mac_address"sv).value_or({});
if (proto_address_column != -1)
columns[proto_address_column].buffer = ip_address;

View file

@ -26,7 +26,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.parse(arguments);
Core::EventLoop loop;
Core::DirIterator iterator(DeprecatedString::formatted("/proc/{}/stacks", pid), Core::DirIterator::SkipDots);
Core::DirIterator iterator(ByteString::formatted("/proc/{}/stacks", pid), Core::DirIterator::SkipDots);
if (iterator.has_error()) {
warnln("Error: pid '{}' doesn't appear to exist.", pid);
return 1;
@ -54,7 +54,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
// See if we can find the sources in /usr/src
// FIXME: I'm sure this can be improved!
auto full_path = LexicalPath::canonicalized_path(DeprecatedString::formatted("/usr/src/serenity/dummy/dummy/{}", source_position.file_path));
auto full_path = LexicalPath::canonicalized_path(ByteString::formatted("/usr/src/serenity/dummy/dummy/{}", source_position.file_path));
if (access(full_path.characters(), F_OK) == 0) {
linked = true;
auto url = URL::create_with_file_scheme(full_path, {}, hostname);

View file

@ -51,7 +51,7 @@ static ErrorOr<int> weekday_index(StringView weekday_name)
static ErrorOr<int> default_weekday_start()
{
auto calendar_config = TRY(Core::ConfigFile::open_for_app("Calendar"sv));
String default_first_day_of_week = TRY(String::from_deprecated_string(calendar_config->read_entry("View"sv, "FirstDayOfWeek"sv, "Sunday"sv)));
String default_first_day_of_week = TRY(String::from_byte_string(calendar_config->read_entry("View"sv, "FirstDayOfWeek"sv, "Sunday"sv)));
return TRY(weekday_index(default_first_day_of_week));
}

View file

@ -35,8 +35,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
exit(1);
}
auto hash_name = program_name.substring_view(0, program_name.length() - 3).to_deprecated_string().to_uppercase();
auto paths_help_string = DeprecatedString::formatted("File(s) to print {} checksum of", hash_name);
auto hash_name = program_name.substring_view(0, program_name.length() - 3).to_byte_string().to_uppercase();
auto paths_help_string = ByteString::formatted("File(s) to print {} checksum of", hash_name);
bool verify_from_paths = false;
Vector<StringView> paths;
@ -99,7 +99,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
hash.reset();
while (!file_from_filename->is_eof())
hash.update(TRY(file_from_filename->read_some(buffer)));
if (DeprecatedString::formatted("{:hex-dump}", hash.digest().bytes()) == line[0])
if (ByteString::formatted("{:hex-dump}", hash.digest().bytes()) == line[0])
outln("{}: OK", filename);
else {
++failed_verification_count;

View file

@ -22,8 +22,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio rpath"));
DeprecatedString file1_path;
DeprecatedString file2_path;
ByteString file1_path;
ByteString file2_path;
bool suppress_col1 { false };
bool suppress_col2 { false };
bool suppress_col3 { false };
@ -61,7 +61,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 1;
}
auto open_file = [](DeprecatedString const& path, auto& file, int file_number) {
auto open_file = [](ByteString const& path, auto& file, int file_number) {
auto file_or_error = Core::File::open_file_or_standard_stream(path, Core::File::OpenMode::Read);
if (file_or_error.is_error()) {
warnln("Failed to open file{} '{}': {}", file_number, path, file_or_error.error());
@ -90,17 +90,17 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
char tab { '\t' };
size_t tab_count { 0 };
DeprecatedString col1_fmt;
DeprecatedString col2_fmt;
DeprecatedString col3_fmt;
ByteString col1_fmt;
ByteString col2_fmt;
ByteString col3_fmt;
if (!suppress_col1)
col1_fmt = DeprecatedString::formatted("{}{}", DeprecatedString::repeated(tab, tab_count++), print_color ? COL1_COLOR : "{}");
col1_fmt = ByteString::formatted("{}{}", ByteString::repeated(tab, tab_count++), print_color ? COL1_COLOR : "{}");
if (!suppress_col2)
col2_fmt = DeprecatedString::formatted("{}{}", DeprecatedString::repeated(tab, tab_count++), print_color ? COL2_COLOR : "{}");
col2_fmt = ByteString::formatted("{}{}", ByteString::repeated(tab, tab_count++), print_color ? COL2_COLOR : "{}");
if (!suppress_col3)
col3_fmt = DeprecatedString::formatted("{}{}", DeprecatedString::repeated(tab, tab_count++), print_color ? COL3_COLOR : "{}");
col3_fmt = ByteString::formatted("{}{}", ByteString::repeated(tab, tab_count++), print_color ? COL3_COLOR : "{}");
auto cmp = [&](DeprecatedString const& str1, DeprecatedString const& str2) {
auto cmp = [&](ByteString const& str1, ByteString const& str2) {
if (case_insensitive)
return strcasecmp(str1.characters(), str2.characters());
return strcmp(str1.characters(), str2.characters());
@ -111,8 +111,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
int col1_count { 0 };
int col2_count { 0 };
int col3_count { 0 };
DeprecatedString file1_line;
DeprecatedString file2_line;
ByteString file1_line;
ByteString file2_line;
Array<u8, PAGE_SIZE> buffer;
auto should_continue_comparing_files = [&]() {
@ -167,7 +167,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
outln(col2_fmt, file2_line);
}
auto process_remaining = [&](DeprecatedString const& fmt, auto& file, int& count, bool print) {
auto process_remaining = [&](ByteString const& fmt, auto& file, int& count, bool print) {
while (true) {
auto can_read_result = file->can_read_line();
if (can_read_result.is_error() || !can_read_result.value())

View file

@ -21,7 +21,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
bool recursion_allowed = false;
bool verbose = false;
Vector<StringView> sources;
DeprecatedString destination;
ByteString destination;
Core::ArgsParser args_parser;
args_parser.add_option(link, "Link files instead of copying", "link", 'l');
@ -73,7 +73,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
for (auto& source : sources) {
auto destination_path = destination_is_existing_dir
? DeprecatedString::formatted("{}/{}", destination, LexicalPath::basename(source))
? ByteString::formatted("{}/{}", destination, LexicalPath::basename(source))
: destination;
auto result = FileSystem::copy_file_or_directory(

View file

@ -23,7 +23,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Cpp::Lexer lexer(content);
lexer.lex_iterable([](auto token) {
outln("{}", token.to_deprecated_string());
outln("{}", token.to_byte_string());
});
return 0;

View file

@ -21,7 +21,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto file = TRY(Core::File::open(path, Core::File::OpenMode::Read));
auto content = TRY(file->read_until_eof());
DeprecatedString name = LexicalPath::basename(path);
ByteString name = LexicalPath::basename(path);
Cpp::Preprocessor cpp(name, StringView { content });
auto tokens = cpp.process_and_lex();
@ -31,13 +31,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (definition.value.parameters.is_empty())
outln("{}: {}", definition.key, definition.value.value);
else
outln("{}({}): {}", definition.key, DeprecatedString::join(',', definition.value.parameters), definition.value.value);
outln("{}({}): {}", definition.key, ByteString::join(',', definition.value.parameters), definition.value.value);
}
outln("");
}
for (auto& token : tokens) {
outln("{}", token.to_deprecated_string());
outln("{}", token.to_byte_string());
}
return 0;

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/QuickSort.h>
#include <AK/StdLibExtras.h>
#include <AK/Vector.h>
@ -33,9 +33,9 @@ struct Range {
}
};
static bool expand_list(DeprecatedString& list, Vector<Range>& ranges)
static bool expand_list(ByteString& list, Vector<Range>& ranges)
{
Vector<DeprecatedString> tokens = list.split(',', SplitBehavior::KeepEmpty);
Vector<ByteString> tokens = list.split(',', SplitBehavior::KeepEmpty);
for (auto& token : tokens) {
if (token.length() == 0) {
@ -128,7 +128,7 @@ static void process_line_bytes(StringView line, Vector<Range> const& ranges)
continue;
auto to = min(i.m_to, line.length());
auto sub_string = DeprecatedString(line).substring(i.m_from - 1, to - i.m_from + 1);
auto sub_string = ByteString(line).substring(i.m_from - 1, to - i.m_from + 1);
out("{}", sub_string);
}
outln();
@ -136,7 +136,7 @@ static void process_line_bytes(StringView line, Vector<Range> const& ranges)
static void process_line_fields(StringView line, Vector<Range> const& ranges, char delimiter, bool only_print_delimited_lines)
{
auto string_split = DeprecatedString(line).split(delimiter, SplitBehavior::KeepEmpty);
auto string_split = ByteString(line).split(delimiter, SplitBehavior::KeepEmpty);
if (string_split.size() == 1) {
if (!only_print_delimited_lines)
outln("{}", line);
@ -144,21 +144,21 @@ static void process_line_fields(StringView line, Vector<Range> const& ranges, ch
return;
}
Vector<DeprecatedString> output_fields;
Vector<ByteString> output_fields;
for (auto& range : ranges) {
for (size_t i = range.m_from - 1; i < min(range.m_to, string_split.size()); i++) {
output_fields.append(string_split[i]);
}
}
outln("{}", DeprecatedString::join(delimiter, output_fields));
outln("{}", ByteString::join(delimiter, output_fields));
}
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
DeprecatedString byte_list = "";
DeprecatedString fields_list = "";
DeprecatedString delimiter = "\t";
ByteString byte_list = "";
ByteString fields_list = "";
ByteString delimiter = "\t";
bool only_print_delimited_lines = false;
Vector<StringView> files;
@ -194,7 +194,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 1;
}
DeprecatedString ranges_list;
ByteString ranges_list;
Vector<Range> ranges_vector;
if (selected_bytes) {

View file

@ -57,17 +57,17 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
warnln("date: Format string must start with '+'");
return 1;
}
outln("{}", date.to_deprecated_string(format_string.substring_view(1)));
outln("{}", date.to_byte_string(format_string.substring_view(1)));
} else if (print_unix_date) {
outln("{}", date.timestamp());
} else if (print_iso_8601) {
outln("{}", date.to_deprecated_string("%Y-%m-%dT%H:%M:%S%:z"sv));
outln("{}", date.to_byte_string("%Y-%m-%dT%H:%M:%S%:z"sv));
} else if (print_rfc_5322) {
outln("{}", date.to_deprecated_string("%a, %d %b %Y %H:%M:%S %z"sv));
outln("{}", date.to_byte_string("%a, %d %b %Y %H:%M:%S %z"sv));
} else if (print_rfc_3339) {
outln("{}", date.to_deprecated_string("%Y-%m-%d %H:%M:%S%:z"sv));
outln("{}", date.to_byte_string("%Y-%m-%d %H:%M:%S%:z"sv));
} else {
outln("{}", date.to_deprecated_string("%Y-%m-%d %H:%M:%S %Z"sv));
outln("{}", date.to_byte_string("%Y-%m-%d %H:%M:%S %Z"sv));
}
return 0;
}

View file

@ -5,8 +5,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/ByteString.h>
#include <AK/CharacterTypes.h>
#include <AK/DeprecatedString.h>
#include <AK/NumberFormat.h>
#include <AK/Optional.h>
#include <AK/Vector.h>
@ -56,7 +56,7 @@ static void closing_statistics()
warnln("{}+{} blocks out", statistics.total_blocks_out, statistics.partial_blocks_out);
if (statistics.status != Noxfer) {
auto elapsed_time = statistics.timer.elapsed_time();
DeprecatedString copy_speed = "INF B/s";
ByteString copy_speed = "INF B/s";
if (!elapsed_time.is_zero()) {
auto speed = statistics.total_bytes_copied * 1000 / elapsed_time.to_milliseconds();
copy_speed = human_readable_quantity(speed, AK::HumanReadableBasedOn::Base2, "B/s"sv);
@ -83,7 +83,7 @@ static int handle_io_file_arguments(int& fd, int flags, StringView argument)
return -1;
}
fd = open(value.to_deprecated_string().characters(), flags, 0666);
fd = open(value.to_byte_string().characters(), flags, 0666);
if (fd == -1) {
warnln("Unable to open: {}", value);
return -1;

View file

@ -14,13 +14,13 @@
#include <stdlib.h>
struct FileSystem {
DeprecatedString fs;
ByteString fs;
size_t total_block_count { 0 };
size_t free_block_count { 0 };
size_t total_inode_count { 0 };
size_t free_inode_count { 0 };
size_t block_size { 0 };
DeprecatedString mount_point;
ByteString mount_point;
};
ErrorOr<int> serenity_main(Main::Arguments arguments)
@ -62,7 +62,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto const& json = json_result.as_array();
json.for_each([&](auto& value) {
auto& fs_object = value.as_object();
auto fs = fs_object.get_deprecated_string("class_name"sv).value_or({});
auto fs = fs_object.get_byte_string("class_name"sv).value_or({});
auto total_block_count = fs_object.get_u64("total_block_count"sv).value_or(0);
auto free_block_count = fs_object.get_u64("free_block_count"sv).value_or(0);
auto used_block_count = total_block_count - free_block_count;
@ -70,7 +70,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto free_inode_count = fs_object.get_u64("free_inode_count"sv).value_or(0);
auto used_inode_count = total_inode_count - free_inode_count;
auto block_size = fs_object.get_u64("block_size"sv).value_or(0);
auto mount_point = fs_object.get_deprecated_string("mount_point"sv).value_or({});
auto mount_point = fs_object.get_byte_string("mount_point"sv).value_or({});
auto used_percentage = 100;
if (total_block_count != 0)

View file

@ -12,7 +12,7 @@
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
bool null_terminated = false;
Vector<DeprecatedString> paths;
Vector<ByteString> paths;
Core::ArgsParser args_parser;
args_parser.add_option(null_terminated, "End each output line with \\0, rather than \\n", "zero", 'z');
args_parser.add_positional_argument(paths, "Path", "path");

View file

@ -141,7 +141,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
builder.append(" "sv);
}
builder.append(" "sv);
builder.append(insn.value().to_deprecated_string(virtual_offset, symbol_provider));
builder.append(insn.value().to_byte_string(virtual_offset, symbol_provider));
outln("{}", builder.string_view());
for (size_t bytes_printed = 7; bytes_printed < length; bytes_printed += 7) {

View file

@ -6,7 +6,7 @@
*/
#include <AK/ByteBuffer.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/ScopeGuard.h>
#include <AK/Types.h>
#include <AK/Vector.h>
@ -39,13 +39,13 @@ static Result average_result(Vector<Result> const& results)
return average;
}
static ErrorOr<Result> benchmark(DeprecatedString const& filename, int file_size, ByteBuffer& buffer, bool allow_cache);
static ErrorOr<Result> benchmark(ByteString const& filename, int file_size, ByteBuffer& buffer, bool allow_cache);
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
using namespace AK::TimeLiterals;
DeprecatedString directory = ".";
ByteString directory = ".";
i64 time_per_benchmark_sec = 10;
Vector<size_t> file_sizes;
Vector<size_t> block_sizes;
@ -68,7 +68,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
block_sizes = { 8192, 32768, 65536 };
}
auto filename = DeprecatedString::formatted("{}/disk_benchmark.tmp", directory);
auto filename = ByteString::formatted("{}/disk_benchmark.tmp", directory);
for (auto file_size : file_sizes) {
for (auto block_size : block_sizes) {
@ -101,7 +101,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 0;
}
ErrorOr<Result> benchmark(DeprecatedString const& filename, int file_size, ByteBuffer& buffer, bool allow_cache)
ErrorOr<Result> benchmark(ByteString const& filename, int file_size, ByteBuffer& buffer, bool allow_cache)
{
int flags = O_CREAT | O_TRUNC | O_RDWR;
if (!allow_cache)

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/LexicalPath.h>
#include <AK/NumberFormat.h>
#include <AK/Vector.h>
@ -32,7 +32,7 @@ struct DuOption {
bool one_file_system = false;
i64 threshold = 0;
TimeType time_type = TimeType::NotUsed;
Vector<DeprecatedString> excluded_patterns;
Vector<ByteString> excluded_patterns;
u64 block_size = 1024;
size_t max_depth = SIZE_MAX;
};
@ -57,12 +57,12 @@ struct AK::Traits<VisitedFile> : public DefaultTraits<VisitedFile> {
static HashTable<VisitedFile> s_visited_files;
static ErrorOr<void> parse_args(Main::Arguments arguments, Vector<DeprecatedString>& files, DuOption& du_option);
static u64 print_space_usage(DeprecatedString const& path, DuOption const& du_option, size_t current_depth, Optional<dev_t> root_device = {});
static ErrorOr<void> parse_args(Main::Arguments arguments, Vector<ByteString>& files, DuOption& du_option);
static u64 print_space_usage(ByteString const& path, DuOption const& du_option, size_t current_depth, Optional<dev_t> root_device = {});
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
Vector<DeprecatedString> files;
Vector<ByteString> files;
DuOption du_option;
TRY(parse_args(arguments, files, du_option));
@ -73,7 +73,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 0;
}
ErrorOr<void> parse_args(Main::Arguments arguments, Vector<DeprecatedString>& files, DuOption& du_option)
ErrorOr<void> parse_args(Main::Arguments arguments, Vector<ByteString>& files, DuOption& du_option)
{
bool summarize = false;
StringView pattern;
@ -140,7 +140,7 @@ ErrorOr<void> parse_args(Main::Arguments arguments, Vector<DeprecatedString>& fi
auto file = TRY(Core::File::open(exclude_from, Core::File::OpenMode::Read));
auto const buff = TRY(file->read_until_eof());
if (!buff.is_empty()) {
DeprecatedString patterns = DeprecatedString::copy(buff, Chomp);
ByteString patterns = ByteString::copy(buff, Chomp);
du_option.excluded_patterns.extend(patterns.split('\n'));
}
}
@ -156,7 +156,7 @@ ErrorOr<void> parse_args(Main::Arguments arguments, Vector<DeprecatedString>& fi
return {};
}
u64 print_space_usage(DeprecatedString const& path, DuOption const& du_option, size_t current_depth, Optional<dev_t> root_device)
u64 print_space_usage(ByteString const& path, DuOption const& du_option, size_t current_depth, Optional<dev_t> root_device)
{
u64 size = 0;
auto path_stat_or_error = Core::System::lstat(path);
@ -240,7 +240,7 @@ u64 print_space_usage(DeprecatedString const& path, DuOption const& du_option, s
break;
}
auto const formatted_time = Core::DateTime::from_timestamp(time).to_deprecated_string();
auto const formatted_time = Core::DateTime::from_timestamp(time).to_byte_string();
outln("\t{}\t{}", formatted_time, path);
}

View file

@ -39,7 +39,7 @@ static Optional<u8> parse_hex_number(GenericLexer& lexer)
return value;
}
static DeprecatedString interpret_backslash_escapes(StringView string, bool& no_trailing_newline)
static ByteString interpret_backslash_escapes(StringView string, bool& no_trailing_newline)
{
static constexpr auto escape_map = "a\ab\be\ef\fn\nr\rt\tv\v"sv;
static constexpr auto unescaped_chars = "\a\b\e\f\n\r\t\v\\"sv;
@ -94,14 +94,14 @@ static DeprecatedString interpret_backslash_escapes(StringView string, bool& no_
}
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio"));
Vector<DeprecatedString> text;
Vector<ByteString> text;
bool no_trailing_newline = false;
bool should_interpret_backslash_escapes = false;
@ -118,7 +118,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 0;
}
auto output = DeprecatedString::join(' ', text);
auto output = ByteString::join(' ', text);
if (should_interpret_backslash_escapes)
output = interpret_backslash_escapes(output, no_trailing_newline);
out("{}", output);

View file

@ -17,8 +17,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
bool ignore_env = false;
StringView split_string {};
Vector<DeprecatedString> values_to_set;
Vector<DeprecatedString> values_to_unset;
Vector<ByteString> values_to_set;
Vector<ByteString> values_to_unset;
Core::ArgsParser args_parser;
args_parser.set_stop_on_first_non_option(true);

View file

@ -5,7 +5,7 @@
*/
#include <AK/Assertions.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/GenericLexer.h>
#include <AK/NonnullOwnPtr.h>
#include <AK/OwnPtr.h>
@ -56,7 +56,7 @@ public:
virtual bool truth() const = 0;
virtual int integer() const = 0;
virtual DeprecatedString string() const = 0;
virtual ByteString string() const = 0;
virtual Type type() const = 0;
virtual ~Expression() = default;
};
@ -69,7 +69,7 @@ public:
{
}
ValueExpression(DeprecatedString&& v)
ValueExpression(ByteString&& v)
: as_string(move(v))
, m_type(Type::String)
{
@ -96,11 +96,11 @@ private:
}
VERIFY_NOT_REACHED();
}
virtual DeprecatedString string() const override
virtual ByteString string() const override
{
switch (m_type) {
case Type::Integer:
return DeprecatedString::formatted("{}", as_integer);
return ByteString::formatted("{}", as_integer);
case Type::String:
return as_string;
}
@ -110,7 +110,7 @@ private:
union {
int as_integer;
DeprecatedString as_string;
ByteString as_string;
};
Type m_type { Type::String };
};
@ -161,7 +161,7 @@ private:
VERIFY_NOT_REACHED();
}
virtual DeprecatedString string() const override
virtual ByteString string() const override
{
switch (m_op) {
case BooleanOperator::And:
@ -260,7 +260,7 @@ private:
VERIFY_NOT_REACHED();
}
virtual int integer() const override { return truth(); }
virtual DeprecatedString string() const override { return truth() ? "1" : "0"; }
virtual ByteString string() const override { return truth() ? "1" : "0"; }
virtual Type type() const override { return Type::Integer; }
ComparisonOperation m_op { ComparisonOperation::Less };
@ -330,9 +330,9 @@ private:
}
VERIFY_NOT_REACHED();
}
virtual DeprecatedString string() const override
virtual ByteString string() const override
{
return DeprecatedString::formatted("{}", integer());
return ByteString::formatted("{}", integer());
}
virtual Type type() const override
{
@ -388,7 +388,7 @@ private:
VERIFY_NOT_REACHED();
}
static auto safe_substring(DeprecatedString const& str, int start, int length)
static auto safe_substring(ByteString const& str, int start, int length)
{
if (start < 1 || (size_t)start > str.length())
fail("Index out of range");
@ -397,7 +397,7 @@ private:
fail("Index out of range");
return str.substring(start, length);
}
virtual DeprecatedString string() const override
virtual ByteString string() const override
{
if (m_op == StringOperation::Substring)
return safe_substring(m_str->string(), m_pos_or_chars->integer(), m_length->integer());
@ -412,7 +412,7 @@ private:
for (auto& m : match.matches)
count += m.view.length();
return DeprecatedString::number(count);
return ByteString::number(count);
} else {
if (!match.success)
return "";
@ -421,11 +421,11 @@ private:
for (auto& e : match.capture_group_matches[0])
result.append(e.view.string_view());
return result.to_deprecated_string();
return result.to_byte_string();
}
}
return DeprecatedString::number(integer());
return ByteString::number(integer());
}
virtual Type type() const override
{

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/MappedFile.h>
#include <LibCore/System.h>
@ -16,7 +16,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio rpath"));
DeprecatedString filename;
ByteString filename;
Core::ArgsParser args;
args.add_positional_argument(filename, "File to process", "file", Core::ArgsParser::Required::Yes);

View file

@ -62,7 +62,7 @@ struct FileData {
// File type as returned from readdir(), or DT_UNKNOWN.
unsigned char d_type { DT_UNKNOWN };
DeprecatedString full_path() const
ByteString full_path() const
{
if (root_path.is_empty())
return relative_path.string();
@ -73,9 +73,9 @@ struct FileData {
// POSIX says that a single slash should be added between the root path and the relative portion if the root path doesn't end in one
// any additional trailing slashes should be left unaltered.
if (root_path.ends_with('/'))
return DeprecatedString::formatted("{}{}", root_path, relative_path.string());
return ByteString::formatted("{}{}", root_path, relative_path.string());
return DeprecatedString::formatted("{}/{}", root_path, relative_path.string());
return ByteString::formatted("{}/{}", root_path, relative_path.string());
}
const struct stat* ensure_stat()
@ -579,7 +579,7 @@ private:
auto full_path_or_error = FileSystem::real_path(file_data.full_path());
if (!full_path_or_error.is_error()) {
auto fullpath = full_path_or_error.release_value();
auto url = URL::create_with_file_scheme(fullpath.to_deprecated_string());
auto url = URL::create_with_file_scheme(fullpath.to_byte_string());
out("\033]8;;{}\033\\{}{}\033]8;;\033\\", url.serialize(), file_data.full_path(), m_terminator);
printed = true;
}
@ -611,7 +611,7 @@ private:
virtual bool evaluate(FileData& file_data) const override
{
// Replace any occurrences of "{}" with the path.
Vector<DeprecatedString> full_paths;
Vector<ByteString> full_paths;
Vector<char*> argv = m_argv;
for (auto& arg : argv) {
if (StringView { arg, strlen(arg) } == "{}") {
@ -1030,8 +1030,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
for (auto& path : paths) {
LexicalPath lexical_path { path };
DeprecatedString dirname = lexical_path.dirname();
DeprecatedString basename = lexical_path.basename();
ByteString dirname = lexical_path.dirname();
ByteString basename = lexical_path.basename();
int dirfd = TRY(Core::System::open(dirname, O_RDONLY | O_DIRECTORY | O_CLOEXEC));

View file

@ -30,30 +30,30 @@ public:
if (!entry.has_string("quote"sv) || !entry.has_string("author"sv) || !entry.has_u64("utc_time"sv) || !entry.has_string("url"sv))
return {};
// From here on, trust that it's probably fine.
q.m_quote = entry.get_deprecated_string("quote"sv).value();
q.m_author = entry.get_deprecated_string("author"sv).value();
q.m_quote = entry.get_byte_string("quote"sv).value();
q.m_author = entry.get_byte_string("author"sv).value();
q.m_utc_time = entry.get_u64("utc_time"sv).value();
q.m_url = entry.get_deprecated_string("url"sv).value();
q.m_url = entry.get_byte_string("url"sv).value();
if (entry.has("context"sv))
q.m_context = entry.get_deprecated_string("context"sv).value();
q.m_context = entry.get_byte_string("context"sv).value();
return q;
}
DeprecatedString const& quote() const { return m_quote; }
DeprecatedString const& author() const { return m_author; }
ByteString const& quote() const { return m_quote; }
ByteString const& author() const { return m_author; }
u64 const& utc_time() const { return m_utc_time; }
DeprecatedString const& url() const { return m_url; }
Optional<DeprecatedString> const& context() const { return m_context; }
ByteString const& url() const { return m_url; }
Optional<ByteString> const& context() const { return m_context; }
private:
Quote() = default;
DeprecatedString m_quote;
DeprecatedString m_author;
ByteString m_quote;
ByteString m_author;
u64 m_utc_time;
DeprecatedString m_url;
Optional<DeprecatedString> m_context;
ByteString m_url;
Optional<ByteString> m_context;
};
static Vector<Quote> parse_all(JsonArray const& array)
@ -131,11 +131,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
if (show_color) {
out("\033[34m({})\033[m", datetime.to_deprecated_string());
out("\033[34m({})\033[m", datetime.to_byte_string());
out(" \033[34;1m<{}>\033[m", chosen_quote.author());
out(" \033[32m{}\033[m", chosen_quote.quote());
} else {
out("({})", datetime.to_deprecated_string());
out("({})", datetime.to_byte_string());
out(" <{}>", chosen_quote.author());
out(" {}", chosen_quote.quote());
}

View file

@ -34,7 +34,7 @@ static void handle_sigint(int)
g_debug_session = nullptr;
}
static void print_function_call(DeprecatedString function_name, size_t depth)
static void print_function_call(ByteString function_name, size_t depth)
{
for (size_t i = 0; i < depth; ++i) {
out(" ");

View file

@ -40,7 +40,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
TRY(Core::System::pledge("stdio rpath wpath cpath"));
bool inplace = false;
Vector<DeprecatedString> files;
Vector<ByteString> files;
Core::ArgsParser args_parser;
args_parser.set_general_help("Format GML files.");

View file

@ -6,7 +6,7 @@
*/
#include <AK/Assertions.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/LexicalPath.h>
#include <AK/ScopeGuard.h>
#include <AK/StringBuilder.h>
@ -46,7 +46,7 @@ void fail(StringView format, Ts... args)
constexpr StringView ere_special_characters = ".^$*+?()[{\\|"sv;
constexpr StringView basic_special_characters = ".^$*[\\"sv;
static DeprecatedString escape_characters(StringView string, StringView characters)
static ByteString escape_characters(StringView string, StringView characters)
{
StringBuilder builder;
for (auto ch : string) {
@ -55,12 +55,12 @@ static DeprecatedString escape_characters(StringView string, StringView characte
builder.append(ch);
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
static DeprecatedString& hostname()
static ByteString& hostname()
{
static DeprecatedString s_hostname;
static ByteString s_hostname;
if (s_hostname.is_empty()) {
auto result = Core::System::gethostname();
if (result.is_error())
@ -88,7 +88,7 @@ static void append_formatted_path(StringBuilder& builder, StringView path, Optio
auto full_path_or_error = FileSystem::real_path(path);
if (!full_path_or_error.is_error()) {
auto fullpath = full_path_or_error.release_value();
auto url = URL::create_with_file_scheme(fullpath.to_deprecated_string(), {}, hostname());
auto url = URL::create_with_file_scheme(fullpath.to_byte_string(), {}, hostname());
if (has_flag(print_type, PrintType::LineNumbers) && line_number.has_value())
url.set_query(MUST(String::formatted("line_number={}", *line_number)));
builder.appendff("\033]8;;{}\033\\", url.serialize());
@ -117,14 +117,14 @@ ErrorOr<int> serenity_main(Main::Arguments args)
{
TRY(Core::System::pledge("stdio rpath"));
DeprecatedString program_name = AK::LexicalPath::basename(args.strings[0]);
ByteString program_name = AK::LexicalPath::basename(args.strings[0]);
Vector<DeprecatedString> files;
Vector<ByteString> files;
bool recursive = (program_name == "rgrep"sv);
bool use_ere = (program_name == "egrep"sv);
bool fixed_strings = (program_name == "fgrep"sv);
Vector<DeprecatedString> patterns;
Vector<ByteString> patterns;
StringView pattern_file;
BinaryFileMode binary_mode { BinaryFileMode::Binary };
bool case_insensitive = false;
@ -219,7 +219,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
// should be ignored.
if (next_pattern.is_empty() && buffered_file->is_eof())
break;
patterns.append(next_pattern.to_deprecated_string());
patterns.append(next_pattern.to_byte_string());
}
}
@ -280,7 +280,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
auto pre_match_length = match.global_offset - last_printed_char_pos;
out(colored_output ? "{}\x1B[32m{}\x1B[0m"sv : "{}{}"sv,
pre_match_length > 0 ? StringView(&str[last_printed_char_pos], pre_match_length) : ""sv,
match.view.to_deprecated_string());
match.view.to_byte_string());
last_printed_char_pos = match.global_offset + match.view.length();
}
auto remaining_length = str.length() - last_printed_char_pos;
@ -328,7 +328,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
return {};
};
auto add_directory = [&handle_file, &exit_status, user_has_specified_files, suppress_errors](DeprecatedString base, Optional<DeprecatedString> recursive, auto handle_directory) -> void {
auto add_directory = [&handle_file, &exit_status, user_has_specified_files, suppress_errors](ByteString base, Optional<ByteString> recursive, auto handle_directory) -> void {
Core::DirIterator it(recursive.value_or(base), Core::DirIterator::Flags::SkipDots);
while (it.has_next()) {
auto path = it.next_full_path();

View file

@ -15,7 +15,7 @@
#include <unistd.h>
static bool use_color = false;
static void print(StringView name, JsonValue const&, Vector<DeprecatedString>& trail);
static void print(StringView name, JsonValue const&, Vector<ByteString>& trail);
static StringView color_name = ""sv;
static StringView color_index = ""sv;
@ -71,12 +71,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
color_off = "\033[0m"sv;
}
Vector<DeprecatedString> trail;
Vector<ByteString> trail;
print("json"sv, json, trail);
return 0;
}
static void print(StringView name, JsonValue const& value, Vector<DeprecatedString>& trail)
static void print(StringView name, JsonValue const& value, Vector<ByteString>& trail)
{
for (size_t i = 0; i < trail.size(); ++i)
out("{}", trail[i]);
@ -85,16 +85,16 @@ static void print(StringView name, JsonValue const& value, Vector<DeprecatedStri
if (value.is_object()) {
outln("{}{{}}{};", color_brace, color_off);
trail.append(DeprecatedString::formatted("{}{}{}.", color_name, name, color_off));
trail.append(ByteString::formatted("{}{}{}.", color_name, name, color_off));
value.as_object().for_each_member([&](auto& on, auto& ov) { print(on, ov, trail); });
trail.take_last();
return;
}
if (value.is_array()) {
outln("{}[]{};", color_brace, color_off);
trail.append(DeprecatedString::formatted("{}{}{}", color_name, name, color_off));
trail.append(ByteString::formatted("{}{}{}", color_name, name, color_off));
for (size_t i = 0; i < value.as_array().size(); ++i) {
auto element_name = DeprecatedString::formatted("{}{}[{}{}{}{}{}]{}", color_off, color_brace, color_off, color_index, i, color_off, color_brace, color_off);
auto element_name = ByteString::formatted("{}{}[{}{}{}{}{}]{}", color_off, color_brace, color_off, color_index, i, color_off, color_brace, color_off);
print(element_name, value.as_array()[i], trail);
}
trail.take_last();

View file

@ -21,7 +21,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
gid_t gid = 0;
StringView group_name;
Vector<DeprecatedString> group_members;
Vector<ByteString> group_members;
Core::ArgsParser args_parser;
args_parser.add_option(gid, "Group ID (gid) for the new group", "gid", 'g', "gid");
@ -36,7 +36,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (accounts_or_error.is_error())
return false;
OrderedHashTable<DeprecatedString> unique_group_members;
OrderedHashTable<ByteString> unique_group_members;
auto accounts = accounts_or_error.release_value();
for (auto const& username : comma_separated_users.split_view(',')) {
auto matching_account = accounts.first_matching([&](auto const& account) { return username == account.username(); });

View file

@ -21,7 +21,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/bin/rm", "x"));
TRY(Core::System::unveil(nullptr, nullptr));
DeprecatedString groupname;
ByteString groupname;
Core::ArgsParser args_parser;
args_parser.add_positional_argument(groupname, "Group name", "group");

View file

@ -35,7 +35,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil(nullptr, nullptr));
TRY(Core::System::pledge("stdio rpath"));
Vector<DeprecatedString> usernames;
Vector<ByteString> usernames;
Core::ArgsParser args_parser;
args_parser.set_general_help("Print group memberships for each username or, if no username is specified, for the current process.");

View file

@ -35,13 +35,13 @@ ErrorOr<int> serenity_main(Main::Arguments args)
for (auto filename : filenames) {
DeprecatedString input_filename;
DeprecatedString output_filename;
ByteString input_filename;
ByteString output_filename;
if (filename.ends_with(".gz"sv)) {
input_filename = filename;
output_filename = filename.substring_view(0, filename.length() - 3);
} else {
input_filename = DeprecatedString::formatted("{}.gz", filename);
input_filename = ByteString::formatted("{}.gz", filename);
output_filename = filename;
}

View file

@ -30,7 +30,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
keep_input_files = true;
for (auto const& input_filename : filenames) {
DeprecatedString output_filename;
ByteString output_filename;
if (decompress) {
if (!input_filename.ends_with(".gz"sv)) {
warnln("unknown suffix for: {}, skipping", input_filename);
@ -38,7 +38,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
output_filename = input_filename.substring_view(0, input_filename.length() - ".gz"sv.length());
} else {
output_filename = DeprecatedString::formatted("{}.gz", input_filename);
output_filename = ByteString::formatted("{}.gz", input_filename);
}
auto output_stream = write_to_stdout ? TRY(Core::File::standard_output()) : TRY(Core::File::open(output_filename, Core::File::OpenMode::Write));

View file

@ -14,7 +14,7 @@
#include <string.h>
#include <unistd.h>
int head(DeprecatedString const& filename, bool print_filename, ssize_t line_count, ssize_t byte_count);
int head(ByteString const& filename, bool print_filename, ssize_t line_count, ssize_t byte_count);
ErrorOr<int> serenity_main(Main::Arguments args)
{
@ -24,7 +24,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
int byte_count = -1;
bool never_print_filenames = false;
bool always_print_filenames = false;
Vector<DeprecatedString> files;
Vector<ByteString> files;
Core::ArgsParser args_parser;
args_parser.set_general_help("Print the beginning ('head') of a file.");
@ -60,7 +60,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
return rc;
}
int head(DeprecatedString const& filename, bool print_filename, ssize_t line_count, ssize_t byte_count)
int head(ByteString const& filename, bool print_filename, ssize_t line_count, ssize_t byte_count)
{
bool is_stdin = false;
int fd = -1;

View file

@ -8,7 +8,7 @@
*/
#include <AK/Badge.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Function.h>
#include <AK/JsonObject.h>
#include <AK/JsonParser.h>
@ -90,17 +90,17 @@ public:
ErrorOr<String> dump_layout_tree()
{
return String::from_deprecated_string(client().dump_layout_tree());
return String::from_byte_string(client().dump_layout_tree());
}
ErrorOr<String> dump_paint_tree()
{
return String::from_deprecated_string(client().dump_paint_tree());
return String::from_byte_string(client().dump_paint_tree());
}
ErrorOr<String> dump_text()
{
return String::from_deprecated_string(client().dump_text());
return String::from_byte_string(client().dump_text());
}
void clear_content_filters()
@ -190,7 +190,7 @@ static ErrorOr<TestResult> run_dump_test(HeadlessWebContentView& view, StringVie
loop.quit(0);
}));
view.load(URL::create_with_file_scheme(TRY(FileSystem::real_path(input_path)).to_deprecated_string()));
view.load(URL::create_with_file_scheme(TRY(FileSystem::real_path(input_path)).to_byte_string()));
String result;
@ -266,7 +266,7 @@ static ErrorOr<TestResult> run_ref_test(HeadlessWebContentView& view, StringView
loop.quit(0);
}));
view.load(URL::create_with_file_scheme(TRY(FileSystem::real_path(input_path)).to_deprecated_string()));
view.load(URL::create_with_file_scheme(TRY(FileSystem::real_path(input_path)).to_byte_string()));
RefPtr<Gfx::Bitmap> actual_screenshot, expectation_screenshot;
view.on_load_finish = [&](auto const&) {
@ -332,7 +332,7 @@ struct Test {
Optional<TestResult> result;
};
static Vector<DeprecatedString> s_skipped_tests;
static Vector<ByteString> s_skipped_tests;
static ErrorOr<void> load_test_config(StringView test_root_path)
{
@ -361,7 +361,7 @@ static ErrorOr<void> load_test_config(StringView test_root_path)
static ErrorOr<void> collect_dump_tests(Vector<Test>& tests, StringView path, StringView trail, TestMode mode)
{
Core::DirIterator it(TRY(String::formatted("{}/input/{}", path, trail)).to_deprecated_string(), Core::DirIterator::Flags::SkipDots);
Core::DirIterator it(TRY(String::formatted("{}/input/{}", path, trail)).to_byte_string(), Core::DirIterator::Flags::SkipDots);
while (it.has_next()) {
auto name = it.next_path();
auto input_path = TRY(FileSystem::real_path(TRY(String::formatted("{}/input/{}/{}", path, trail, name))));

View file

@ -17,7 +17,7 @@ ErrorOr<int> serenity_main(Main::Arguments args)
{
TRY(Core::System::pledge("stdio unix"));
DeprecatedString name_or_ip {};
ByteString name_or_ip {};
Core::ArgsParser args_parser;
args_parser.set_general_help("Convert between domain name and IPv4 address.");
args_parser.add_positional_argument(name_or_ip, "Domain name or IPv4 address", "name");

View file

@ -21,7 +21,7 @@ static bool flag_print_uid = false;
static bool flag_print_gid = false;
static bool flag_print_name = false;
static bool flag_print_gid_all = false;
static DeprecatedString user_str;
static ByteString user_str;
ErrorOr<int> serenity_main(Main::Arguments arguments)
{

View file

@ -38,11 +38,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
json.as_array().for_each([](auto& value) {
auto& if_object = value.as_object();
auto name = if_object.get_deprecated_string("name"sv).value_or({});
auto class_name = if_object.get_deprecated_string("class_name"sv).value_or({});
auto mac_address = if_object.get_deprecated_string("mac_address"sv).value_or({});
auto ipv4_address = if_object.get_deprecated_string("ipv4_address"sv).value_or({});
auto netmask = if_object.get_deprecated_string("ipv4_netmask"sv).value_or({});
auto name = if_object.get_byte_string("name"sv).value_or({});
auto class_name = if_object.get_byte_string("class_name"sv).value_or({});
auto mac_address = if_object.get_byte_string("mac_address"sv).value_or({});
auto ipv4_address = if_object.get_byte_string("ipv4_address"sv).value_or({});
auto netmask = if_object.get_byte_string("ipv4_netmask"sv).value_or({});
auto packets_in = if_object.get_u32("packets_in"sv).value_or(0);
auto bytes_in = if_object.get_u32("bytes_in"sv).value_or(0);
auto packets_out = if_object.get_u32("packets_out"sv).value_or(0);
@ -66,7 +66,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 1;
}
DeprecatedString ifname = value_adapter;
ByteString ifname = value_adapter;
if (!value_ipv4.is_empty()) {
auto address = IPv4Address::from_string(value_ipv4);

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Random.h>
#include <AK/StringBuilder.h>
#include <LibCore/ArgsParser.h>
@ -17,7 +17,7 @@
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio rpath unix"));
DeprecatedString path;
ByteString path;
Core::ArgsParser args_parser;
args_parser.add_positional_argument(path, "Path to image", "path");

View file

@ -15,8 +15,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::pledge("stdio rpath wpath cpath"));
StringView path;
DeprecatedString group;
DeprecatedString key;
ByteString group;
ByteString key;
StringView value_to_write;
Core::ArgsParser args_parser;

View file

@ -32,15 +32,15 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto permission_mask = TRY(Core::FilePermissionsMask::parse(mode));
DeprecatedString destination_dir = (sources.size() > 1 ? DeprecatedString { destination } : LexicalPath::dirname(destination));
ByteString destination_dir = (sources.size() > 1 ? ByteString { destination } : LexicalPath::dirname(destination));
if (create_leading_dest_components) {
String destination_dir_absolute = TRY(FileSystem::absolute_path(destination_dir));
MUST(Core::Directory::create(destination_dir_absolute.to_deprecated_string(), Core::Directory::CreateDirectories::Yes));
MUST(Core::Directory::create(destination_dir_absolute.to_byte_string(), Core::Directory::CreateDirectories::Yes));
}
for (auto const& source : sources) {
DeprecatedString final_destination;
ByteString final_destination;
if (sources.size() > 1) {
final_destination = LexicalPath(destination).append(LexicalPath::basename(source)).string();
} else {

View file

@ -120,7 +120,7 @@ static ErrorOr<String> read_next_piece()
auto line_level_delta_for_next_line { 0 };
do {
auto line_result = s_editor->get_line(TRY(prompt_for_level(s_repl_line_level)).to_deprecated_string());
auto line_result = s_editor->get_line(TRY(prompt_for_level(s_repl_line_level)).to_byte_string());
line_level_delta_for_next_line = 0;
@ -276,7 +276,7 @@ static JS::ThrowCompletionOr<JS::Value> load_ini_impl(JS::VM& vm)
{
auto& realm = *vm.current_realm();
auto filename = TRY(vm.argument(0).to_deprecated_string(vm));
auto filename = TRY(vm.argument(0).to_byte_string(vm));
auto file_or_error = Core::File::open(filename, Core::File::OpenMode::Read);
if (file_or_error.is_error())
return vm.throw_completion<JS::Error>(TRY_OR_THROW_OOM(vm, String::formatted("Failed to open '{}': {}", filename, file_or_error.error())));
@ -599,12 +599,12 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto& global_environment = realm.global_environment();
s_editor = Line::Editor::construct();
s_editor->load_history(s_history_path.to_deprecated_string());
s_editor->load_history(s_history_path.to_byte_string());
signal(SIGINT, [](int) {
if (!s_editor->is_editing())
sigint_handler();
s_editor->save_history(s_history_path.to_deprecated_string());
s_editor->save_history(s_history_path.to_byte_string());
});
s_editor->on_display_refresh = [syntax_highlight](Line::Editor& editor) {
@ -667,7 +667,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
}
editor.set_prompt(prompt_for_level(open_indents).release_value_but_fixme_should_propagate_errors().to_deprecated_string());
editor.set_prompt(prompt_for_level(open_indents).release_value_but_fixme_should_propagate_errors().to_byte_string());
};
auto complete = [&realm, &global_environment](Line::Editor const& editor) -> Vector<Line::CompletionSuggestion> {
@ -749,7 +749,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (key.view().starts_with(property_pattern)) {
Line::CompletionSuggestion completion { key, Line::CompletionSuggestion::ForSearch };
if (!results.contains_slow(completion)) { // hide duplicates
results.append(DeprecatedString(key));
results.append(ByteString(key));
results.last().invariant_offset = property_pattern.length();
}
}
@ -799,7 +799,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
};
s_editor->on_tab_complete = move(complete);
TRY(repl(realm));
s_editor->save_history(s_history_path.to_deprecated_string());
s_editor->save_history(s_history_path.to_byte_string());
} else {
OwnPtr<JS::ExecutionContext> root_execution_context;
if (use_test262_global)

View file

@ -110,7 +110,7 @@ void print(JsonValue const& value, int spaces_per_indent, int indent, bool use_c
}
if (value.is_string())
out("\"");
out("{}", value.to_deprecated_string());
out("{}", value.to_byte_string());
if (value.is_string())
out("\"");
if (use_color)

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/ConfigFile.h>
@ -13,9 +13,9 @@
#include <LibMain/Main.h>
#include <stdio.h>
int set_keymap(DeprecatedString const& keymap);
int set_keymap(ByteString const& keymap);
int set_keymap(DeprecatedString const& keymap)
int set_keymap(ByteString const& keymap)
{
auto character_map = Keyboard::CharacterMap::load_from_file(keymap);
if (character_map.is_error()) {
@ -38,8 +38,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/res/keymaps", "r"));
TRY(Core::System::unveil("/etc/Keyboard.ini", "rwc"));
DeprecatedString mapping;
DeprecatedString mappings;
ByteString mapping;
ByteString mappings;
Core::ArgsParser args_parser;
args_parser.add_option(mapping, "The mapping to be used", "set-keymap", 'm', "keymap");
args_parser.add_option(mappings, "Comma separated list of enabled mappings", "set-keymaps", 's', "keymaps");
@ -71,7 +71,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
}
auto keymaps = DeprecatedString::join(',', mappings_vector);
auto keymaps = ByteString::join(',', mappings_vector);
mapper_config->write_entry("Mapping", "Keymaps", keymaps);
TRY(mapper_config->sync());
}

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/LexicalPath.h>
#include <AK/StringBuilder.h>
#include <AK/StringView.h>
@ -22,16 +22,16 @@
#include <stdio.h>
#include <unistd.h>
static Vector<DeprecatedString> found_libraries;
static Vector<ByteString> found_libraries;
static ErrorOr<void> recusively_resolve_all_necessary_libraries(StringView interpreter_path, size_t recursive_iteration_max, size_t recursive_iteration, ELF::DynamicObject& object)
{
if (recursive_iteration > recursive_iteration_max)
return ELOOP;
Vector<DeprecatedString> libraries;
Vector<ByteString> libraries;
object.for_each_needed_library([&libraries](StringView entry) {
libraries.append(DeprecatedString::formatted("{}", entry));
libraries.append(ByteString::formatted("{}", entry));
});
for (auto& library_name : libraries) {
auto possible_library_path = ELF::DynamicLinker::resolve_library(library_name, object);
@ -82,7 +82,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio rpath map_fixed"));
DeprecatedString path {};
ByteString path {};
Optional<size_t> recursive_iteration_max;
bool force_without_valid_interpreter = false;

View file

@ -53,7 +53,7 @@ static void teardown_tty()
out("\e[?1047l\e[u");
}
static Vector<StringView> wrap_line(DeprecatedString const& string, size_t width)
static Vector<StringView> wrap_line(ByteString const& string, size_t width)
{
auto const result = Line::Editor::actual_rendered_string_metrics(string, {}, width);
@ -286,7 +286,7 @@ public:
if (line[size - 1] == '\n')
--size;
m_lines.append(DeprecatedString(line, size));
m_lines.append(ByteString(line, size));
return true;
}
@ -464,7 +464,7 @@ private:
}
// FIXME: Don't save scrollback when emulating more.
Vector<DeprecatedString> m_lines;
Vector<ByteString> m_lines;
size_t m_line { 0 };
size_t m_subline { 0 };
@ -479,22 +479,22 @@ private:
size_t m_width { 0 };
size_t m_height { 0 };
DeprecatedString m_filename;
DeprecatedString m_prompt;
ByteString m_filename;
ByteString m_prompt;
bool m_show_line_numbers { false };
};
/// Return the next key sequence, or nothing if a signal is received while waiting
/// to read the next sequence.
static Optional<DeprecatedString> get_key_sequence()
static Optional<ByteString> get_key_sequence()
{
// We need a buffer to handle ansi sequences.
char buff[8];
ssize_t n = read(STDOUT_FILENO, buff, sizeof(buff));
if (n > 0) {
return DeprecatedString(buff, n);
return ByteString(buff, n);
} else {
return {};
}
@ -523,8 +523,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::pledge("stdio rpath tty sigaction"));
// FIXME: Make these into StringViews once we stop using fopen below.
DeprecatedString filename = "-";
DeprecatedString prompt = "?f%f :.(line %l)?e (END):.";
ByteString filename = "-";
ByteString prompt = "?f%f :.(line %l)?e (END):.";
bool dont_switch_buffer = false;
bool quit_at_eof = false;
bool quit_if_one_screen = false;
@ -545,7 +545,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.parse(arguments);
FILE* file;
if (DeprecatedString("-") == filename) {
if (ByteString("-") == filename) {
file = stdin;
} else if ((file = fopen(filename.characters(), "r")) == nullptr) {
perror("fopen");
@ -604,7 +604,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
pager.init();
StringBuilder modifier_buffer = StringBuilder(10);
for (Optional<DeprecatedString> sequence_value;; sequence_value = get_key_sequence()) {
for (Optional<ByteString> sequence_value;; sequence_value = get_key_sequence()) {
if (g_resized) {
g_resized = false;
pager.resize();
@ -624,28 +624,28 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
} else if (sequence == "j" || sequence == "\e[B" || sequence == "\n") {
if (!emulate_more) {
if (!modifier_buffer.is_empty())
pager.down_n(modifier_buffer.to_deprecated_string().to_uint().value_or(1));
pager.down_n(modifier_buffer.to_byte_string().to_uint().value_or(1));
else
pager.down();
}
} else if (sequence == "k" || sequence == "\e[A") {
if (!emulate_more) {
if (!modifier_buffer.is_empty())
pager.up_n(modifier_buffer.to_deprecated_string().to_uint().value_or(1));
pager.up_n(modifier_buffer.to_byte_string().to_uint().value_or(1));
else
pager.up();
}
} else if (sequence == "g") {
if (!emulate_more) {
if (!modifier_buffer.is_empty())
pager.go_to_line(modifier_buffer.to_deprecated_string().to_uint().value());
pager.go_to_line(modifier_buffer.to_byte_string().to_uint().value());
else
pager.top();
}
} else if (sequence == "G") {
if (!emulate_more) {
if (!modifier_buffer.is_empty())
pager.go_to_line(modifier_buffer.to_deprecated_string().to_uint().value());
pager.go_to_line(modifier_buffer.to_byte_string().to_uint().value());
else
pager.bottom();
}

View file

@ -24,7 +24,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_positional_argument(path, "Link path", "path", Core::ArgsParser::Required::No);
args_parser.parse(arguments);
DeprecatedString path_buffer;
ByteString path_buffer;
if (path.is_empty()) {
path_buffer = LexicalPath::basename(target);
path = path_buffer.view();

View file

@ -5,7 +5,7 @@
*/
#include <AK/Assertions.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/HashMap.h>
#include <AK/NumberFormat.h>
#include <AK/QuickSort.h>
@ -36,8 +36,8 @@
#include <unistd.h>
struct FileMetadata {
DeprecatedString name;
DeprecatedString path;
ByteString name;
ByteString path;
ino_t raw_inode_number;
struct stat stat {
};
@ -60,8 +60,8 @@ enum class IndicatorStyle {
};
AK_ENUM_BITWISE_OPERATORS(IndicatorStyle)
static int do_file_system_object_long(DeprecatedString const& path);
static int do_file_system_object_short(DeprecatedString const& path);
static int do_file_system_object_long(ByteString const& path);
static int do_file_system_object_short(ByteString const& path);
static bool print_names(char const* path, size_t longest_name, Vector<FileMetadata> const& files);
@ -91,8 +91,8 @@ static size_t terminal_rows = 0;
static size_t terminal_columns = 0;
static bool output_is_terminal = false;
static HashMap<uid_t, DeprecatedString> users;
static HashMap<gid_t, DeprecatedString> groups;
static HashMap<uid_t, ByteString> users;
static HashMap<gid_t, ByteString> groups;
static bool is_a_tty = false;
@ -162,7 +162,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
endgrent();
}
auto do_file_system_object = [&](DeprecatedString const& path) {
auto do_file_system_object = [&](ByteString const& path) {
if (flag_long)
return do_file_system_object_long(path);
return do_file_system_object_short(path);
@ -176,7 +176,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
FileMetadata metadata {};
metadata.name = path;
int rc = lstat(DeprecatedString(path).characters(), &metadata.stat);
int rc = lstat(ByteString(path).characters(), &metadata.stat);
if (rc < 0) {
perror("lstat");
continue;
@ -201,7 +201,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
while (di.has_next()) {
DeprecatedString directory = di.next_full_path();
ByteString directory = di.next_full_path();
if (FileSystem::is_directory(directory) && !FileSystem::is_link(directory)) {
++subdirs;
FileMetadata new_file;
@ -248,9 +248,9 @@ static int print_escaped(StringView name)
return printed;
}
static DeprecatedString& hostname()
static ByteString& hostname()
{
static Optional<DeprecatedString> s_hostname;
static Optional<ByteString> s_hostname;
if (!s_hostname.has_value()) {
char buffer[HOST_NAME_MAX];
if (gethostname(buffer, sizeof(buffer)) == 0)
@ -261,13 +261,13 @@ static DeprecatedString& hostname()
return *s_hostname;
}
static size_t print_name(const struct stat& st, DeprecatedString const& name, Optional<StringView> path_for_link_resolution, StringView path_for_hyperlink)
static size_t print_name(const struct stat& st, ByteString const& name, Optional<StringView> path_for_link_resolution, StringView path_for_hyperlink)
{
if (!flag_disable_hyperlinks) {
auto full_path_or_error = FileSystem::real_path(path_for_hyperlink);
if (!full_path_or_error.is_error()) {
auto fullpath = full_path_or_error.release_value();
auto url = URL::create_with_file_scheme(fullpath.to_deprecated_string(), {}, hostname());
auto url = URL::create_with_file_scheme(fullpath.to_byte_string(), {}, hostname());
out("\033]8;;{}\033\\", url.serialize());
}
}
@ -334,13 +334,13 @@ static size_t print_name(const struct stat& st, DeprecatedString const& name, Op
return nprinted;
}
static bool print_filesystem_object(DeprecatedString const& path, DeprecatedString const& name, const struct stat& st, Optional<ino_t> raw_inode_number)
static bool print_filesystem_object(ByteString const& path, ByteString const& name, const struct stat& st, Optional<ino_t> raw_inode_number)
{
if (flag_show_inode) {
printf("%s ", DeprecatedString::formatted("{}", st.st_ino).characters());
printf("%s ", ByteString::formatted("{}", st.st_ino).characters());
} else if (flag_show_raw_inode) {
if (raw_inode_number.has_value())
printf("%s ", DeprecatedString::formatted("{}", raw_inode_number.value()).characters());
printf("%s ", ByteString::formatted("{}", raw_inode_number.value()).characters());
else
printf("n/a ");
}
@ -409,7 +409,7 @@ static bool print_filesystem_object(DeprecatedString const& path, DeprecatedStri
}
}
printf(" %s ", Core::DateTime::from_timestamp(st.st_mtime).to_deprecated_string().characters());
printf(" %s ", Core::DateTime::from_timestamp(st.st_mtime).to_byte_string().characters());
print_name(st, name, path.view(), path);
@ -422,7 +422,7 @@ static bool print_filesystem_metadata_object(FileMetadata const& file)
return print_filesystem_object(file.path, file.name, file.stat, file.raw_inode_number);
}
static int do_file_system_object_long(DeprecatedString const& path)
static int do_file_system_object_long(ByteString const& path)
{
if (flag_list_directories_only) {
struct stat stat {
@ -478,7 +478,7 @@ static int do_file_system_object_long(DeprecatedString const& path)
builder.append(path);
builder.append('/');
builder.append(metadata.name);
metadata.path = builder.to_deprecated_string();
metadata.path = builder.to_byte_string();
int rc = lstat(metadata.path.characters(), &metadata.stat);
if (rc < 0)
perror("lstat");
@ -495,7 +495,7 @@ static int do_file_system_object_long(DeprecatedString const& path)
return 0;
}
static bool print_filesystem_object_short(DeprecatedString const& path, char const* name, Optional<ino_t> raw_inode_number, size_t* nprinted)
static bool print_filesystem_object_short(ByteString const& path, char const* name, Optional<ino_t> raw_inode_number, size_t* nprinted)
{
struct stat st;
int rc = lstat(path.characters(), &st);
@ -505,10 +505,10 @@ static bool print_filesystem_object_short(DeprecatedString const& path, char con
}
if (flag_show_inode) {
printf("%s ", DeprecatedString::formatted("{}", st.st_ino).characters());
printf("%s ", ByteString::formatted("{}", st.st_ino).characters());
} else if (flag_show_raw_inode) {
if (raw_inode_number.has_value())
printf("%s ", DeprecatedString::formatted("{}", raw_inode_number.value()).characters());
printf("%s ", ByteString::formatted("{}", raw_inode_number.value()).characters());
else
printf("n/a ");
}
@ -527,7 +527,7 @@ static bool print_names(char const* path, size_t longest_name, Vector<FileMetada
builder.append({ path, strlen(path) });
builder.append('/');
builder.append(name);
if (!print_filesystem_object_short(builder.to_deprecated_string(), name.characters(), files[i].raw_inode_number, &nprinted))
if (!print_filesystem_object_short(builder.to_byte_string(), name.characters(), files[i].raw_inode_number, &nprinted))
return 2;
int offset = 0;
if (terminal_columns > longest_name)
@ -551,7 +551,7 @@ static bool print_names(char const* path, size_t longest_name, Vector<FileMetada
return printed_on_row;
}
int do_file_system_object_short(DeprecatedString const& path)
int do_file_system_object_short(ByteString const& path)
{
if (flag_list_directories_only) {
if (flag_show_raw_inode)
@ -602,7 +602,7 @@ int do_file_system_object_short(DeprecatedString const& path)
builder.append(path);
builder.append('/');
builder.append(metadata.name);
metadata.path = builder.to_deprecated_string();
metadata.path = builder.to_byte_string();
int rc = lstat(metadata.path.characters(), &metadata.stat);
if (rc < 0)
perror("lstat");

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Hex.h>
#include <AK/StringView.h>
#include <LibCore/ArgsParser.h>
@ -38,19 +38,19 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
while (di.has_next()) {
auto dir = di.next_path();
auto command_set_filename = DeprecatedString::formatted("/sys/devices/storage/{}/command_set", dir);
auto command_set_filename = ByteString::formatted("/sys/devices/storage/{}/command_set", dir);
auto command_set_file = Core::File::open(command_set_filename, Core::File::OpenMode::Read);
if (command_set_file.is_error()) {
dbgln("Error: Could not open {}: {}", command_set_filename, command_set_file.error());
continue;
}
auto last_lba_filename = DeprecatedString::formatted("/sys/devices/storage/{}/last_lba", dir);
auto last_lba_filename = ByteString::formatted("/sys/devices/storage/{}/last_lba", dir);
auto last_lba_file = Core::File::open(last_lba_filename, Core::File::OpenMode::Read);
if (last_lba_file.is_error()) {
dbgln("Error: Could not open {}: {}", last_lba_filename, last_lba_file.error());
continue;
}
auto sector_size_filename = DeprecatedString::formatted("/sys/devices/storage/{}/sector_size", dir);
auto sector_size_filename = ByteString::formatted("/sys/devices/storage/{}/sector_size", dir);
auto sector_size_file = Core::File::open(sector_size_filename, Core::File::OpenMode::Read);
if (sector_size_file.is_error()) {
dbgln("Error: Could not open {}: {}", sector_size_filename, sector_size_file.error());
@ -62,21 +62,21 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
dbgln("Error: Could not read {}: {}", command_set_filename, maybe_command_set.error());
continue;
}
DeprecatedString command_set = StringView(maybe_command_set.value().bytes());
ByteString command_set = StringView(maybe_command_set.value().bytes());
auto maybe_last_lba = last_lba_file.value()->read_until_eof();
if (maybe_last_lba.is_error()) {
dbgln("Error: Could not read {}: {}", last_lba_filename, maybe_last_lba.error());
continue;
}
DeprecatedString last_lba = StringView(maybe_last_lba.value().bytes());
ByteString last_lba = StringView(maybe_last_lba.value().bytes());
auto maybe_sector_size = sector_size_file.value()->read_until_eof();
if (maybe_sector_size.is_error()) {
dbgln("Error: Could not read {}: {}", sector_size_filename, maybe_sector_size.error());
continue;
}
DeprecatedString sector_size = StringView(maybe_sector_size.value().bytes());
ByteString sector_size = StringView(maybe_sector_size.value().bytes());
outln(format_row, dir, command_set, sector_size, last_lba);
}

View file

@ -23,10 +23,10 @@ static void print_cache_info(StringView description, JsonObject const& cache_obj
static void print_cpu_info(JsonObject const& value)
{
outln("CPU {}:", value.get_u32("processor"sv).value());
outln("\tVendor ID: {}", value.get_deprecated_string("vendor_id"sv).value());
outln("\tVendor ID: {}", value.get_byte_string("vendor_id"sv).value());
if (value.has("hypervisor_vendor_id"sv))
outln("\tHypervisor Vendor ID: {}", value.get_deprecated_string("hypervisor_vendor_id"sv).value());
outln("\tBrand: {}", value.get_deprecated_string("brand"sv).value());
outln("\tHypervisor Vendor ID: {}", value.get_byte_string("hypervisor_vendor_id"sv).value());
outln("\tBrand: {}", value.get_byte_string("brand"sv).value());
outln("\tFamily: {}", value.get_u32("family"sv).value());
outln("\tModel: {}", value.get_u32("model"sv).value());
outln("\tStepping: {}", value.get_u32("stepping"sv).value());

View file

@ -28,21 +28,21 @@ ErrorOr<int> serenity_main(Main::Arguments)
out(" "sv);
for (size_t i = 0; i < cpu_count; ++i) {
out("{:>10}", DeprecatedString::formatted("CPU{}", i));
out("{:>10}", ByteString::formatted("CPU{}", i));
}
outln("");
json.as_array().for_each([cpu_count](JsonValue const& value) {
auto& handler = value.as_object();
auto purpose = handler.get_deprecated_string("purpose"sv).value_or({});
auto purpose = handler.get_byte_string("purpose"sv).value_or({});
auto interrupt = handler.get_u8("interrupt_line"sv).value();
auto controller = handler.get_deprecated_string("controller"sv).value_or({});
auto controller = handler.get_byte_string("controller"sv).value_or({});
auto call_counts = handler.get_array("per_cpu_call_counts"sv).value();
out("{:>4}: ", interrupt);
for (size_t i = 0; i < cpu_count; ++i)
out("{:>10}", call_counts[i].to_deprecated_string());
out("{:>10}", call_counts[i].to_byte_string());
outln(" {:10} {:30}", controller, purpose);
});

View file

@ -25,8 +25,8 @@ ErrorOr<int> serenity_main(Main::Arguments)
auto json = TRY(JsonValue::from_string(file_contents));
json.as_array().for_each([](auto& value) {
auto& jail = value.as_object();
auto index = jail.get_deprecated_string("index"sv).value_or({});
auto name = jail.get_deprecated_string("name"sv).value_or({});
auto index = jail.get_byte_string("index"sv).value_or({});
auto name = jail.get_byte_string("name"sv).value_or({});
outln("{:4} {:10}", index, name);
});

View file

@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/ByteString.h>
#include <AK/CharacterTypes.h>
#include <AK/DeprecatedString.h>
#include <AK/GenericLexer.h>
#include <AK/JsonArray.h>
#include <AK/JsonObject.h>
@ -22,10 +22,10 @@
struct OpenFile {
int fd;
int pid;
DeprecatedString type;
DeprecatedString name;
DeprecatedString state;
DeprecatedString full_name;
ByteString type;
ByteString name;
ByteString state;
ByteString full_name;
};
static bool parse_name(StringView name, OpenFile& file)
@ -66,7 +66,7 @@ static bool parse_name(StringView name, OpenFile& file)
static Vector<OpenFile> get_open_files_by_pid(pid_t pid)
{
auto file = Core::File::open(DeprecatedString::formatted("/proc/{}/fds", pid), Core::File::OpenMode::Read);
auto file = Core::File::open(ByteString::formatted("/proc/{}/fds", pid), Core::File::OpenMode::Read);
if (file.is_error()) {
outln("lsof: PID {}: {}", pid, file.error());
return Vector<OpenFile>();
@ -90,7 +90,7 @@ static Vector<OpenFile> get_open_files_by_pid(pid_t pid)
open_file.pid = pid;
open_file.fd = object.as_object().get_integer<int>("fd"sv).value();
DeprecatedString name = object.as_object().get_deprecated_string("absolute_path"sv).value_or({});
ByteString name = object.as_object().get_byte_string("absolute_path"sv).value_or({});
VERIFY(parse_name(name, open_file));
open_file.full_name = name;
@ -136,7 +136,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
{
// try convert UID to int
auto arg = DeprecatedString(arg_uid).to_int();
auto arg = ByteString(arg_uid).to_int();
if (arg.has_value())
arg_uid_int = arg.value();
}

View file

@ -5,7 +5,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Hex.h>
#include <AK/JsonArray.h>
#include <AK/JsonObject.h>
@ -29,11 +29,11 @@ static u32 read_hex_string_from_bytebuffer(ByteBuffer const& buf)
{
// FIXME: Propagate errors.
return AK::StringUtils::convert_to_uint_from_hex(
DeprecatedString(MUST(buf.slice(2, buf.size() - 2)).bytes()))
ByteString(MUST(buf.slice(2, buf.size() - 2)).bytes()))
.release_value();
}
static u32 convert_sysfs_value_to_uint(DeprecatedString const& value)
static u32 convert_sysfs_value_to_uint(ByteString const& value)
{
if (auto result = AK::StringUtils::convert_to_uint_from_hex(value); result.has_value())
return result.release_value();
@ -89,31 +89,31 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
VERIFY(function_parts.size() == 2);
auto function = convert_sysfs_value_to_uint(function_parts[1]);
auto vendor_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/vendor", dir);
auto vendor_id_filename = ByteString::formatted("/sys/bus/pci/{}/vendor", dir);
auto vendor_id_file = Core::File::open(vendor_id_filename, Core::File::OpenMode::Read);
if (vendor_id_file.is_error()) {
dbgln("Error: Could not open {}: {}", vendor_id_filename, vendor_id_file.error());
continue;
}
auto device_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/device_id", dir);
auto device_id_filename = ByteString::formatted("/sys/bus/pci/{}/device_id", dir);
auto device_id_file = Core::File::open(device_id_filename, Core::File::OpenMode::Read);
if (device_id_file.is_error()) {
dbgln("Error: Could not open {}: {}", device_id_filename, device_id_file.error());
continue;
}
auto class_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/class", dir);
auto class_id_filename = ByteString::formatted("/sys/bus/pci/{}/class", dir);
auto class_id_file = Core::File::open(class_id_filename, Core::File::OpenMode::Read);
if (class_id_file.is_error()) {
dbgln("Error: Could not open {}: {}", class_id_filename, class_id_file.error());
continue;
}
auto subclass_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/subclass", dir);
auto subclass_id_filename = ByteString::formatted("/sys/bus/pci/{}/subclass", dir);
auto subclass_id_file = Core::File::open(subclass_id_filename, Core::File::OpenMode::Read);
if (subclass_id_file.is_error()) {
dbgln("Error: Could not open {}: {}", subclass_id_filename, subclass_id_file.error());
continue;
}
auto revision_id_filename = DeprecatedString::formatted("/sys/bus/pci/{}/revision", dir);
auto revision_id_filename = ByteString::formatted("/sys/bus/pci/{}/revision", dir);
auto revision_id_file = Core::File::open(revision_id_filename, Core::File::OpenMode::Read);
if (revision_id_file.is_error()) {
dbgln("Error: Could not open {}: {}", revision_id_filename, revision_id_file.error());
@ -155,9 +155,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
u32 subclass_id = read_hex_string_from_bytebuffer(subclass_id_contents.value());
DeprecatedString vendor_name;
DeprecatedString device_name;
DeprecatedString class_name;
ByteString vendor_name;
ByteString device_name;
ByteString class_name;
if (db) {
vendor_name = db->get_vendor(vendor_id);
@ -166,18 +166,18 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
if (vendor_name.is_empty())
vendor_name = DeprecatedString::formatted("{:04x}", vendor_id);
vendor_name = ByteString::formatted("{:04x}", vendor_id);
if (device_name.is_empty())
device_name = DeprecatedString::formatted("{:04x}", device_id);
device_name = ByteString::formatted("{:04x}", device_id);
if (class_name.is_empty())
class_name = DeprecatedString::formatted("{:02x}{:02x}", class_id, subclass_id);
class_name = ByteString::formatted("{:02x}{:02x}", class_id, subclass_id);
outln(format, domain, bus, device, function, class_name, vendor_name, device_name, revision_id);
if (!flag_verbose)
continue;
for (size_t bar_index = 0; bar_index <= 5; bar_index++) {
auto bar_value_filename = DeprecatedString::formatted("/sys/bus/pci/{}/bar{}", dir, bar_index);
auto bar_value_filename = ByteString::formatted("/sys/bus/pci/{}/bar{}", dir, bar_index);
auto bar_value_file = Core::File::open(bar_value_filename, Core::File::OpenMode::Read);
if (bar_value_file.is_error()) {
dbgln("Error: Could not open {}: {}", bar_value_filename, bar_value_file.error());

View file

@ -63,9 +63,9 @@ static bool is_missing_file_acceptable(String const& filename)
}
struct FileLink {
DeprecatedString file_path; // May be empty, but not null
DeprecatedString anchor; // May be null ("foo.md", "bar.png"), may be empty ("baz.md#")
DeprecatedString label; // May be empty, but not null
ByteString file_path; // May be empty, but not null
ByteString anchor; // May be null ("foo.md", "bar.png"), may be empty ("baz.md#")
ByteString label; // May be empty, but not null
};
class MarkdownLinkage final : Markdown::Visitor {
@ -74,8 +74,8 @@ public:
static MarkdownLinkage analyze(Markdown::Document const&, bool verbose);
bool has_anchor(DeprecatedString const& anchor) const { return m_anchors.contains(anchor); }
HashTable<DeprecatedString> const& anchors() const { return m_anchors; }
bool has_anchor(ByteString const& anchor) const { return m_anchors.contains(anchor); }
HashTable<ByteString> const& anchors() const { return m_anchors; }
bool has_invalid_link() const { return m_has_invalid_link; }
Vector<FileLink> const& file_links() const { return m_file_links; }
@ -94,12 +94,12 @@ private:
virtual RecursionDecision visit(Markdown::Heading const&) override;
virtual RecursionDecision visit(Markdown::Text::LinkNode const&) override;
HashTable<DeprecatedString> m_anchors;
HashTable<ByteString> m_anchors;
Vector<FileLink> m_file_links;
bool m_has_invalid_link { false };
bool m_verbose { false };
DeprecatedString m_serenity_source_directory;
ByteString m_serenity_source_directory;
};
MarkdownLinkage MarkdownLinkage::analyze(Markdown::Document const& document, bool verbose)
@ -116,16 +116,16 @@ public:
StringCollector() = default;
virtual ~StringCollector() = default;
DeprecatedString build() { return m_builder.to_deprecated_string(); }
ByteString build() { return m_builder.to_byte_string(); }
static DeprecatedString from(Markdown::Heading const& heading)
static ByteString from(Markdown::Heading const& heading)
{
StringCollector collector;
heading.walk(collector);
return collector.build();
}
static DeprecatedString from(Markdown::Text::Node const& node)
static ByteString from(Markdown::Text::Node const& node)
{
StringCollector collector;
node.walk(collector);
@ -133,7 +133,7 @@ public:
}
private:
virtual RecursionDecision visit(DeprecatedString const& text) override
virtual RecursionDecision visit(ByteString const& text) override
{
m_builder.append(text);
return RecursionDecision::Recurse;
@ -142,10 +142,10 @@ private:
StringBuilder m_builder;
};
static DeprecatedString slugify(DeprecatedString const& text)
static ByteString slugify(ByteString const& text)
{
// TODO: This feels like it belongs into LibWeb.
DeprecatedString slug = text.to_lowercase();
ByteString slug = text.to_lowercase();
// Reverse-engineered through github, using:
// find AK/ Base/ Documentation/ Kernel/ Meta/ Ports/ Tests/ Userland/ -name '*.md' | xargs grep --color=always -Pin '^##+ .*[^a-z0-9 ?()`_:/!&|.$'"'"',<>"+-]' README.md
slug = slug.replace(" "sv, "-"sv, ReplaceMode::All)
@ -178,7 +178,7 @@ RecursionDecision MarkdownLinkage::visit(Markdown::Heading const& heading)
RecursionDecision MarkdownLinkage::visit(Markdown::Text::LinkNode const& link_node)
{
DeprecatedString const& href = link_node.href;
ByteString const& href = link_node.href;
if (href.is_empty()) {
// Nothing to do here.
return RecursionDecision::Recurse;
@ -204,9 +204,9 @@ RecursionDecision MarkdownLinkage::visit(Markdown::Text::LinkNode const& link_no
}
// Remove leading '/' from the path.
auto file = DeprecatedString::formatted("{}/Base/usr/share/man/man{}.md", m_serenity_source_directory, url.serialize_path().substring(1));
auto file = ByteString::formatted("{}/Base/usr/share/man/man{}.md", m_serenity_source_directory, url.serialize_path().substring(1));
m_file_links.append({ file, DeprecatedString(), StringCollector::from(*link_node.text) });
m_file_links.append({ file, ByteString(), StringCollector::from(*link_node.text) });
return RecursionDecision::Recurse;
}
if (url.scheme() == "file") {
@ -218,8 +218,8 @@ RecursionDecision MarkdownLinkage::visit(Markdown::Text::LinkNode const& link_no
}
// TODO: Check more possible links other than icons.
if (file_path.starts_with("/res/icons/"sv)) {
auto file = DeprecatedString::formatted("{}/Base{}", m_serenity_source_directory, file_path);
m_file_links.append({ file, DeprecatedString(), StringCollector::from(*link_node.text) });
auto file = ByteString::formatted("{}/Base{}", m_serenity_source_directory, file_path);
m_file_links.append({ file, ByteString(), StringCollector::from(*link_node.text) });
} else if (file_path.starts_with("/bin"sv)) {
StringBuilder builder;
link_node.text->render_to_html(builder);
@ -235,12 +235,12 @@ RecursionDecision MarkdownLinkage::visit(Markdown::Text::LinkNode const& link_no
}
}
DeprecatedString label = StringCollector::from(*link_node.text);
ByteString label = StringCollector::from(*link_node.text);
Optional<size_t> last_hash = href.find_last('#');
if (last_hash.has_value()) {
m_file_links.append({ href.substring(0, last_hash.value()), href.substring(last_hash.value() + 1), label });
} else {
m_file_links.append({ href, DeprecatedString(), label });
m_file_links.append({ href, ByteString(), label });
}
return RecursionDecision::Recurse;
@ -339,14 +339,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
continue;
}
auto file_lexical_path = LexicalPath(file_item.key.to_deprecated_string());
auto file_lexical_path = LexicalPath(file_item.key.to_byte_string());
auto file_dir = file_lexical_path.dirname();
for (auto const& file_link : file_item.value.file_links()) {
String pointee_file;
if (file_link.file_path.is_empty()) {
pointee_file = file_item.key;
} else {
pointee_file = TRY(String::from_deprecated_string(LexicalPath::absolute_path(file_dir, file_link.file_path)));
pointee_file = TRY(String::from_byte_string(LexicalPath::absolute_path(file_dir, file_link.file_path)));
}
if (!FileSystem::exists(pointee_file) && !is_missing_file_acceptable(pointee_file)) {
outln("File '{}' points to '{}' (label '{}'), but '{}' does not exist!",
@ -404,7 +404,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
dbgln("Not including {} in the link graph since it's not a man page.", link.file_path);
continue;
}
TRY(pages.try_set(TRY(String::from_deprecated_string(link.file_path)), maybe_target_page.value()));
TRY(pages.try_set(TRY(String::from_byte_string(link.file_path)), maybe_target_page.value()));
}
}
@ -416,7 +416,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Vector<NonnullRefPtr<Manual::PageNode const>> linked_pages;
for (auto const& link : file.value.file_links()) {
auto linked_page = pages.get(TRY(String::from_deprecated_string(link.file_path)));
auto linked_page = pages.get(TRY(String::from_byte_string(link.file_path)));
if (!linked_page.has_value())
continue;

View file

@ -42,8 +42,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
outln("DocTypeVersion is {}", reader.header().doc_type_version);
auto segment_information = TRY_PARSE(reader.segment_information());
outln("Timestamp scale is {}", segment_information.timestamp_scale());
outln("Muxing app is \"{}\"", segment_information.muxing_app().as_string().to_deprecated_string().characters());
outln("Writing app is \"{}\"", segment_information.writing_app().as_string().to_deprecated_string().characters());
outln("Muxing app is \"{}\"", segment_information.muxing_app().as_string().to_byte_string().characters());
outln("Writing app is \"{}\"", segment_information.writing_app().as_string().to_byte_string().characters());
outln("Document has {} tracks", TRY_PARSE(reader.track_count()));
TRY_PARSE(reader.for_each_track([&](Video::Matroska::TrackEntry const& track_entry) -> Video::DecoderErrorOr<IterationDecision> {

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/File.h>
#include <LibCore/System.h>
@ -48,7 +48,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto buffer = TRY(file->read_until_eof());
dbgln("Read size {}", buffer.size());
auto input = DeprecatedString::copy(buffer);
auto input = ByteString::copy(buffer);
auto document = Markdown::Document::parse(input);
if (!document) {

View file

@ -14,7 +14,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio dpath"));
DeprecatedString mode_string;
ByteString mode_string;
mode_t mask_reference_mode = 0777;
mode_t mode = 0666;
Vector<StringView> paths;

View file

@ -15,7 +15,7 @@
#include <sys/stat.h>
#include <unistd.h>
static DeprecatedString generate_random_filename(DeprecatedString const& pattern)
static ByteString generate_random_filename(ByteString const& pattern)
{
StringBuilder new_filename { pattern.length() };
@ -27,10 +27,10 @@ static DeprecatedString generate_random_filename(DeprecatedString const& pattern
new_filename.append(pattern[i]);
}
return new_filename.to_deprecated_string();
return new_filename.to_byte_string();
}
static ErrorOr<Optional<DeprecatedString>> make_temp(DeprecatedString const& pattern, bool directory, bool dry_run)
static ErrorOr<Optional<ByteString>> make_temp(ByteString const& pattern, bool directory, bool dry_run)
{
for (int i = 0; i < 100; ++i) {
auto path = generate_random_filename(pattern);
@ -76,7 +76,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (target_directory.is_empty()) {
if (!file_template.is_empty()) {
auto resolved_path = LexicalPath(TRY(FileSystem::absolute_path(file_template)).to_deprecated_string());
auto resolved_path = LexicalPath(TRY(FileSystem::absolute_path(file_template)).to_byte_string());
final_target_directory = TRY(String::from_utf8(resolved_path.dirname()));
final_file_template = TRY(String::from_utf8(resolved_path.basename()));
} else {
@ -97,7 +97,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 1;
}
auto target_path = LexicalPath::join(final_target_directory->to_deprecated_string(), final_file_template->to_deprecated_string()).string();
auto target_path = LexicalPath::join(final_target_directory->to_byte_string(), final_file_template->to_byte_string()).string();
auto final_path = TRY(make_temp(target_path, create_directory, dry_run));
if (!final_path.has_value()) {

View file

@ -63,13 +63,13 @@ static ErrorOr<int> get_source_fd(StringView source)
return fd_or_error;
}
static bool mount_by_line(DeprecatedString const& line)
static bool mount_by_line(ByteString const& line)
{
// Skip comments and blank lines.
if (line.is_empty() || line.starts_with('#'))
return true;
Vector<DeprecatedString> parts = line.split('\t');
Vector<ByteString> parts = line.split('\t');
if (parts.size() < 3) {
warnln("Invalid fstab entry: {}", line);
return false;
@ -163,9 +163,9 @@ static ErrorOr<void> print_mounts()
json.as_array().for_each([](auto& value) {
auto& fs_object = value.as_object();
auto class_name = fs_object.get_deprecated_string("class_name"sv).value_or({});
auto mount_point = fs_object.get_deprecated_string("mount_point"sv).value_or({});
auto source = fs_object.get_deprecated_string("source"sv).value_or("none");
auto class_name = fs_object.get_byte_string("class_name"sv).value_or({});
auto mount_point = fs_object.get_byte_string("mount_point"sv).value_or({});
auto source = fs_object.get_byte_string("source"sv).value_or("none");
auto readonly = fs_object.get_bool("readonly"sv).value_or(false);
auto mount_flags = fs_object.get_u32("mount_flags"sv).value_or(0);

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/LexicalPath.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/System.h>
@ -23,7 +23,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
bool no_clobber = false;
bool verbose = false;
Vector<DeprecatedString> paths;
Vector<ByteString> paths;
Core::ArgsParser args_parser;
args_parser.add_option(force, "Force", "force", 'f');
@ -61,11 +61,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
umask(my_umask);
for (auto& old_path : paths) {
DeprecatedString combined_new_path;
ByteString combined_new_path;
auto new_path = original_new_path;
if (S_ISDIR(st.st_mode)) {
auto old_basename = LexicalPath::basename(old_path);
combined_new_path = DeprecatedString::formatted("{}/{}", original_new_path, old_basename);
combined_new_path = ByteString::formatted("{}/{}", original_new_path, old_basename);
new_path = combined_new_path.characters();
}

View file

@ -51,7 +51,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
bool should_close = false;
bool udp_mode = false;
bool numeric_mode = false;
DeprecatedString target;
ByteString target;
u16 port = 0;
u16 local_port = 0;
int maximum_tcp_receive_buffer_size_input = -1;

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/HashMap.h>
#include <AK/IPv4Address.h>
#include <AK/JsonArray.h>
@ -59,7 +59,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
uid_t current_uid = getuid();
HashMap<pid_t, DeprecatedString> programs;
HashMap<pid_t, ByteString> programs;
if (flag_program) {
auto processes = TRY(Core::ProcessStatisticsReader::get_all());
@ -75,10 +75,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
};
struct Column {
DeprecatedString title;
ByteString title;
Alignment alignment { Alignment::Left };
int width { 0 };
DeprecatedString buffer;
ByteString buffer;
};
Vector<Column> columns;
@ -118,22 +118,22 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
};
auto get_formatted_address = [&](DeprecatedString const& address, String const& port) {
auto get_formatted_address = [&](ByteString const& address, String const& port) {
if (flag_wide)
return DeprecatedString::formatted("{}:{}", address, port);
return ByteString::formatted("{}:{}", address, port);
if ((address.length() + port.bytes().size()) <= max_formatted_address_length)
return DeprecatedString::formatted("{}:{}", address, port);
return ByteString::formatted("{}:{}", address, port);
return DeprecatedString::formatted("{}:{}", address.substring_view(0, max_formatted_address_length - port.bytes().size()), port);
return ByteString::formatted("{}:{}", address.substring_view(0, max_formatted_address_length - port.bytes().size()), port);
};
auto get_formatted_program = [&](pid_t pid) {
if (pid == -1)
return DeprecatedString("-");
return ByteString("-");
auto program = programs.get(pid);
return DeprecatedString::formatted("{}/{}", pid, program.value());
return ByteString::formatted("{}/{}", pid, program.value());
};
auto get_formatted_user = [&](i32 uid) -> ErrorOr<String> {
@ -185,7 +185,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto bytes_in = if_object.get_u32("bytes_in"sv).value_or({});
auto bytes_out = if_object.get_u32("bytes_out"sv).value_or({});
auto peer_address = if_object.get_deprecated_string("peer_address"sv).value_or({});
auto peer_address = if_object.get_byte_string("peer_address"sv).value_or({});
if (!flag_numeric) {
auto from_string = IPv4Address::from_string(peer_address);
auto addr = from_string.value().to_in_addr_t();
@ -207,7 +207,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
}
auto local_address = if_object.get_deprecated_string("local_address"sv).value_or({});
auto local_address = if_object.get_byte_string("local_address"sv).value_or({});
if (!flag_numeric) {
auto from_string = IPv4Address::from_string(local_address);
auto addr = from_string.value().to_in_addr_t();
@ -229,7 +229,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
}
auto state = if_object.get_deprecated_string("state"sv).value_or({});
auto state = if_object.get_byte_string("state"sv).value_or({});
auto origin_uid = if_object.get_i32("origin_uid"sv).value_or(-1);
auto origin_pid = if_object.get_i32("origin_pid"sv).value_or(-1);
@ -239,9 +239,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (protocol_column != -1)
columns[protocol_column].buffer = "tcp";
if (bytes_in_column != -1)
columns[bytes_in_column].buffer = TRY(String::number(bytes_in)).to_deprecated_string();
columns[bytes_in_column].buffer = TRY(String::number(bytes_in)).to_byte_string();
if (bytes_out_column != -1)
columns[bytes_out_column].buffer = TRY(String::number(bytes_out)).to_deprecated_string();
columns[bytes_out_column].buffer = TRY(String::number(bytes_out)).to_byte_string();
if (local_address_column != -1)
columns[local_address_column].buffer = get_formatted_address(local_address, local_port);
if (peer_address_column != -1)
@ -249,7 +249,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (state_column != -1)
columns[state_column].buffer = state;
if (flag_extend && user_column != -1)
columns[user_column].buffer = TRY(get_formatted_user(origin_uid)).to_deprecated_string();
columns[user_column].buffer = TRY(get_formatted_user(origin_uid)).to_byte_string();
if (flag_program && program_column != -1)
columns[program_column].buffer = get_formatted_program(origin_pid);
@ -272,7 +272,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
for (auto& value : sorted_regions) {
auto& if_object = value.as_object();
auto local_address = if_object.get_deprecated_string("local_address"sv).value_or({});
auto local_address = if_object.get_byte_string("local_address"sv).value_or({});
if (!flag_numeric) {
auto from_string = IPv4Address::from_string(local_address);
auto addr = from_string.value().to_in_addr_t();
@ -294,7 +294,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
}
auto peer_address = if_object.get_deprecated_string("peer_address"sv).value_or({});
auto peer_address = if_object.get_byte_string("peer_address"sv).value_or({});
if (!flag_numeric) {
auto from_string = IPv4Address::from_string(peer_address);
auto addr = from_string.value().to_in_addr_t();
@ -332,7 +332,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (state_column != -1)
columns[state_column].buffer = "-";
if (flag_extend && user_column != -1)
columns[user_column].buffer = TRY(get_formatted_user(origin_uid)).to_deprecated_string();
columns[user_column].buffer = TRY(get_formatted_user(origin_uid)).to_byte_string();
if (flag_program && program_column != -1)
columns[program_column].buffer = get_formatted_program(origin_pid);

View file

@ -35,8 +35,8 @@ ErrorOr<int> serenity_main(Main::Arguments)
auto json_object = json.as_object();
auto config_file = TRY(Core::ConfigFile::open_for_system("Network", Core::ConfigFile::AllowWriting::Yes));
json_object.for_each_member([&](DeprecatedString const& adapter_name, JsonValue const& adapter_data) {
adapter_data.as_object().for_each_member([&](const DeprecatedString& key, const JsonValue& value) {
json_object.for_each_member([&](ByteString const& adapter_name, JsonValue const& adapter_data) {
adapter_data.as_object().for_each_member([&](const ByteString& key, const JsonValue& value) {
switch (value.type()) {
case JsonValue::Type::String:
config_file->write_entry(adapter_name, key, value.as_string());

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Vector.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/File.h>

View file

@ -16,7 +16,7 @@ namespace {
void dup_out_file(int fd_to_redirect)
{
int fd = -1;
DeprecatedString path = "nohup.out";
ByteString path = "nohup.out";
auto options = O_CREAT | O_WRONLY | O_APPEND;
auto mode = S_IRUSR | S_IWUSR;
auto fd_or_error = Core::System::open(path, options, mode);

View file

@ -76,7 +76,7 @@ static timeval timeval_from_ntp_timestamp(NtpTimestamp const& ntp_timestamp)
return t;
}
static DeprecatedString format_ntp_timestamp(NtpTimestamp ntp_timestamp)
static ByteString format_ntp_timestamp(NtpTimestamp ntp_timestamp)
{
char buffer[28]; // YYYY-MM-DDTHH:MM:SS.UUUUUUZ is 27 characters long.
timeval t = timeval_from_ntp_timestamp(ntp_timestamp);
@ -107,7 +107,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
// Leap seconds smearing NTP servers:
// - time.facebook.com , https://engineering.fb.com/production-engineering/ntp-service/ , sine-smears over 18 hours
// - time.google.com , https://developers.google.com/time/smear , linear-smears over 24 hours
DeprecatedString host = "time.google.com"sv;
ByteString host = "time.google.com"sv;
Core::ArgsParser args_parser;
args_parser.add_option(adjust_time, "Gradually adjust system time (requires root)", "adjust", 'a');
args_parser.add_option(set_time, "Immediately set system time (requires root)", "set", 's');

View file

@ -34,7 +34,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
continue;
}
} else {
url = URL::create_with_url_or_path(path_or_error.value().to_deprecated_string());
url = URL::create_with_url_or_path(path_or_error.value().to_byte_string());
}
if (!Desktop::Launcher::open(url)) {

View file

@ -5,7 +5,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Format.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/System.h>
@ -69,7 +69,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (watch) {
watch_command.append({});
clipboard.on_change = [&](DeprecatedString const&) {
clipboard.on_change = [&](ByteString const&) {
// Technically there's a race here...
auto data_and_type = clipboard.fetch_data_and_type();
if (data_and_type.mime_type.is_empty()) {

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>
@ -18,7 +18,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
static bool flag_most_posix = false;
static bool flag_portability = false;
static bool flag_empty_name_and_leading_dash = false;
Vector<DeprecatedString> paths;
Vector<ByteString> paths;
Core::ArgsParser args_parser;
args_parser.add_option(flag_most_posix, "Check for most POSIX systems", nullptr, 'p');

View file

@ -119,7 +119,7 @@ static ErrorOr<String> summary_string(Vector<int> const& pages)
static PDF::PDFErrorOr<void> print_debugging_stats(PDF::Document& document, bool json)
{
HashMap<DeprecatedString, Vector<int>> diags_to_pages;
HashMap<ByteString, Vector<int>> diags_to_pages;
for (u32 page_number = 1; page_number <= document.get_page_count(); ++page_number) {
if (!json) {
out("page number {} / {}", page_number, document.get_page_count());
@ -165,7 +165,7 @@ static PDF::PDFErrorOr<void> print_debugging_stats(PDF::Document& document, bool
}
if (json) {
json_output.set("issues", issues);
outln("{}", json_output.to_deprecated_string());
outln("{}", json_output.to_byte_string());
}
return {};
}

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/ProcessStatisticsReader.h>
#include <LibCore/System.h>

View file

@ -30,7 +30,7 @@ static Optional<size_t> count;
static uint32_t total_ms;
static int min_ms;
static int max_ms;
static DeprecatedString host;
static ByteString host;
static int payload_size = -1;
static bool quiet = false;
static Optional<size_t> ttl;

View file

@ -50,7 +50,7 @@ ErrorOr<NonnullRefPtr<Client>> Client::create(StringView image_path, StringView
auto port = maybe_port.release_value();
auto hostname = TRY(String::join(':', parts));
auto socket = TRY(Core::BufferedTCPSocket::create(TRY(Core::TCPSocket::connect(hostname.to_deprecated_string(), port))));
auto socket = TRY(Core::BufferedTCPSocket::create(TRY(Core::TCPSocket::connect(hostname.to_byte_string(), port))));
// Ask the server for the canvas size.
TRY(socket->write_until_depleted(get_command.bytes()));
@ -113,7 +113,7 @@ ErrorOr<void> Client::send_current_pixel()
auto color = m_image->get_pixel(m_current_point);
if (color.alpha() == 0)
return {};
auto hex = color.to_deprecated_string();
auto hex = color.to_byte_string();
// Pixelflut requires hex colors without leading hash.
auto hex_without_hash = hex.substring(1);

View file

@ -84,14 +84,14 @@ ErrorOr<int> AvailablePort::update_available_ports_list_file()
}
RefPtr<Protocol::Request> request;
auto protocol_client = TRY(Protocol::RequestClient::try_create());
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> request_headers;
HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> request_headers;
Core::ProxyData proxy_data {};
auto output_stream = TRY(Core::File::open("/usr/Ports/AvailablePorts.md"sv, Core::File::OpenMode::ReadWrite, 0644));
Core::EventLoop loop;
URL url("https://raw.githubusercontent.com/SerenityOS/serenity/master/Ports/AvailablePorts.md");
DeprecatedString method = "GET";
ByteString method = "GET";
outln("pkg: Syncing packages database...");
request = protocol_client->start_request(method, url, request_headers, ReadonlyBytes {}, proxy_data);
request->on_finish = [&](bool success, auto) {
@ -161,11 +161,11 @@ ErrorOr<HashMap<String, AvailablePort>> AvailablePort::read_available_ports_list
HashMap<String, AvailablePort> available_ports;
for (size_t port_index = 0; port_index < port_name_column.rows.size(); port_index++) {
auto name = TRY(extract_port_name_from_column(port_name_column, port_index));
auto website = TRY(String::from_deprecated_string(port_website_column.rows[port_index].render_for_terminal()));
auto website = TRY(String::from_byte_string(port_website_column.rows[port_index].render_for_terminal()));
if (website.is_empty())
website = "n/a"_string;
auto version = TRY(String::from_deprecated_string(port_version_column.rows[port_index].render_for_terminal()));
auto version = TRY(String::from_byte_string(port_version_column.rows[port_index].render_for_terminal()));
if (version.is_empty())
version = "n/a"_string;

View file

@ -21,7 +21,7 @@ static ErrorOr<bool> is_dynamically_linked_executable(StringView filename)
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
DeprecatedString promises;
ByteString promises;
Vector<StringView> command;
bool add_promises_for_dynamic_linker;
@ -35,7 +35,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto constexpr loader_promises = "stdio rpath prot_exec"sv;
MUST(Core::System::setenv("_LOADER_PLEDGE_PROMISES"sv, loader_promises, true));
MUST(Core::System::setenv("_LOADER_MAIN_PROGRAM_PLEDGE_PROMISES"sv, promises, true));
promises = DeprecatedString::formatted("{} {}", promises, loader_promises);
promises = ByteString::formatted("{} {}", promises, loader_promises);
}
TRY(Core::System::pledge(StringView(), promises));

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/JsonObject.h>
#include <AK/QuickSort.h>
#include <LibCore/ArgsParser.h>
@ -26,7 +26,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_positional_argument(pid, "PID", "PID", Core::ArgsParser::Required::Yes);
args_parser.parse(arguments);
auto file = TRY(Core::File::open(DeprecatedString::formatted("/proc/{}/vm", pid), Core::File::OpenMode::Read));
auto file = TRY(Core::File::open(ByteString::formatted("/proc/{}/vm", pid), Core::File::OpenMode::Read));
outln("{}:", pid);
@ -49,9 +49,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
for (auto& value : sorted_regions) {
auto& map = value.as_object();
auto address = map.get_addr("address"sv).value_or(0);
auto size = map.get("size"sv).value_or({}).to_deprecated_string();
auto size = map.get("size"sv).value_or({}).to_byte_string();
auto access = DeprecatedString::formatted("{}{}{}{}{}",
auto access = ByteString::formatted("{}{}{}{}{}",
(map.get_bool("readable"sv).value_or(false) ? "r" : "-"),
(map.get_bool("writable"sv).value_or(false) ? "w" : "-"),
(map.get_bool("executable"sv).value_or(false) ? "x" : "-"),
@ -61,13 +61,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
out("{:p} ", address);
out("{:>10} ", size);
if (extended) {
auto resident = map.get("amount_resident"sv).value_or({}).to_deprecated_string();
auto dirty = map.get("amount_dirty"sv).value_or({}).to_deprecated_string();
auto vmobject = map.get_deprecated_string("vmobject"sv).value_or({});
auto resident = map.get("amount_resident"sv).value_or({}).to_byte_string();
auto dirty = map.get("amount_dirty"sv).value_or({}).to_byte_string();
auto vmobject = map.get_byte_string("vmobject"sv).value_or({});
if (vmobject.ends_with("VMObject"sv))
vmobject = vmobject.substring(0, vmobject.length() - 8);
auto purgeable = map.get("purgeable"sv).value_or({}).to_deprecated_string();
auto cow_pages = map.get("cow_pages"sv).value_or({}).to_deprecated_string();
auto purgeable = map.get("purgeable"sv).value_or({}).to_byte_string();
auto cow_pages = map.get("cow_pages"sv).value_or({}).to_byte_string();
out("{:>10} ", resident);
out("{:>10} ", dirty);
out("{:6} ", access);
@ -77,7 +77,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
} else {
out("{:6} ", access);
}
auto name = map.get_deprecated_string("name"sv).value_or({});
auto name = map.get_byte_string("name"sv).value_or({});
out("{:20}", name);
outln();
}

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/StringUtils.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/System.h>
@ -19,7 +19,7 @@
#include <sys/stat.h>
#include <unistd.h>
static bool try_set_offset_and_length_parameters(DeprecatedString const& arg_offset, DeprecatedString const& arg_length, u64& offset, u64& length)
static bool try_set_offset_and_length_parameters(ByteString const& arg_offset, ByteString const& arg_length, u64& offset, u64& length)
{
// TODO: Add support for hex values
auto possible_offset = arg_offset.to_uint<u64>();

View file

@ -5,7 +5,7 @@
*/
#include <AK/Assertions.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/PrintfImplementation.h>
#include <AK/StringBuilder.h>
#include <AK/Types.h>
@ -234,7 +234,7 @@ struct ArgvWithCount {
int& argc;
};
static DeprecatedString handle_escapes(char const* string)
static ByteString handle_escapes(char const* string)
{
StringBuilder builder;
for (auto c = *string; c; c = *++string) {
@ -252,7 +252,7 @@ static DeprecatedString handle_escapes(char const* string)
builder.append('\b');
break;
case 'c':
return builder.to_deprecated_string();
return builder.to_byte_string();
case 'e':
builder.append('\e');
break;
@ -288,7 +288,7 @@ static DeprecatedString handle_escapes(char const* string)
}
}
return builder.to_deprecated_string();
return builder.to_byte_string();
}
ErrorOr<int> serenity_main(Main::Arguments arguments)
@ -300,7 +300,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto argv = arguments.argv;
++argv;
DeprecatedString format = handle_escapes(*(argv++));
ByteString format = handle_escapes(*(argv++));
auto format_string = format.characters();
argc -= 2;

View file

@ -154,9 +154,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
bool verbose_output = false;
StringView data;
StringView proxy_spec;
DeprecatedString method = "GET";
ByteString method = "GET";
StringView method_override;
HashMap<DeprecatedString, DeprecatedString, CaseInsensitiveStringTraits> request_headers;
HashMap<ByteString, ByteString, CaseInsensitiveStringTraits> request_headers;
String credentials;
Core::ArgsParser args_parser;
@ -253,7 +253,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
// that scheme as (...) or a single sequence of characters capable of holding base64-encoded information.
auto const encoded_credentials = TRY(encode_base64(credentials.bytes()));
auto const authorization = TRY(String::formatted("Basic {}", encoded_credentials));
request_headers.set("Authorization", authorization.to_deprecated_string());
request_headers.set("Authorization", authorization.to_byte_string());
} else {
if (is_http_url && has_credentials && has_manual_authorization_header)
warnln("* Skipping encoding provided authorization, manual header present.");
@ -326,7 +326,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
if (!following_url && save_at_provided_name) {
DeprecatedString output_name;
ByteString output_name;
if (auto content_disposition = response_headers.get("Content-Disposition"); content_disposition.has_value()) {
auto& value = content_disposition.value();
ContentDispositionParser parser(value);
@ -343,9 +343,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (output_name.is_empty() || output_name == "/") {
int i = -1;
do {
output_name = url.serialized_host().release_value_but_fixme_should_propagate_errors().to_deprecated_string();
output_name = url.serialized_host().release_value_but_fixme_should_propagate_errors().to_byte_string();
if (i > -1)
output_name = DeprecatedString::formatted("{}.{}", output_name, i);
output_name = ByteString::formatted("{}.{}", output_name, i);
++i;
} while (FileSystem::exists(output_name));
}

View file

@ -38,7 +38,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_option(Core::ArgsParser::Option {
Core::ArgsParser::OptionArgumentMode::Required,
"Enable tracking specific event type", nullptr, 't', "event_type",
[&](DeprecatedString event_type) {
[&](ByteString event_type) {
seen_event_type_arg = true;
if (event_type == "sample")
event_mask |= PERF_EVENT_SAMPLE;

View file

@ -85,7 +85,7 @@ static ErrorOr<String> column_to_string(ColumnId column_id, Core::ProcessStatist
{
switch (column_id) {
case ColumnId::UserId:
return String::from_deprecated_string(process.username);
return String::from_byte_string(process.username);
case ColumnId::ProcessId:
return String::number(process.pid);
case ColumnId::ParentProcessId:
@ -95,11 +95,11 @@ static ErrorOr<String> column_to_string(ColumnId column_id, Core::ProcessStatist
case ColumnId::SessionId:
return String::number(process.sid);
case ColumnId::TTY:
return process.tty == "" ? "n/a"_string : String::from_deprecated_string(process.tty);
return process.tty == "" ? "n/a"_string : String::from_byte_string(process.tty);
case ColumnId::State:
return process.threads.is_empty()
? "Zombie"_string
: String::from_deprecated_string(process.threads.first().state);
: String::from_byte_string(process.threads.first().state);
case ColumnId::StartTime: {
auto now = Core::DateTime::now();
auto today_start = Core::DateTime::now();
@ -110,7 +110,7 @@ static ErrorOr<String> column_to_string(ColumnId column_id, Core::ProcessStatist
return process_creation_time.to_string("%b%d"sv);
}
case ColumnId::Command:
return String::from_deprecated_string(process.name);
return String::from_byte_string(process.name);
default:
VERIFY_NOT_REACHED();
}
@ -230,7 +230,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Vector<Column> columns;
Vector<pid_t> pid_list;
Vector<pid_t> parent_pid_list;
Vector<DeprecatedString> tty_list;
Vector<ByteString> tty_list;
Vector<uid_t> uid_list;
Core::ArgsParser args_parser;
@ -267,14 +267,14 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
warnln("Could not parse '{}' as a PID.", pid_string);
return pid;
}));
args_parser.add_option(make_list_option(tty_list, "Show processes associated with the given terminal. (Comma- or space-separated list.) The short TTY name or the full device path may be used.", "tty", 't', "tty-list", [&](StringView tty_string) -> Optional<DeprecatedString> {
args_parser.add_option(make_list_option(tty_list, "Show processes associated with the given terminal. (Comma- or space-separated list.) The short TTY name or the full device path may be used.", "tty", 't', "tty-list", [&](StringView tty_string) -> Optional<ByteString> {
provided_filtering_option = true;
auto tty_pseudo_name_or_error = parse_tty_pseudo_name(tty_string);
if (tty_pseudo_name_or_error.is_error()) {
warnln("Could not parse '{}' as a TTY", tty_string);
return {};
}
return tty_pseudo_name_or_error.release_value().to_deprecated_string();
return tty_pseudo_name_or_error.release_value().to_byte_string();
}));
args_parser.add_option(make_list_option(uid_list, "Show processes with a matching user ID or login name. (Comma- or space-separated list.)", nullptr, 'u', "user-list", [&](StringView user_string) -> Optional<uid_t> {
provided_filtering_option = true;

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Format.h>
#include <LibCore/System.h>
#include <LibMain/Main.h>

View file

@ -4,8 +4,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/ByteString.h>
#include <AK/CharacterTypes.h>
#include <AK/DeprecatedString.h>
#include <AK/LexicalPath.h>
#include <AK/StringBuilder.h>
#include <AK/StringView.h>
@ -206,7 +206,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{
TRY(Core::System::pledge("stdio rpath map_fixed"));
DeprecatedString path {};
ByteString path {};
static bool display_all = false;
static bool display_elf_header = false;
static bool display_program_headers = false;
@ -432,17 +432,17 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
found_dynamic_section = true;
if (section.entry_count()) {
outln("Dynamic section '{}' at offset {:#08x} contains {} entries.", section.name().to_deprecated_string(), section.offset(), section.entry_count());
outln("Dynamic section '{}' at offset {:#08x} contains {} entries.", section.name().to_byte_string(), section.offset(), section.entry_count());
} else {
outln("Dynamic section '{}' at offset {:#08x} contains zero entries.", section.name().to_deprecated_string(), section.offset());
outln("Dynamic section '{}' at offset {:#08x} contains zero entries.", section.name().to_byte_string(), section.offset());
}
return IterationDecision::Break;
});
Vector<DeprecatedString> libraries;
Vector<ByteString> libraries;
object->for_each_needed_library([&libraries](StringView entry) {
libraries.append(DeprecatedString::formatted("{}", entry));
libraries.append(ByteString::formatted("{}", entry));
});
auto library_index = 0;

View file

@ -5,7 +5,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <LibCore/File.h>
#include <LibMain/Main.h>
@ -13,7 +13,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
{
auto file = TRY(Core::File::open("/sys/kernel/power_state"sv, Core::File::OpenMode::Write));
const DeprecatedString file_contents = "1";
const ByteString file_contents = "1";
TRY(file->write_until_depleted(file_contents.bytes()));
file->close();

View file

@ -31,7 +31,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (path == "-") {
streams.append(stdin);
} else {
FILE* stream = fopen(DeprecatedString(path).characters(), "r");
FILE* stream = fopen(ByteString(path).characters(), "r");
if (!stream) {
warnln("Failed to open {}: {}", path, strerror(errno));
continue;
@ -70,7 +70,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
}
break;
}
outln("{}", DeprecatedString { buffer, Chomp }.reverse());
outln("{}", ByteString { buffer, Chomp }.reverse());
}
}

View file

@ -51,7 +51,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
for (size_t i = path_parts.size() - 1; i > 0; --i) {
auto current_path_parts = path_parts.span().slice(0, i);
LexicalPath current_path { DeprecatedString::join('/', current_path_parts) };
LexicalPath current_path { ByteString::join('/', current_path_parts) };
if (!remove_directory(current_path.string()))
break;
}

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/IPv4Address.h>
#include <AK/JsonArray.h>
#include <AK/JsonObject.h>
@ -51,10 +51,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
};
struct Column {
DeprecatedString title;
ByteString title;
Alignment alignment { Alignment::Left };
int width { 0 };
DeprecatedString buffer;
ByteString buffer;
};
Vector<Column> columns;
@ -101,16 +101,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Vector<JsonValue> sorted_regions = json.as_array().values();
quick_sort(sorted_regions, [](auto& a, auto& b) {
return a.as_object().get_deprecated_string("destination"sv).value_or({}) < b.as_object().get_deprecated_string("destination"sv).value_or({});
return a.as_object().get_byte_string("destination"sv).value_or({}) < b.as_object().get_byte_string("destination"sv).value_or({});
});
for (auto& value : sorted_regions) {
auto& if_object = value.as_object();
auto destination = if_object.get_deprecated_string("destination"sv).value_or({});
auto gateway = if_object.get_deprecated_string("gateway"sv).value_or({});
auto genmask = if_object.get_deprecated_string("genmask"sv).value_or({});
auto interface = if_object.get_deprecated_string("interface"sv).value_or({});
auto destination = if_object.get_byte_string("destination"sv).value_or({});
auto gateway = if_object.get_byte_string("gateway"sv).value_or({});
auto genmask = if_object.get_byte_string("genmask"sv).value_or({});
auto interface = if_object.get_byte_string("interface"sv).value_or({});
auto flags = if_object.get_u32("flags"sv).value_or(0);
StringBuilder flags_builder;

View file

@ -33,11 +33,11 @@ struct FileResult {
pid_t child_pid { 0 };
};
DeprecatedString g_currently_running_test;
ByteString g_currently_running_test;
class TestRunner : public ::Test::TestRunner {
public:
TestRunner(DeprecatedString test_root, Regex<PosixExtended> exclude_regex, NonnullRefPtr<Core::ConfigFile> config, Regex<PosixExtended> skip_regex, bool run_skipped_tests, bool print_progress, bool print_json, bool print_all_output, bool unlink_coredumps, bool print_times = true)
TestRunner(ByteString test_root, Regex<PosixExtended> exclude_regex, NonnullRefPtr<Core::ConfigFile> config, Regex<PosixExtended> skip_regex, bool run_skipped_tests, bool print_progress, bool print_json, bool print_all_output, bool unlink_coredumps, bool print_times = true)
: ::Test::TestRunner(move(test_root), print_times, print_progress, print_json)
, m_exclude_regex(move(exclude_regex))
, m_config(move(config))
@ -55,29 +55,29 @@ public:
virtual ~TestRunner() = default;
protected:
virtual void do_run_single_test(DeprecatedString const& test_path, size_t current_text_index, size_t num_tests) override;
virtual Vector<DeprecatedString> get_test_paths() const override;
virtual Vector<DeprecatedString> const* get_failed_test_names() const override { return &m_failed_test_names; }
virtual void do_run_single_test(ByteString const& test_path, size_t current_text_index, size_t num_tests) override;
virtual Vector<ByteString> get_test_paths() const override;
virtual Vector<ByteString> const* get_failed_test_names() const override { return &m_failed_test_names; }
virtual FileResult run_test_file(DeprecatedString const& test_path);
virtual FileResult run_test_file(ByteString const& test_path);
bool should_skip_test(LexicalPath const& test_path);
Regex<PosixExtended> m_exclude_regex;
NonnullRefPtr<Core::ConfigFile> m_config;
Vector<DeprecatedString> m_skip_directories;
Vector<DeprecatedString> m_skip_files;
Vector<DeprecatedString> m_failed_test_names;
Vector<ByteString> m_skip_directories;
Vector<ByteString> m_skip_files;
Vector<ByteString> m_failed_test_names;
Regex<PosixExtended> m_skip_regex;
bool m_run_skipped_tests { false };
bool m_print_all_output { false };
bool m_unlink_coredumps { false };
};
Vector<DeprecatedString> TestRunner::get_test_paths() const
Vector<ByteString> TestRunner::get_test_paths() const
{
Vector<DeprecatedString> paths;
Test::iterate_directory_recursively(m_test_root, [&](DeprecatedString const& file_path) {
Vector<ByteString> paths;
Test::iterate_directory_recursively(m_test_root, [&](ByteString const& file_path) {
if (access(file_path.characters(), R_OK | X_OK) != 0)
return;
auto result = m_exclude_regex.match(file_path, PosixFlags::Global);
@ -93,11 +93,11 @@ bool TestRunner::should_skip_test(LexicalPath const& test_path)
if (m_run_skipped_tests)
return false;
for (DeprecatedString const& dir : m_skip_directories) {
for (ByteString const& dir : m_skip_directories) {
if (test_path.dirname().contains(dir))
return true;
}
for (DeprecatedString const& file : m_skip_files) {
for (ByteString const& file : m_skip_files) {
if (test_path.basename().contains(file))
return true;
}
@ -108,7 +108,7 @@ bool TestRunner::should_skip_test(LexicalPath const& test_path)
return false;
}
void TestRunner::do_run_single_test(DeprecatedString const& test_path, size_t current_test_index, size_t num_tests)
void TestRunner::do_run_single_test(ByteString const& test_path, size_t current_test_index, size_t num_tests)
{
g_currently_running_test = test_path;
auto test_relative_path = LexicalPath::relative_path(test_path, m_test_root);
@ -146,8 +146,8 @@ void TestRunner::do_run_single_test(DeprecatedString const& test_path, size_t cu
out("{}", test_result.result == Test::Result::Fail ? " FAIL " : "CRASHED");
print_modifiers({ Test::CLEAR });
if (test_result.result == Test::Result::Crashed) {
auto pid_search_string = DeprecatedString::formatted("_{}_", test_result.child_pid);
Optional<DeprecatedString> coredump_path;
auto pid_search_string = ByteString::formatted("_{}_", test_result.child_pid);
Optional<ByteString> coredump_path;
Core::DirIterator iterator("/tmp/coredump"sv);
if (!iterator.has_error()) {
while (iterator.has_next()) {
@ -166,7 +166,7 @@ void TestRunner::do_run_single_test(DeprecatedString const& test_path, size_t cu
auto tid = thread_info.tid; // Note: Yoinking this out of the struct because we can't pass a reference to it (as it's a misaligned field in a packed struct)
dbgln("Thread {}", tid);
for (auto const& entry : thread_backtrace.entries())
dbgln("- {}", entry.to_deprecated_string(true));
dbgln("- {}", entry.to_byte_string(true));
return IterationDecision::Continue;
});
break;
@ -235,7 +235,7 @@ void TestRunner::do_run_single_test(DeprecatedString const& test_path, size_t cu
close(test_result.stdout_err_fd);
}
FileResult TestRunner::run_test_file(DeprecatedString const& test_path)
FileResult TestRunner::run_test_file(ByteString const& test_path)
{
double start_time = get_time_in_ms();
@ -251,8 +251,8 @@ FileResult TestRunner::run_test_file(DeprecatedString const& test_path)
int child_out_err_file = mkstemp(child_out_err_path);
VERIFY(child_out_err_file >= 0);
DeprecatedString dirname = path_for_test.dirname();
DeprecatedString basename = path_for_test.basename();
ByteString dirname = path_for_test.dirname();
ByteString basename = path_for_test.basename();
(void)posix_spawn_file_actions_adddup2(&file_actions, child_out_err_file, STDOUT_FILENO);
(void)posix_spawn_file_actions_adddup2(&file_actions, child_out_err_file, STDERR_FILENO);
@ -327,9 +327,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
bool run_skipped_tests = false;
bool unlink_coredumps = false;
StringView specified_test_root;
DeprecatedString test_glob;
DeprecatedString exclude_pattern;
DeprecatedString config_file;
ByteString test_glob;
ByteString exclude_pattern;
ByteString config_file;
Core::ArgsParser args_parser;
args_parser.add_option(Core::ArgsParser::Option {
@ -358,7 +358,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.add_positional_argument(specified_test_root, "Tests root directory", "path", Core::ArgsParser::Required::No);
args_parser.parse(arguments);
test_glob = DeprecatedString::formatted("*{}*", test_glob);
test_glob = ByteString::formatted("*{}*", test_glob);
if (getenv("DISABLE_DBG_OUTPUT")) {
AK::set_debug_enabled(false);
@ -370,10 +370,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (!run_benchmarks)
TRY(Core::System::setenv("TESTS_ONLY"sv, "1"sv, true));
DeprecatedString test_root;
ByteString test_root;
if (!specified_test_root.is_empty()) {
test_root = DeprecatedString { specified_test_root };
test_root = ByteString { specified_test_root };
} else {
test_root = "/usr/Tests";
}
@ -382,7 +382,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return 1;
}
test_root = TRY(FileSystem::real_path(test_root)).to_deprecated_string();
test_root = TRY(FileSystem::real_path(test_root)).to_byte_string();
auto void_or_error = Core::System::chdir(test_root);
if (void_or_error.is_error()) {

View file

@ -711,7 +711,7 @@ private:
OwnPtr<Core::File> m_output;
OwnPtr<FileSystem::TempFile> m_output_temp_file;
size_t m_line_number { 0 };
DeprecatedString m_current_line;
ByteString m_current_line;
constexpr static size_t MAX_SUPPORTED_LINE_SIZE = 4096;
Array<u8, MAX_SUPPORTED_LINE_SIZE> m_buffer;
};
@ -759,7 +759,7 @@ static void print_unambiguous(StringView pattern_space)
else if (AK::is_ascii_printable(c))
folded_append(c, 1);
else
folded_append(DeprecatedString::formatted("\\{:3o}", (unsigned char)c), 4);
folded_append(ByteString::formatted("\\{:3o}", (unsigned char)c), 4);
}
outln("{}$", unambiguous_output.string_view());
}

View file

@ -92,7 +92,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
{
Core::ArgsParser args_parser;
DeprecatedString output_path;
ByteString output_path;
bool output_to_clipboard = false;
unsigned delay = 0;
bool select_region = false;
@ -109,7 +109,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
args_parser.parse(arguments);
if (output_path.is_empty()) {
output_path = Core::DateTime::now().to_deprecated_string("screenshot-%Y-%m-%d-%H-%M-%S.png"sv);
output_path = Core::DateTime::now().to_byte_string("screenshot-%Y-%m-%d-%H-%M-%S.png"sv);
}
auto app = TRY(GUI::Application::create(arguments));
@ -158,7 +158,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto encoded_bitmap = encoded_bitmap_or_error.release_value();
if (edit_image)
output_path = Core::DateTime::now().to_deprecated_string("/tmp/screenshot-%Y-%m-%d-%H-%M-%S.png"sv);
output_path = Core::DateTime::now().to_byte_string("/tmp/screenshot-%Y-%m-%d-%H-%M-%S.png"sv);
auto file_or_error = Core::File::open(output_path, Core::File::OpenMode::Write);
if (file_or_error.is_error()) {
@ -179,7 +179,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
char hostname[HOST_NAME_MAX];
VERIFY(gethostname(hostname, sizeof(hostname)) == 0);
auto url = URL::create_with_file_scheme(full_path_or_error.value().to_deprecated_string(), {}, hostname);
auto url = URL::create_with_file_scheme(full_path_or_error.value().to_byte_string(), {}, hostname);
out("\033]8;;{}\033\\", url.serialize());
printed_hyperlink = true;
}

View file

@ -6,7 +6,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <LibCore/File.h>
#include <LibMain/Main.h>
#include <fcntl.h>
@ -17,7 +17,7 @@ ErrorOr<int> serenity_main(Main::Arguments)
{
auto file = TRY(Core::File::open("/sys/kernel/power_state"sv, Core::File::OpenMode::Write));
const DeprecatedString file_contents = "2";
const ByteString file_contents = "2";
TRY(file->write_until_depleted(file_contents.bytes()));
file->close();

View file

@ -5,8 +5,8 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/ByteString.h>
#include <AK/CharacterTypes.h>
#include <AK/DeprecatedString.h>
#include <AK/HashMap.h>
#include <AK/QuickSort.h>
#include <AK/Vector.h>
@ -18,7 +18,7 @@
struct Line {
StringView key;
long int numeric_key;
DeprecatedString line;
ByteString line;
bool numeric;
bool operator<(Line const& other) const
@ -58,7 +58,7 @@ struct Options {
bool reverse { false };
bool zero_terminated { false };
StringView separator {};
Vector<DeprecatedString> files;
Vector<ByteString> files;
};
static ErrorOr<void> load_file(Options const& options, StringView filename, StringView line_delimiter, Vector<Line>& lines, HashTable<Line>& seen)
@ -69,7 +69,7 @@ static ErrorOr<void> load_file(Options const& options, StringView filename, Stri
// FIXME: Unlimited line length
auto buffer = TRY(ByteBuffer::create_uninitialized(4096));
while (TRY(file->can_read_line())) {
DeprecatedString line { TRY(file->read_until(buffer, line_delimiter)) };
ByteString line { TRY(file->read_until(buffer, line_delimiter)) };
StringView key = line;
if (options.key_field != 0) {
auto split = (!options.separator.is_empty())

View file

@ -5,7 +5,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/Format.h>
#include <AK/String.h>
#include <AK/StringBuilder.h>
@ -21,7 +21,7 @@
class SQLRepl {
public:
explicit SQLRepl(Core::EventLoop& loop, DeprecatedString const& database_name, NonnullRefPtr<SQL::SQLClient> sql_client)
explicit SQLRepl(Core::EventLoop& loop, ByteString const& database_name, NonnullRefPtr<SQL::SQLClient> sql_client)
: m_sql_client(move(sql_client))
, m_loop(loop)
{
@ -85,7 +85,7 @@ public:
m_sql_client->on_next_result = [](auto result) {
StringBuilder builder;
builder.join(", "sv, result.values);
outln("{}", builder.to_deprecated_string());
outln("{}", builder.to_byte_string());
};
m_sql_client->on_results_exhausted = [this](auto result) {
@ -107,7 +107,7 @@ public:
m_editor->save_history(m_history_path);
}
void connect(DeprecatedString const& database_name)
void connect(ByteString const& database_name)
{
if (!m_database_name.is_empty()) {
m_sql_client->disconnect(m_connection_id);
@ -124,13 +124,13 @@ public:
}
}
void source_file(DeprecatedString file_name)
void source_file(ByteString file_name)
{
m_input_file_chain.append(move(file_name));
m_quit_when_files_read = false;
}
void read_file(DeprecatedString file_name)
void read_file(ByteString file_name)
{
m_input_file_chain.append(move(file_name));
m_quit_when_files_read = true;
@ -143,20 +143,20 @@ public:
}
private:
DeprecatedString m_history_path { DeprecatedString::formatted("{}/.sql-history", Core::StandardPaths::home_directory()) };
ByteString m_history_path { ByteString::formatted("{}/.sql-history", Core::StandardPaths::home_directory()) };
RefPtr<Line::Editor> m_editor { nullptr };
int m_repl_line_level { 0 };
bool m_keep_running { true };
DeprecatedString m_database_name {};
ByteString m_database_name {};
NonnullRefPtr<SQL::SQLClient> m_sql_client;
SQL::ConnectionID m_connection_id { 0 };
Core::EventLoop& m_loop;
OwnPtr<Core::InputBufferedFile> m_input_file { nullptr };
bool m_quit_when_files_read { false };
Vector<DeprecatedString> m_input_file_chain {};
Vector<ByteString> m_input_file_chain {};
Array<u8, 4096> m_buffer {};
Optional<DeprecatedString> get_line()
Optional<ByteString> get_line()
{
if (!m_input_file && !m_input_file_chain.is_empty()) {
auto file_name = m_input_file_chain.take_first();
@ -196,7 +196,7 @@ private:
return line_result.value();
}
DeprecatedString read_next_piece()
ByteString read_next_piece()
{
StringBuilder piece;
@ -250,12 +250,12 @@ private:
m_repl_line_level = last_token_ended_statement ? 0 : (m_repl_line_level > 0 ? m_repl_line_level : 1);
} while ((m_repl_line_level > 0) || piece.is_empty());
return piece.to_deprecated_string();
return piece.to_byte_string();
}
void read_sql()
{
DeprecatedString piece = read_next_piece();
ByteString piece = read_next_piece();
// m_keep_running can be set to false when the file we are reading
// from is exhausted...
@ -288,7 +288,7 @@ private:
}
}
static DeprecatedString prompt_for_level(int level)
static ByteString prompt_for_level(int level)
{
static StringBuilder prompt_builder;
prompt_builder.clear();
@ -297,7 +297,7 @@ private:
for (auto i = 0; i < level; ++i)
prompt_builder.append(" "sv);
return prompt_builder.to_deprecated_string();
return prompt_builder.to_byte_string();
}
bool handle_command(StringView command)
@ -334,11 +334,11 @@ private:
ErrorOr<int> serenity_main(Main::Arguments arguments)
{
DeprecatedString database_name(getlogin());
DeprecatedString file_to_source;
DeprecatedString file_to_read;
ByteString database_name(getlogin());
ByteString file_to_source;
ByteString file_to_read;
bool suppress_sqlrc = false;
auto sqlrc_path = DeprecatedString::formatted("{}/.sqlrc", Core::StandardPaths::home_directory());
auto sqlrc_path = ByteString::formatted("{}/.sqlrc", Core::StandardPaths::home_directory());
#if !defined(AK_OS_SERENITY)
StringView sql_server_path;
#endif

View file

@ -73,7 +73,7 @@ static ErrorOr<int> stat(StringView file, bool should_follow_links)
outln(")");
auto print_time = [](timespec t) {
outln("{}.{:09}", Core::DateTime::from_timestamp(t.tv_sec).to_deprecated_string(), t.tv_nsec);
outln("{}.{:09}", Core::DateTime::from_timestamp(t.tv_sec).to_byte_string(), t.tv_nsec);
};
out("Accessed: ");

View file

@ -34,13 +34,13 @@
#define HANDLE(VALUE) \
case VALUE: \
return #VALUE##sv;
#define VALUES_TO_NAMES(FUNC_NAME) \
static DeprecatedString FUNC_NAME(int value) \
{ \
#define VALUES_TO_NAMES(FUNC_NAME) \
static ByteString FUNC_NAME(int value) \
{ \
switch (value) {
#define END_VALUES_TO_NAMES() \
} \
return DeprecatedString::formatted("{}", value); \
#define END_VALUES_TO_NAMES() \
} \
return ByteString::formatted("{}", value); \
}
VALUES_TO_NAMES(errno_name)
@ -613,7 +613,7 @@ struct Formatter<struct sockaddr> : StandardFormatter {
builder.appendff(
", sin_port={}, sin_addr={}",
address_in->sin_port,
IPv4Address(address_in->sin_addr.s_addr).to_deprecated_string());
IPv4Address(address_in->sin_addr.s_addr).to_byte_string());
} else if (address.sa_family == AF_UNIX) {
auto* address_un = (const struct sockaddr_un*)&address;
builder.appendff(

View file

@ -7,8 +7,8 @@
#define __USE_MISC
#define TTYDEFCHARS
#include <AK/ByteString.h>
#include <AK/CharacterTypes.h>
#include <AK/DeprecatedString.h>
#include <AK/Optional.h>
#include <AK/Result.h>
#include <AK/ScopeGuard.h>
@ -212,7 +212,7 @@ void print_human_readable(termios const& modes, winsize const& ws, bool verbose_
} else {
sb.append(ch);
}
return sb.to_deprecated_string();
return sb.to_byte_string();
};
auto print_control_characters = [&] {
@ -536,7 +536,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::unveil("/dev", "r"));
TRY(Core::System::unveil(nullptr, nullptr));
DeprecatedString device_file;
ByteString device_file;
bool stty_readable = false;
bool all_settings = false;

View file

@ -24,7 +24,7 @@
FlatPtr arg[SC_NARG];
char outbuf[BUFSIZ];
using Arguments = Vector<DeprecatedString>;
using Arguments = Vector<ByteString>;
using ArgIter = Arguments::Iterator;
static FlatPtr parse_from(ArgIter&);
@ -128,7 +128,7 @@ static FlatPtr as_buf(Vector<FlatPtr> params_vec)
builder.appendff(" {:p}", params_vec[i]);
}
builder.appendff(" ] at {:p}", (FlatPtr)buf);
dbgln("{}", builder.to_deprecated_string());
dbgln("{}", builder.to_byte_string());
}
// Leak the buffer here. We need to keep it until the special syscall happens,

View file

@ -12,9 +12,9 @@
static bool s_set_variable = false;
static Optional<DeprecatedString> get_variable(StringView name)
static Optional<ByteString> get_variable(StringView name)
{
auto path = DeprecatedString::formatted("/sys/kernel/conf/{}", name);
auto path = ByteString::formatted("/sys/kernel/conf/{}", name);
auto file = Core::File::open(path, Core::File::OpenMode::Read);
if (file.is_error()) {
warnln("Failed to open {}: {}", path, file.error());
@ -25,7 +25,7 @@ static Optional<DeprecatedString> get_variable(StringView name)
warnln("Failed to read {}: {}", path, buffer.error());
return {};
}
return DeprecatedString { (char const*)buffer.value().data(), buffer.value().size(), Chomp };
return ByteString { (char const*)buffer.value().data(), buffer.value().size(), Chomp };
}
static bool read_variable(StringView name)
@ -42,7 +42,7 @@ static bool write_variable(StringView name, StringView value)
auto old_value = get_variable(name);
if (!old_value.has_value())
return false;
auto path = DeprecatedString::formatted("/sys/kernel/conf/{}", name);
auto path = ByteString::formatted("/sys/kernel/conf/{}", name);
auto file = Core::File::open(path, Core::File::OpenMode::Write);
if (file.is_error()) {
warnln("Failed to open {}: {}", path, file.error());

View file

@ -32,7 +32,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
if (path == "-"sv) {
stream = stdin;
} else {
stream = fopen(DeprecatedString(path).characters(), "r");
stream = fopen(ByteString(path).characters(), "r");
if (!stream) {
warnln("Failed to open {}: {}", path, strerror(errno));
continue;
@ -56,7 +56,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
TRY(Core::System::pledge("stdio"));
for (auto* stream : streams) {
Vector<DeprecatedString> lines;
Vector<ByteString> lines;
for (;;) {
size_t n = 0;
errno = 0;

View file

@ -86,7 +86,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
line.append(ch);
if (ch == '\n' || i == bytes.size() - 1) {
if (wanted_line_count > line_count || line_index >= line_count - wanted_line_count)
out("{}", line.to_deprecated_string());
out("{}", line.to_byte_string());
line_index++;
line.clear();
}

View file

@ -5,7 +5,7 @@
*/
#include <AK/Assertions.h>
#include <AK/DeprecatedString.h>
#include <AK/ByteString.h>
#include <AK/HashMap.h>
#include <AK/LexicalPath.h>
#include <AK/Span.h>
@ -40,7 +40,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
StringView archive_file;
bool dereference;
StringView directory;
Vector<DeprecatedString> paths;
Vector<ByteString> paths;
Core::ArgsParser args_parser;
args_parser.add_option(create, "Create archive", "create", 'c');
@ -88,16 +88,16 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto tar_stream = TRY(Archive::TarInputStream::construct(move(input_stream)));
HashMap<DeprecatedString, DeprecatedString> global_overrides;
HashMap<DeprecatedString, DeprecatedString> local_overrides;
HashMap<ByteString, ByteString> global_overrides;
HashMap<ByteString, ByteString> local_overrides;
auto get_override = [&](StringView key) -> Optional<DeprecatedString> {
Optional<DeprecatedString> maybe_local = local_overrides.get(key);
auto get_override = [&](StringView key) -> Optional<ByteString> {
Optional<ByteString> maybe_local = local_overrides.get(key);
if (maybe_local.has_value())
return maybe_local;
Optional<DeprecatedString> maybe_global = global_overrides.get(key);
Optional<ByteString> maybe_global = global_overrides.get(key);
if (maybe_global.has_value())
return maybe_global;
@ -149,7 +149,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
long_name.append(reinterpret_cast<char*>(slice.data()), slice.size());
}
local_overrides.set("path", long_name.to_deprecated_string());
local_overrides.set("path", long_name.to_byte_string());
TRY(tar_stream->advance());
continue;
}
@ -161,13 +161,13 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
LexicalPath path = LexicalPath(header.filename());
if (!header.prefix().is_empty())
path = path.prepend(header.prefix());
DeprecatedString filename = get_override("path"sv).value_or(path.string());
ByteString filename = get_override("path"sv).value_or(path.string());
if (list || verbose)
outln("{}", filename);
if (extract) {
DeprecatedString absolute_path = TRY(FileSystem::absolute_path(filename)).to_deprecated_string();
ByteString absolute_path = TRY(FileSystem::absolute_path(filename)).to_byte_string();
auto parent_path = LexicalPath(absolute_path).parent();
auto header_mode = TRY(header.mode());
@ -242,7 +242,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
Archive::TarOutputStream tar_stream(move(output_stream));
auto add_file = [&](DeprecatedString path) -> ErrorOr<void> {
auto add_file = [&](ByteString path) -> ErrorOr<void> {
auto file_or_error = Core::File::open(path, Core::File::OpenMode::Read);
if (file_or_error.is_error()) {
warnln("Failed to open {}: {}", path, file_or_error.error());
@ -251,7 +251,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
auto file = file_or_error.release_value();
auto statbuf = TRY(Core::System::lstat(path));
auto canonicalized_path = TRY(String::from_deprecated_string(LexicalPath::canonicalized_path(path)));
auto canonicalized_path = TRY(String::from_byte_string(LexicalPath::canonicalized_path(path)));
// FIXME: We should stream instead of reading the entire file in one go, but TarOutputStream does not have any interface to do so.
auto file_content = TRY(file->read_until_eof());
TRY(tar_stream.add_file(canonicalized_path, statbuf.st_mode, file_content));
@ -261,10 +261,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return {};
};
auto add_link = [&](DeprecatedString path) -> ErrorOr<void> {
auto add_link = [&](ByteString path) -> ErrorOr<void> {
auto statbuf = TRY(Core::System::lstat(path));
auto canonicalized_path = TRY(String::from_deprecated_string(LexicalPath::canonicalized_path(path)));
auto canonicalized_path = TRY(String::from_byte_string(LexicalPath::canonicalized_path(path)));
TRY(tar_stream.add_link(canonicalized_path, statbuf.st_mode, TRY(Core::System::readlink(path))));
if (verbose)
outln("{}", canonicalized_path);
@ -272,10 +272,10 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
return {};
};
auto add_directory = [&](DeprecatedString path, auto handle_directory) -> ErrorOr<void> {
auto add_directory = [&](ByteString path, auto handle_directory) -> ErrorOr<void> {
auto statbuf = TRY(Core::System::lstat(path));
auto canonicalized_path = TRY(String::from_deprecated_string(LexicalPath::canonicalized_path(path)));
auto canonicalized_path = TRY(String::from_byte_string(LexicalPath::canonicalized_path(path)));
TRY(tar_stream.add_directory(canonicalized_path, statbuf.st_mode));
if (verbose)
outln("{}", canonicalized_path);

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