mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 15:04:59 +00:00
LaunchServer: Resolve symlinks when querying for handler application
This lets us launch proper handler application for symlinks :^)
This commit is contained in:
parent
51d559e253
commit
31d659d9a0
1 changed files with 10 additions and 2 deletions
|
@ -12,6 +12,7 @@
|
||||||
#include <AK/LexicalPath.h>
|
#include <AK/LexicalPath.h>
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
#include <LibCore/ConfigFile.h>
|
#include <LibCore/ConfigFile.h>
|
||||||
|
#include <LibCore/File.h>
|
||||||
#include <LibDesktop/AppFile.h>
|
#include <LibDesktop/AppFile.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <serenity.h>
|
#include <serenity.h>
|
||||||
|
@ -252,8 +253,8 @@ void Launcher::for_each_handler(const String& key, HashMap<String, String>& user
|
||||||
void Launcher::for_each_handler_for_path(const String& path, Function<bool(const Handler&)> f)
|
void Launcher::for_each_handler_for_path(const String& path, Function<bool(const Handler&)> f)
|
||||||
{
|
{
|
||||||
struct stat st;
|
struct stat st;
|
||||||
if (stat(path.characters(), &st) < 0) {
|
if (lstat(path.characters(), &st) < 0) {
|
||||||
perror("stat");
|
perror("lstat");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,6 +270,13 @@ void Launcher::for_each_handler_for_path(const String& path, Function<bool(const
|
||||||
if (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode))
|
if (!S_ISREG(st.st_mode) && !S_ISLNK(st.st_mode))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (S_ISLNK(st.st_mode)) {
|
||||||
|
auto real_path = Core::File::real_path_for(String::formatted("{}/{}", LexicalPath::dirname(path), Core::File::read_link(path)));
|
||||||
|
return for_each_handler_for_path(real_path, [&](const auto& handler) -> bool {
|
||||||
|
return f(handler);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if ((st.st_mode & S_IFMT) == S_IFREG && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
|
if ((st.st_mode & S_IFMT) == S_IFREG && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
|
||||||
f(get_handler_for_executable(Handler::Type::Application, path));
|
f(get_handler_for_executable(Handler::Type::Application, path));
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue