mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 08:34:57 +00:00
LibFileSystem+Userland: Return ByteString from real_path()
This commit is contained in:
parent
cdf17efb9a
commit
56c5ffe398
25 changed files with 44 additions and 40 deletions
|
@ -413,11 +413,11 @@ bool DirectoryView::open(ByteString const& path)
|
||||||
warnln("Failed to open '{}': {}", real_path, result.error());
|
warnln("Failed to open '{}': {}", real_path, result.error());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model().root_path() == real_path.to_byte_string()) {
|
if (model().root_path() == real_path) {
|
||||||
refresh();
|
refresh();
|
||||||
} else {
|
} else {
|
||||||
set_active_widget(¤t_view());
|
set_active_widget(¤t_view());
|
||||||
model().set_root_path(real_path.to_byte_string());
|
model().set_root_path(real_path);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,7 +109,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
LexicalPath path(initial_location);
|
LexicalPath path(initial_location);
|
||||||
if (!initial_location.is_empty()) {
|
if (!initial_location.is_empty()) {
|
||||||
if (auto error_or_path = FileSystem::real_path(initial_location); !ignore_path_resolution && !error_or_path.is_error())
|
if (auto error_or_path = FileSystem::real_path(initial_location); !ignore_path_resolution && !error_or_path.is_error())
|
||||||
initial_location = error_or_path.release_value().to_byte_string();
|
initial_location = error_or_path.release_value();
|
||||||
|
|
||||||
if (!FileSystem::is_directory(initial_location)) {
|
if (!FileSystem::is_directory(initial_location)) {
|
||||||
// We want to extract zips to a temporary directory when FileManager is launched with a .zip file as its first argument
|
// We want to extract zips to a temporary directory when FileManager is launched with a .zip file as its first argument
|
||||||
|
|
|
@ -147,7 +147,7 @@ bool RunWindow::run_via_launch(ByteString const& run_input)
|
||||||
warnln("Failed to launch '{}': {}", file_path, real_path_or_error.error());
|
warnln("Failed to launch '{}': {}", file_path, real_path_or_error.error());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
url = URL::create_with_url_or_path(real_path_or_error.release_value().to_byte_string());
|
url = URL::create_with_url_or_path(real_path_or_error.release_value());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Desktop::Launcher::open(url)) {
|
if (!Desktop::Launcher::open(url)) {
|
||||||
|
|
|
@ -228,7 +228,7 @@ static ErrorOr<NonnullRefPtr<HackStudioWidget>> create_hack_studio_widget(bool m
|
||||||
else if (auto last_path = last_opened_project_path(); last_path.has_value())
|
else if (auto last_path = last_opened_project_path(); last_path.has_value())
|
||||||
project_path = last_path.release_value();
|
project_path = last_path.release_value();
|
||||||
else
|
else
|
||||||
project_path = TRY(FileSystem::real_path("."sv)).to_byte_string();
|
project_path = TRY(FileSystem::real_path("."sv));
|
||||||
|
|
||||||
return HackStudioWidget::create(project_path);
|
return HackStudioWidget::create(project_path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,7 @@ ErrorOr<ByteString> current_working_directory()
|
||||||
ErrorOr<ByteString> absolute_path(StringView path)
|
ErrorOr<ByteString> absolute_path(StringView path)
|
||||||
{
|
{
|
||||||
if (exists(path))
|
if (exists(path))
|
||||||
return TRY(real_path(path)).to_byte_string();
|
return real_path(path);
|
||||||
|
|
||||||
if (path.starts_with("/"sv))
|
if (path.starts_with("/"sv))
|
||||||
return LexicalPath::canonicalized_path(path);
|
return LexicalPath::canonicalized_path(path);
|
||||||
|
@ -40,7 +40,7 @@ ErrorOr<ByteString> absolute_path(StringView path)
|
||||||
return LexicalPath::absolute_path(working_directory, path);
|
return LexicalPath::absolute_path(working_directory, path);
|
||||||
}
|
}
|
||||||
|
|
||||||
ErrorOr<String> real_path(StringView path)
|
ErrorOr<ByteString> real_path(StringView path)
|
||||||
{
|
{
|
||||||
if (path.is_null())
|
if (path.is_null())
|
||||||
return Error::from_errno(ENOENT);
|
return Error::from_errno(ENOENT);
|
||||||
|
@ -52,7 +52,7 @@ ErrorOr<String> real_path(StringView path)
|
||||||
if (!real_path)
|
if (!real_path)
|
||||||
return Error::from_syscall("realpath"sv, -errno);
|
return Error::from_syscall("realpath"sv, -errno);
|
||||||
|
|
||||||
return TRY(String::from_utf8({ real_path, strlen(real_path) }));
|
return ByteString { real_path, strlen(real_path) };
|
||||||
}
|
}
|
||||||
|
|
||||||
bool exists(StringView path)
|
bool exists(StringView path)
|
||||||
|
@ -244,12 +244,12 @@ ErrorOr<void> copy_directory(StringView destination_path, StringView source_path
|
||||||
TRY(Core::System::mkdir(destination_path, 0755));
|
TRY(Core::System::mkdir(destination_path, 0755));
|
||||||
|
|
||||||
auto source_rp = TRY(real_path(source_path));
|
auto source_rp = TRY(real_path(source_path));
|
||||||
source_rp = TRY(String::formatted("{}/", source_rp));
|
source_rp = ByteString::formatted("{}/", source_rp);
|
||||||
|
|
||||||
auto destination_rp = TRY(real_path(destination_path));
|
auto destination_rp = TRY(real_path(destination_path));
|
||||||
destination_rp = TRY(String::formatted("{}/", destination_rp));
|
destination_rp = ByteString::formatted("{}/", destination_rp);
|
||||||
|
|
||||||
if (!destination_rp.is_empty() && destination_rp.starts_with_bytes(source_rp))
|
if (!destination_rp.is_empty() && destination_rp.starts_with(source_rp))
|
||||||
return Error::from_errno(EINVAL);
|
return Error::from_errno(EINVAL);
|
||||||
|
|
||||||
Core::DirIterator di(source_path, Core::DirIterator::SkipParentAndBaseDir);
|
Core::DirIterator di(source_path, Core::DirIterator::SkipParentAndBaseDir);
|
||||||
|
|
|
@ -20,7 +20,7 @@ namespace FileSystem {
|
||||||
|
|
||||||
ErrorOr<ByteString> current_working_directory();
|
ErrorOr<ByteString> current_working_directory();
|
||||||
ErrorOr<ByteString> absolute_path(StringView path);
|
ErrorOr<ByteString> absolute_path(StringView path);
|
||||||
ErrorOr<String> real_path(StringView path);
|
ErrorOr<ByteString> real_path(StringView path);
|
||||||
|
|
||||||
bool exists(StringView path);
|
bool exists(StringView path);
|
||||||
bool exists(int fd);
|
bool exists(int fd);
|
||||||
|
|
|
@ -259,9 +259,9 @@ Icon FileIconProvider::icon_for_path(StringView path, mode_t mode)
|
||||||
auto raw_symlink_target_or_error = FileSystem::read_link(path);
|
auto raw_symlink_target_or_error = FileSystem::read_link(path);
|
||||||
if (raw_symlink_target_or_error.is_error())
|
if (raw_symlink_target_or_error.is_error())
|
||||||
return s_symlink_icon;
|
return s_symlink_icon;
|
||||||
auto raw_symlink_target = raw_symlink_target_or_error.release_value();
|
auto raw_symlink_target = raw_symlink_target_or_error.release_value().to_byte_string();
|
||||||
|
|
||||||
String target_path;
|
ByteString target_path;
|
||||||
if (raw_symlink_target.starts_with('/')) {
|
if (raw_symlink_target.starts_with('/')) {
|
||||||
target_path = raw_symlink_target;
|
target_path = raw_symlink_target;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -144,7 +144,7 @@ Optional<Interface&> Parser::resolve_import(auto path)
|
||||||
auto real_path_error_or = FileSystem::real_path(include_path);
|
auto real_path_error_or = FileSystem::real_path(include_path);
|
||||||
if (real_path_error_or.is_error())
|
if (real_path_error_or.is_error())
|
||||||
report_parsing_error(ByteString::formatted("Failed to resolve path {}: {}", include_path, real_path_error_or.error()), filename, input, lexer.tell());
|
report_parsing_error(ByteString::formatted("Failed to resolve path {}: {}", include_path, real_path_error_or.error()), filename, input, lexer.tell());
|
||||||
auto real_path = real_path_error_or.release_value().to_byte_string();
|
auto real_path = real_path_error_or.release_value();
|
||||||
|
|
||||||
if (top_level_resolved_imports().contains(real_path))
|
if (top_level_resolved_imports().contains(real_path))
|
||||||
return *top_level_resolved_imports().find(real_path)->value;
|
return *top_level_resolved_imports().find(real_path)->value;
|
||||||
|
@ -966,7 +966,7 @@ Interface& Parser::parse()
|
||||||
report_parsing_error(ByteString::formatted("Failed to resolve path '{}': {}", filename, this_module_or_error.error()), filename, input, 0);
|
report_parsing_error(ByteString::formatted("Failed to resolve path '{}': {}", filename, this_module_or_error.error()), filename, input, 0);
|
||||||
VERIFY_NOT_REACHED();
|
VERIFY_NOT_REACHED();
|
||||||
}
|
}
|
||||||
auto this_module = this_module_or_error.release_value().to_byte_string();
|
auto this_module = this_module_or_error.release_value();
|
||||||
|
|
||||||
auto interface_ptr = make<Interface>();
|
auto interface_ptr = make<Interface>();
|
||||||
auto& interface = *interface_ptr;
|
auto& interface = *interface_ptr;
|
||||||
|
|
|
@ -174,14 +174,14 @@ int main(int argc, char** argv)
|
||||||
warnln("Failed to resolve test root: {}", test_root_or_error.error());
|
warnln("Failed to resolve test root: {}", test_root_or_error.error());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
test_root = test_root_or_error.release_value().to_byte_string();
|
test_root = test_root_or_error.release_value();
|
||||||
|
|
||||||
auto common_path_or_error = FileSystem::real_path(common_path);
|
auto common_path_or_error = FileSystem::real_path(common_path);
|
||||||
if (common_path_or_error.is_error()) {
|
if (common_path_or_error.is_error()) {
|
||||||
warnln("Failed to resolve common path: {}", common_path_or_error.error());
|
warnln("Failed to resolve common path: {}", common_path_or_error.error());
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
common_path = common_path_or_error.release_value().to_byte_string();
|
common_path = common_path_or_error.release_value();
|
||||||
|
|
||||||
if (chdir(test_root.characters()) < 0) {
|
if (chdir(test_root.characters()) < 0) {
|
||||||
auto saved_errno = errno;
|
auto saved_errno = errno;
|
||||||
|
|
|
@ -88,7 +88,7 @@ Optional<URL> sanitize_url(StringView url, Optional<StringView> search_engine, A
|
||||||
if (path.is_error())
|
if (path.is_error())
|
||||||
return {};
|
return {};
|
||||||
|
|
||||||
return URL::create_with_file_scheme(path.value().to_byte_string());
|
return URL::create_with_file_scheme(path.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
auto format_search_engine = [&]() -> Optional<URL> {
|
auto format_search_engine = [&]() -> Optional<URL> {
|
||||||
|
|
|
@ -56,7 +56,7 @@ void ConnectionFromClient::request_file_handler(i32 request_id, i32 window_serve
|
||||||
|
|
||||||
if (prompt == ShouldPrompt::Yes) {
|
if (prompt == ShouldPrompt::Yes) {
|
||||||
VERIFY(window_server_client_id != -1 && parent_window_id != -1);
|
VERIFY(window_server_client_id != -1 && parent_window_id != -1);
|
||||||
auto exe_name = LexicalPath::basename(exe_path.to_byte_string());
|
auto exe_name = LexicalPath::basename(exe_path);
|
||||||
auto text = String::formatted("Allow {} ({}) to {} \"{}\"?", exe_name, pid, access_string, path).release_value_but_fixme_should_propagate_errors();
|
auto text = String::formatted("Allow {} ({}) to {} \"{}\"?", exe_name, pid, access_string, path).release_value_but_fixme_should_propagate_errors();
|
||||||
auto result = GUI::MessageBox::try_show({}, window_server_client_id, parent_window_id, text, "File Permissions Requested"sv).release_value_but_fixme_should_propagate_errors();
|
auto result = GUI::MessageBox::try_show({}, window_server_client_id, parent_window_id, text, "File Permissions Requested"sv).release_value_but_fixme_should_propagate_errors();
|
||||||
approved = result == GUI::MessageBox::ExecResult::Yes;
|
approved = result == GUI::MessageBox::ExecResult::Yes;
|
||||||
|
|
|
@ -318,7 +318,7 @@ void Launcher::for_each_handler_for_path(ByteString const& path, Function<bool(H
|
||||||
}
|
}
|
||||||
auto real_path = real_path_or_error.release_value();
|
auto real_path = real_path_or_error.release_value();
|
||||||
|
|
||||||
return for_each_handler_for_path(real_path.to_byte_string(), [&](auto const& handler) -> bool {
|
return for_each_handler_for_path(real_path, [&](auto const& handler) -> bool {
|
||||||
return f(handler);
|
return f(handler);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -68,7 +68,8 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
if (!username.is_empty() && !password.is_empty())
|
if (!username.is_empty() && !password.is_empty())
|
||||||
credentials = HTTP::HttpRequest::BasicAuthenticationCredentials { username, password };
|
credentials = HTTP::HttpRequest::BasicAuthenticationCredentials { username, password };
|
||||||
|
|
||||||
WebServer::Configuration configuration(real_document_root_path, credentials);
|
// FIXME: This should accept a ByteString for the path instead.
|
||||||
|
WebServer::Configuration configuration(TRY(String::from_byte_string(real_document_root_path)), credentials);
|
||||||
|
|
||||||
Core::EventLoop loop;
|
Core::EventLoop loop;
|
||||||
|
|
||||||
|
|
|
@ -454,7 +454,7 @@ ErrorOr<int> Shell::builtin_cd(Main::Arguments arguments)
|
||||||
warnln("Invalid path '{}'", new_path);
|
warnln("Invalid path '{}'", new_path);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
auto real_path = real_path_or_error.release_value().to_byte_string();
|
auto real_path = real_path_or_error.release_value();
|
||||||
|
|
||||||
if (cd_history.is_empty() || cd_history.last() != real_path)
|
if (cd_history.is_empty() || cd_history.last() != real_path)
|
||||||
cd_history.enqueue(real_path);
|
cd_history.enqueue(real_path);
|
||||||
|
|
|
@ -394,7 +394,7 @@ ByteString Shell::resolve_path(ByteString path) const
|
||||||
if (!path.starts_with('/'))
|
if (!path.starts_with('/'))
|
||||||
path = ByteString::formatted("{}/{}", cwd, path);
|
path = ByteString::formatted("{}/{}", cwd, path);
|
||||||
|
|
||||||
return FileSystem::real_path(path).release_value_but_fixme_should_propagate_errors().to_byte_string();
|
return FileSystem::real_path(path).release_value_but_fixme_should_propagate_errors();
|
||||||
}
|
}
|
||||||
|
|
||||||
Shell::LocalFrame* Shell::find_frame_containing_local_variable(StringView name)
|
Shell::LocalFrame* Shell::find_frame_containing_local_variable(StringView name)
|
||||||
|
|
|
@ -579,7 +579,7 @@ private:
|
||||||
auto full_path_or_error = FileSystem::real_path(file_data.full_path());
|
auto full_path_or_error = FileSystem::real_path(file_data.full_path());
|
||||||
if (!full_path_or_error.is_error()) {
|
if (!full_path_or_error.is_error()) {
|
||||||
auto fullpath = full_path_or_error.release_value();
|
auto fullpath = full_path_or_error.release_value();
|
||||||
auto url = URL::create_with_file_scheme(fullpath.to_byte_string());
|
auto url = URL::create_with_file_scheme(fullpath);
|
||||||
out("\033]8;;{}\033\\{}{}\033]8;;\033\\", url.serialize(), file_data.full_path(), m_terminator);
|
out("\033]8;;{}\033\\{}{}\033]8;;\033\\", url.serialize(), file_data.full_path(), m_terminator);
|
||||||
printed = true;
|
printed = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -88,7 +88,7 @@ static void append_formatted_path(StringBuilder& builder, StringView path, Optio
|
||||||
auto full_path_or_error = FileSystem::real_path(path);
|
auto full_path_or_error = FileSystem::real_path(path);
|
||||||
if (!full_path_or_error.is_error()) {
|
if (!full_path_or_error.is_error()) {
|
||||||
auto fullpath = full_path_or_error.release_value();
|
auto fullpath = full_path_or_error.release_value();
|
||||||
auto url = URL::create_with_file_scheme(fullpath.to_byte_string(), {}, hostname());
|
auto url = URL::create_with_file_scheme(fullpath, {}, hostname());
|
||||||
if (has_flag(print_type, PrintType::LineNumbers) && line_number.has_value())
|
if (has_flag(print_type, PrintType::LineNumbers) && line_number.has_value())
|
||||||
url.set_query(MUST(String::formatted("line_number={}", *line_number)));
|
url.set_query(MUST(String::formatted("line_number={}", *line_number)));
|
||||||
builder.appendff("\033]8;;{}\033\\", url.serialize());
|
builder.appendff("\033]8;;{}\033\\", url.serialize());
|
||||||
|
|
|
@ -264,7 +264,7 @@ static ErrorOr<TestResult> run_dump_test(HeadlessWebContentView& view, StringVie
|
||||||
loop.quit(0);
|
loop.quit(0);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
auto url = URL::create_with_file_scheme(TRY(FileSystem::real_path(input_path)).to_byte_string());
|
auto url = URL::create_with_file_scheme(TRY(FileSystem::real_path(input_path)));
|
||||||
|
|
||||||
String result;
|
String result;
|
||||||
auto did_finish_test = false;
|
auto did_finish_test = false;
|
||||||
|
@ -359,7 +359,7 @@ static ErrorOr<TestResult> run_ref_test(HeadlessWebContentView& view, StringView
|
||||||
loop.quit(0);
|
loop.quit(0);
|
||||||
}));
|
}));
|
||||||
|
|
||||||
view.load(URL::create_with_file_scheme(TRY(FileSystem::real_path(input_path)).to_byte_string()));
|
view.load(URL::create_with_file_scheme(TRY(FileSystem::real_path(input_path))));
|
||||||
|
|
||||||
RefPtr<Gfx::Bitmap> actual_screenshot, expectation_screenshot;
|
RefPtr<Gfx::Bitmap> actual_screenshot, expectation_screenshot;
|
||||||
view.on_load_finish = [&](auto const&) {
|
view.on_load_finish = [&](auto const&) {
|
||||||
|
@ -478,7 +478,8 @@ static ErrorOr<void> collect_dump_tests(Vector<Test>& tests, StringView path, St
|
||||||
auto basename = LexicalPath::title(name);
|
auto basename = LexicalPath::title(name);
|
||||||
auto expectation_path = TRY(String::formatted("{}/expected/{}/{}.txt", path, trail, basename));
|
auto expectation_path = TRY(String::formatted("{}/expected/{}/{}.txt", path, trail, basename));
|
||||||
|
|
||||||
tests.append({ move(input_path), move(expectation_path), mode, {} });
|
// FIXME: Test paths should be ByteString
|
||||||
|
tests.append({ TRY(String::from_byte_string(input_path)), move(expectation_path), mode, {} });
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -489,7 +490,8 @@ static ErrorOr<void> collect_ref_tests(Vector<Test>& tests, StringView path)
|
||||||
if (entry.type == Core::DirectoryEntry::Type::Directory)
|
if (entry.type == Core::DirectoryEntry::Type::Directory)
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
auto input_path = TRY(FileSystem::real_path(TRY(String::formatted("{}/{}", path, entry.name))));
|
auto input_path = TRY(FileSystem::real_path(TRY(String::formatted("{}/{}", path, entry.name))));
|
||||||
tests.append({ move(input_path), {}, TestMode::Ref, {} });
|
// FIXME: Test paths should be ByteString
|
||||||
|
tests.append({ TRY(String::from_byte_string(input_path)), {}, TestMode::Ref, {} });
|
||||||
return IterationDecision::Continue;
|
return IterationDecision::Continue;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
|
@ -267,7 +267,7 @@ static size_t print_name(const struct stat& st, ByteString const& name, Optional
|
||||||
auto full_path_or_error = FileSystem::real_path(path_for_hyperlink);
|
auto full_path_or_error = FileSystem::real_path(path_for_hyperlink);
|
||||||
if (!full_path_or_error.is_error()) {
|
if (!full_path_or_error.is_error()) {
|
||||||
auto fullpath = full_path_or_error.release_value();
|
auto fullpath = full_path_or_error.release_value();
|
||||||
auto url = URL::create_with_file_scheme(fullpath.to_byte_string(), {}, hostname());
|
auto url = URL::create_with_file_scheme(fullpath, {}, hostname());
|
||||||
out("\033]8;;{}\033\\", url.serialize());
|
out("\033]8;;{}\033\\", url.serialize());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -301,6 +301,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
|
|
||||||
if (verbose_output)
|
if (verbose_output)
|
||||||
outln("Reading and parsing Markdown files ...");
|
outln("Reading and parsing Markdown files ...");
|
||||||
|
// FIXME: Use ByteString for file paths
|
||||||
HashMap<String, MarkdownLinkage> files;
|
HashMap<String, MarkdownLinkage> files;
|
||||||
for (auto path : file_paths) {
|
for (auto path : file_paths) {
|
||||||
auto file_or_error = Core::File::open(path, Core::File::OpenMode::Read);
|
auto file_or_error = Core::File::open(path, Core::File::OpenMode::Read);
|
||||||
|
@ -326,7 +327,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
// Since this should never happen anyway, fail early.
|
// Since this should never happen anyway, fail early.
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
files.set(TRY(FileSystem::real_path(path)), MarkdownLinkage::analyze(*document, verbose_output));
|
files.set(TRY(String::from_byte_string(TRY(FileSystem::real_path(path)))), MarkdownLinkage::analyze(*document, verbose_output));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (verbose_output)
|
if (verbose_output)
|
||||||
|
|
|
@ -34,7 +34,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
url = URL::create_with_url_or_path(path_or_error.value().to_byte_string());
|
url = URL::create_with_url_or_path(path_or_error.value());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Desktop::Launcher::open(url)) {
|
if (!Desktop::Launcher::open(url)) {
|
||||||
|
|
|
@ -382,7 +382,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
test_root = TRY(FileSystem::real_path(test_root)).to_byte_string();
|
test_root = TRY(FileSystem::real_path(test_root));
|
||||||
|
|
||||||
auto void_or_error = Core::System::chdir(test_root);
|
auto void_or_error = Core::System::chdir(test_root);
|
||||||
if (void_or_error.is_error()) {
|
if (void_or_error.is_error()) {
|
||||||
|
|
|
@ -179,7 +179,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
char hostname[HOST_NAME_MAX];
|
char hostname[HOST_NAME_MAX];
|
||||||
VERIFY(gethostname(hostname, sizeof(hostname)) == 0);
|
VERIFY(gethostname(hostname, sizeof(hostname)) == 0);
|
||||||
|
|
||||||
auto url = URL::create_with_file_scheme(full_path_or_error.value().to_byte_string(), {}, hostname);
|
auto url = URL::create_with_file_scheme(full_path_or_error.value(), {}, hostname);
|
||||||
out("\033]8;;{}\033\\", url.serialize());
|
out("\033]8;;{}\033\\", url.serialize());
|
||||||
printed_hyperlink = true;
|
printed_hyperlink = true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -388,11 +388,11 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
for (auto& string : wasi_preopened_mappings) {
|
for (auto& string : wasi_preopened_mappings) {
|
||||||
auto split_index = string.find(':');
|
auto split_index = string.find(':');
|
||||||
if (split_index.has_value()) {
|
if (split_index.has_value()) {
|
||||||
LexicalPath host_path { FileSystem::real_path(string.substring_view(0, *split_index)).release_value_but_fixme_should_propagate_errors().to_byte_string() };
|
LexicalPath host_path { FileSystem::real_path(string.substring_view(0, *split_index)).release_value_but_fixme_should_propagate_errors() };
|
||||||
LexicalPath mapped_path { string.substring_view(*split_index + 1) };
|
LexicalPath mapped_path { string.substring_view(*split_index + 1) };
|
||||||
paths.append({move(host_path), move(mapped_path)});
|
paths.append({move(host_path), move(mapped_path)});
|
||||||
} else {
|
} else {
|
||||||
LexicalPath host_path { FileSystem::real_path(string).release_value_but_fixme_should_propagate_errors().to_byte_string() };
|
LexicalPath host_path { FileSystem::real_path(string).release_value_but_fixme_should_propagate_errors() };
|
||||||
LexicalPath mapped_path { string };
|
LexicalPath mapped_path { string };
|
||||||
paths.append({move(host_path), move(mapped_path)});
|
paths.append({move(host_path), move(mapped_path)});
|
||||||
}
|
}
|
||||||
|
|
|
@ -355,7 +355,7 @@ static void dump(XML::Document& document)
|
||||||
dump(document.root());
|
dump(document.root());
|
||||||
}
|
}
|
||||||
|
|
||||||
static String s_path;
|
static ByteString s_path;
|
||||||
static auto parse(StringView contents)
|
static auto parse(StringView contents)
|
||||||
{
|
{
|
||||||
return XML::Parser {
|
return XML::Parser {
|
||||||
|
@ -363,7 +363,7 @@ static auto parse(StringView contents)
|
||||||
{
|
{
|
||||||
.preserve_comments = true,
|
.preserve_comments = true,
|
||||||
.resolve_external_resource = [&](XML::SystemID const& system_id, Optional<XML::PublicID> const&) -> ErrorOr<ByteString> {
|
.resolve_external_resource = [&](XML::SystemID const& system_id, Optional<XML::PublicID> const&) -> ErrorOr<ByteString> {
|
||||||
auto base = URL::create_with_file_scheme(s_path.to_byte_string());
|
auto base = URL::create_with_file_scheme(s_path);
|
||||||
auto url = URLParser::basic_parse(system_id.system_literal, base);
|
auto url = URLParser::basic_parse(system_id.system_literal, base);
|
||||||
if (!url.is_valid())
|
if (!url.is_valid())
|
||||||
return Error::from_string_literal("Invalid URL");
|
return Error::from_string_literal("Invalid URL");
|
||||||
|
@ -402,7 +402,7 @@ static void do_run_tests(XML::Document& document)
|
||||||
|
|
||||||
dump_cases(root);
|
dump_cases(root);
|
||||||
|
|
||||||
auto base_path = LexicalPath::dirname(s_path.to_byte_string());
|
auto base_path = LexicalPath::dirname(s_path);
|
||||||
|
|
||||||
while (!suites.is_empty()) {
|
while (!suites.is_empty()) {
|
||||||
auto& node = *suites.dequeue();
|
auto& node = *suites.dequeue();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue