1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-06-01 10:18:13 +00:00

LibGUI+Shell+bt+ls: Use proper APIs for creating file URLs

This patch replaces ad-hoc generation of file URL strings with using
URL::create_with_file_scheme().
This commit is contained in:
Max Wipfli 2021-05-29 23:15:54 +02:00 committed by Andreas Kling
parent 5caaa52bee
commit 628c7f094f
4 changed files with 12 additions and 9 deletions

View file

@ -5,6 +5,7 @@
*/
#include <AK/LexicalPath.h>
#include <AK/URL.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/DirIterator.h>
#include <LibCore/EventLoop.h>
@ -57,7 +58,9 @@ int main(int argc, char** argv)
auto full_path = LexicalPath::canonicalized_path(String::formatted("/usr/src/serenity/dummy/dummy/{}", symbol.filename));
if (access(full_path.characters(), F_OK) == 0) {
linked = true;
out("\033]8;;file://{}{}?line_number={}\033\\", hostname, full_path, symbol.line_number);
auto url = URL::create_with_file_scheme(full_path, {}, hostname);
url.set_query(String::formatted("line_number={}", symbol.line_number));
out("\033]8;;{}\033\\", url.serialize());
}
out("\033[34;1m{}:{}\033[0m", LexicalPath(symbol.filename).basename(), symbol.line_number);