summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Userland/Libraries/LibGUI/FilePicker.cpp2
-rw-r--r--Userland/Libraries/LibGUI/FileSystemModel.cpp10
-rw-r--r--Userland/Libraries/LibGUI/FileSystemModel.h1
3 files changed, 12 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGUI/FilePicker.cpp b/Userland/Libraries/LibGUI/FilePicker.cpp
index c68dbf09e8..0ec144353a 100644
--- a/Userland/Libraries/LibGUI/FilePicker.cpp
+++ b/Userland/Libraries/LibGUI/FilePicker.cpp
@@ -214,7 +214,7 @@ FilePicker::FilePicker(Window* parent_window, Mode mode, const StringView& file_
const FileSystemModel::Node& node = m_model->node(local_index);
auto path = node.full_path();
- if (node.is_directory()) {
+ if (node.is_directory() || node.is_symlink_to_directory()) {
set_path(path);
// NOTE: 'node' is invalid from here on
} else {
diff --git a/Userland/Libraries/LibGUI/FileSystemModel.cpp b/Userland/Libraries/LibGUI/FileSystemModel.cpp
index 330daa0fe2..8cf034518b 100644
--- a/Userland/Libraries/LibGUI/FileSystemModel.cpp
+++ b/Userland/Libraries/LibGUI/FileSystemModel.cpp
@@ -164,6 +164,16 @@ void FileSystemModel::Node::reify_if_needed()
fetch_data(full_path(), parent == nullptr || parent->m_parent_of_root);
}
+bool FileSystemModel::Node::is_symlink_to_directory() const
+{
+ if (!S_ISLNK(mode))
+ return false;
+ struct stat st;
+ if (lstat(symlink_target.characters(), &st) < 0)
+ return false;
+ return S_ISDIR(st.st_mode);
+}
+
String FileSystemModel::Node::full_path() const
{
Vector<String, 32> lineage;
diff --git a/Userland/Libraries/LibGUI/FileSystemModel.h b/Userland/Libraries/LibGUI/FileSystemModel.h
index 5b10438a4a..9189a99131 100644
--- a/Userland/Libraries/LibGUI/FileSystemModel.h
+++ b/Userland/Libraries/LibGUI/FileSystemModel.h
@@ -79,6 +79,7 @@ public:
mutable RefPtr<Gfx::Bitmap> thumbnail;
bool is_directory() const { return S_ISDIR(mode); }
+ bool is_symlink_to_directory() const;
bool is_executable() const { return mode & (S_IXUSR | S_IXGRP | S_IXOTH); }
bool is_selected() const { return m_selected; }