summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDragonAlex98 <alessandro.antinori@studenti.unicam.it>2021-01-24 00:43:33 +0100
committerAndreas Kling <kling@serenityos.org>2021-01-24 19:21:54 +0100
commit509e39ac00fb512fcd192e73b7d69564268d87a7 (patch)
treebac04fcb99903c12a281df8394945853d91e6ab6
parentf8d643284e293978b4a612e901691fad17461d6e (diff)
downloadserenity-509e39ac00fb512fcd192e73b7d69564268d87a7.zip
FileManager: Make DirectoryView open links in their real directory
Previously it was possible to open a link like /home/anon/Desktop/Home, leading to a folder with the same name. Now it correctly opens its real path, which is /home/anon FileManager: Use Core::File::real_path_for to get real path of links
-rw-r--r--Userland/Applications/FileManager/DirectoryView.cpp7
-rw-r--r--Userland/Applications/FileManager/main.cpp4
2 files changed, 6 insertions, 5 deletions
diff --git a/Userland/Applications/FileManager/DirectoryView.cpp b/Userland/Applications/FileManager/DirectoryView.cpp
index ae30df2a4f..9e3595c5b1 100644
--- a/Userland/Applications/FileManager/DirectoryView.cpp
+++ b/Userland/Applications/FileManager/DirectoryView.cpp
@@ -29,6 +29,7 @@
#include <AK/LexicalPath.h>
#include <AK/NumberFormat.h>
#include <AK/StringBuilder.h>
+#include <LibCore/File.h>
#include <LibCore/MimeData.h>
#include <LibCore/StandardPaths.h>
#include <LibGUI/FileIconProvider.h>
@@ -349,13 +350,15 @@ void DirectoryView::add_path_to_history(const StringView& path)
void DirectoryView::open(const StringView& path)
{
- if (model().root_path() == path) {
+ auto real_path = Core::File::real_path_for(path);
+
+ if (model().root_path() == real_path) {
model().update();
return;
}
set_active_widget(&current_view());
- model().set_root_path(path);
+ model().set_root_path(real_path);
}
void DirectoryView::set_status_message(const StringView& message)
diff --git a/Userland/Applications/FileManager/main.cpp b/Userland/Applications/FileManager/main.cpp
index 703d93c91f..926491d5c5 100644
--- a/Userland/Applications/FileManager/main.cpp
+++ b/Userland/Applications/FileManager/main.cpp
@@ -114,9 +114,7 @@ int main(int argc, char** argv)
String initial_location;
if (argc >= 2) {
- char* buffer = realpath(argv[1], nullptr);
- initial_location = buffer;
- free(buffer);
+ initial_location = Core::File::real_path_for(argv[1]);
}
if (initial_location.is_empty())