From ac701cb589496f58ce89ebacf34013b63f763cb8 Mon Sep 17 00:00:00 2001 From: AnotherTest Date: Sun, 10 May 2020 02:27:43 +0430 Subject: [PATCH] Userland: Send absolute paths to LaunchServer and show what failed --- Userland/open.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/Userland/open.cpp b/Userland/open.cpp index 5d8e80cb17..f2b56d977a 100644 --- a/Userland/open.cpp +++ b/Userland/open.cpp @@ -29,6 +29,7 @@ #include #include #include +#include int main(int argc, char* argv[]) { @@ -43,8 +44,20 @@ int main(int argc, char* argv[]) for (auto& url_or_path : urls_or_paths) { URL url = URL::create_with_url_or_path(url_or_path); - bool ok = Desktop::Launcher::open(url); - all_ok = all_ok && ok; + if (url.protocol() == "file" && !url.path().starts_with('/')) { + if (auto* path = realpath(url.path().characters(), nullptr)) { + url.set_path(path); + free(path); + } else { + fprintf(stderr, "Failed to open '%s': %s\n", url.path().characters(), strerror(errno)); + all_ok = false; + continue; + } + } + if (!Desktop::Launcher::open(url)) { + fprintf(stderr, "Failed to open '%s'\n", url.path().characters()); + all_ok = false; + } } return all_ok ? 0 : 1;