diff --git a/Applications/FileManager/DirectoryView.cpp b/Applications/FileManager/DirectoryView.cpp index be96e6c8a8..4832baaffa 100644 --- a/Applications/FileManager/DirectoryView.cpp +++ b/Applications/FileManager/DirectoryView.cpp @@ -27,6 +27,8 @@ #include "DirectoryView.h" #include #include +#include +#include #include #include #include @@ -68,55 +70,12 @@ void DirectoryView::handle_activation(const GUI::ModelIndex& index) return; } - ASSERT(!S_ISLNK(st.st_mode)); + URL url; + url.set_protocol("file"); + url.set_path(path); - if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) { - if (fork() == 0) { - int rc = execl(path.characters(), path.characters(), nullptr); - if (rc < 0) - perror("exec"); - ASSERT_NOT_REACHED(); - } - return; - } - - if (path.to_lowercase().ends_with(".png")) { - if (fork() == 0) { - int rc = execl("/bin/qs", "/bin/qs", path.characters(), nullptr); - if (rc < 0) - perror("exec"); - ASSERT_NOT_REACHED(); - } - return; - } - - if (path.to_lowercase().ends_with(".html")) { - if (fork() == 0) { - int rc = execl("/bin/Browser", "/bin/Browser", path.characters(), nullptr); - if (rc < 0) - perror("exec"); - ASSERT_NOT_REACHED(); - } - return; - } - - if (path.to_lowercase().ends_with(".wav")) { - if (fork() == 0) { - int rc = execl("/bin/SoundPlayer", "/bin/SoundPlayer", path.characters(), nullptr); - if (rc < 0) - perror("exec"); - ASSERT_NOT_REACHED(); - } - return; - } - - if (fork() == 0) { - int rc = execl("/bin/TextEditor", "/bin/TextEditor", path.characters(), nullptr); - if (rc < 0) - perror("exec"); - ASSERT_NOT_REACHED(); - } -}; + GUI::DesktopServices::open(url); +} DirectoryView::DirectoryView() : m_model(GUI::FileSystemModel::create())