mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 02:17:34 +00:00
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
This commit is contained in:
parent
f8d643284e
commit
509e39ac00
2 changed files with 6 additions and 5 deletions
|
@ -29,6 +29,7 @@
|
||||||
#include <AK/LexicalPath.h>
|
#include <AK/LexicalPath.h>
|
||||||
#include <AK/NumberFormat.h>
|
#include <AK/NumberFormat.h>
|
||||||
#include <AK/StringBuilder.h>
|
#include <AK/StringBuilder.h>
|
||||||
|
#include <LibCore/File.h>
|
||||||
#include <LibCore/MimeData.h>
|
#include <LibCore/MimeData.h>
|
||||||
#include <LibCore/StandardPaths.h>
|
#include <LibCore/StandardPaths.h>
|
||||||
#include <LibGUI/FileIconProvider.h>
|
#include <LibGUI/FileIconProvider.h>
|
||||||
|
@ -349,13 +350,15 @@ void DirectoryView::add_path_to_history(const StringView& path)
|
||||||
|
|
||||||
void DirectoryView::open(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();
|
model().update();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
set_active_widget(¤t_view());
|
set_active_widget(¤t_view());
|
||||||
model().set_root_path(path);
|
model().set_root_path(real_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
void DirectoryView::set_status_message(const StringView& message)
|
void DirectoryView::set_status_message(const StringView& message)
|
||||||
|
|
|
@ -114,9 +114,7 @@ int main(int argc, char** argv)
|
||||||
String initial_location;
|
String initial_location;
|
||||||
|
|
||||||
if (argc >= 2) {
|
if (argc >= 2) {
|
||||||
char* buffer = realpath(argv[1], nullptr);
|
initial_location = Core::File::real_path_for(argv[1]);
|
||||||
initial_location = buffer;
|
|
||||||
free(buffer);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (initial_location.is_empty())
|
if (initial_location.is_empty())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue