mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 14:05:08 +00:00
FileManager: Use stat() when activating a file/directory
This makes it possible to open symlinks to directories by activating them (via double click, for example.) :^) Fixes #21.
This commit is contained in:
parent
f2f0965edd
commit
fcb7f6f233
2 changed files with 12 additions and 3 deletions
|
@ -55,11 +55,20 @@ void DirectoryView::handle_activation(const GModelIndex& index)
|
||||||
dbgprintf("on activation: %d,%d, this=%p, m_model=%p\n", index.row(), index.column(), this, m_model.ptr());
|
dbgprintf("on activation: %d,%d, this=%p, m_model=%p\n", index.row(), index.column(), this, m_model.ptr());
|
||||||
auto& node = model().node(index);
|
auto& node = model().node(index);
|
||||||
auto path = node.full_path(model());
|
auto path = node.full_path(model());
|
||||||
if (node.is_directory()) {
|
|
||||||
|
struct stat st;
|
||||||
|
if (stat(path.characters(), &st) < 0) {
|
||||||
|
perror("stat");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (S_ISDIR(st.st_mode)) {
|
||||||
open(path);
|
open(path);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (node.is_executable()) {
|
|
||||||
|
// FIXME: This doesn't seem like the right way to fully detect executability.
|
||||||
|
if (st.st_mode & S_IXUSR) {
|
||||||
if (fork() == 0) {
|
if (fork() == 0) {
|
||||||
int rc = execl(path.characters(), path.characters(), nullptr);
|
int rc = execl(path.characters(), path.characters(), nullptr);
|
||||||
if (rc < 0)
|
if (rc < 0)
|
||||||
|
|
|
@ -140,7 +140,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
struct stat st;
|
struct stat st;
|
||||||
// If the directory no longer exists, we find a parent that does.
|
// If the directory no longer exists, we find a parent that does.
|
||||||
while (lstat(current_path.characters(), &st) != 0) {
|
while (stat(current_path.characters(), &st) != 0) {
|
||||||
directory_view->open_parent_directory();
|
directory_view->open_parent_directory();
|
||||||
current_path = directory_view->path();
|
current_path = directory_view->path();
|
||||||
if (current_path == directories_model->root_path()) {
|
if (current_path == directories_model->root_path()) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue