1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-30 19:38:12 +00:00

FileManager: Disables mkdir action if permissions don't allow it

Now the "New directory..." contextual menu is disabled if the current
user doesn't have enough permissions to create a node in the current
path.

This prevents the user going to the "New Directory" InputBox, writing
an appropriate name and accepting just to find they can't even do it :)
This commit is contained in:
Andres Vieira 2020-04-26 15:56:07 +02:00 committed by Andreas Kling
parent 24b9e57b15
commit a1bcd9ca8a

View file

@ -654,8 +654,15 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
tree_view.update(); tree_view.update();
} }
go_forward_action->set_enabled(directory_view.path_history_position() struct stat st;
< directory_view.path_history_size() - 1); if (lstat(new_path.characters(), &st)) {
perror("stat");
return;
}
auto can_write_in_path = access(new_path.characters(), W_OK) == 0;
mkdir_action->set_enabled(can_write_in_path);
go_forward_action->set_enabled(directory_view.path_history_position() < directory_view.path_history_size() - 1);
go_back_action->set_enabled(directory_view.path_history_position() > 0); go_back_action->set_enabled(directory_view.path_history_position() > 0);
open_parent_directory_action->set_enabled(new_path != "/"); open_parent_directory_action->set_enabled(new_path != "/");
}; };