mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 22:37:34 +00:00
FileManager: Allow launching processes by activating an executable file.
This commit is contained in:
parent
1ab995bfff
commit
5f4245789d
4 changed files with 17 additions and 2 deletions
|
@ -11,6 +11,7 @@ DirectoryTableModel::DirectoryTableModel()
|
||||||
m_file_icon = GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/file16.rgb", { 16, 16 });
|
m_file_icon = GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/file16.rgb", { 16, 16 });
|
||||||
m_symlink_icon = GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/link16.rgb", { 16, 16 });
|
m_symlink_icon = GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/link16.rgb", { 16, 16 });
|
||||||
m_socket_icon = GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/socket16.rgb", { 16, 16 });
|
m_socket_icon = GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/socket16.rgb", { 16, 16 });
|
||||||
|
m_executable_icon = GraphicsBitmap::load_from_file(GraphicsBitmap::Format::RGBA32, "/res/icons/executable16.rgb", { 16, 16 });
|
||||||
}
|
}
|
||||||
|
|
||||||
DirectoryTableModel::~DirectoryTableModel()
|
DirectoryTableModel::~DirectoryTableModel()
|
||||||
|
@ -63,6 +64,8 @@ const GraphicsBitmap& DirectoryTableModel::icon_for(const Entry& entry) const
|
||||||
return *m_symlink_icon;
|
return *m_symlink_icon;
|
||||||
if (S_ISSOCK(entry.mode))
|
if (S_ISSOCK(entry.mode))
|
||||||
return *m_socket_icon;
|
return *m_socket_icon;
|
||||||
|
if (entry.mode & S_IXUSR)
|
||||||
|
return *m_executable_icon;
|
||||||
return *m_file_icon;
|
return *m_file_icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,8 +176,18 @@ void DirectoryTableModel::open(const String& path)
|
||||||
void DirectoryTableModel::activate(const GModelIndex& index)
|
void DirectoryTableModel::activate(const GModelIndex& index)
|
||||||
{
|
{
|
||||||
auto& entry = this->entry(index.row());
|
auto& entry = this->entry(index.row());
|
||||||
|
FileSystemPath path(String::format("%s/%s", m_path.characters(), entry.name.characters()));
|
||||||
if (entry.is_directory()) {
|
if (entry.is_directory()) {
|
||||||
FileSystemPath new_path(String::format("%s/%s", m_path.characters(), entry.name.characters()));
|
open(path.string());
|
||||||
open(new_path.string());
|
return;
|
||||||
|
}
|
||||||
|
if (entry.is_executable()) {
|
||||||
|
if (fork() == 0) {
|
||||||
|
int rc = execl(path.string().characters(), path.string().characters(), nullptr);
|
||||||
|
if (rc < 0)
|
||||||
|
perror("exec");
|
||||||
|
ASSERT_NOT_REACHED();
|
||||||
|
}
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,6 +40,7 @@ private:
|
||||||
uid_t gid { 0 };
|
uid_t gid { 0 };
|
||||||
ino_t inode { 0 };
|
ino_t inode { 0 };
|
||||||
bool is_directory() const { return S_ISDIR(mode); }
|
bool is_directory() const { return S_ISDIR(mode); }
|
||||||
|
bool is_executable() const { return mode & S_IXUSR; }
|
||||||
};
|
};
|
||||||
|
|
||||||
const Entry& entry(int index) const
|
const Entry& entry(int index) const
|
||||||
|
@ -59,4 +60,5 @@ private:
|
||||||
RetainPtr<GraphicsBitmap> m_file_icon;
|
RetainPtr<GraphicsBitmap> m_file_icon;
|
||||||
RetainPtr<GraphicsBitmap> m_symlink_icon;
|
RetainPtr<GraphicsBitmap> m_symlink_icon;
|
||||||
RetainPtr<GraphicsBitmap> m_socket_icon;
|
RetainPtr<GraphicsBitmap> m_socket_icon;
|
||||||
|
RetainPtr<GraphicsBitmap> m_executable_icon;
|
||||||
};
|
};
|
||||||
|
|
BIN
Base/res/icons/executable16.png
Normal file
BIN
Base/res/icons/executable16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 223 B |
BIN
Base/res/icons/executable16.rgb
Normal file
BIN
Base/res/icons/executable16.rgb
Normal file
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue