1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 10:18:11 +00:00

LibGUI+FileManager: Try better to detect executables

We will now consider a file to be an executable if any of the executable
permission bits are set.
This commit is contained in:
Sergey Bugaev 2020-01-28 16:23:59 +03:00 committed by Andreas Kling
parent f983dfe319
commit f9b4d981a8
3 changed files with 5 additions and 4 deletions

View file

@ -68,8 +68,9 @@ void DirectoryView::handle_activation(const GModelIndex& index)
return;
}
// FIXME: This doesn't seem like the right way to fully detect executability.
if (st.st_mode & S_IXUSR) {
ASSERT(!S_ISLNK(st.st_mode));
if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) {
if (fork() == 0) {
int rc = execl(path.characters(), path.characters(), nullptr);
if (rc < 0)

View file

@ -415,7 +415,7 @@ GIcon GFileSystemModel::icon_for_file(const mode_t mode, const String& name) con
return m_symlink_icon;
if (S_ISSOCK(mode))
return m_socket_icon;
if (mode & S_IXUSR)
if (mode & (S_IXUSR | S_IXGRP | S_IXOTH))
return m_executable_icon;
if (name.to_lowercase().ends_with(".wav"))
return m_filetype_sound_icon;

View file

@ -73,7 +73,7 @@ public:
mutable RefPtr<GraphicsBitmap> thumbnail;
bool is_directory() const { return S_ISDIR(mode); }
bool is_executable() const { return mode & S_IXUSR; }
bool is_executable() const { return mode & (S_IXUSR | S_IXGRP | S_IXOTH); }
String full_path(const GFileSystemModel&) const;