mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 21:58:10 +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:
parent
24b9e57b15
commit
a1bcd9ca8a
1 changed files with 9 additions and 2 deletions
|
@ -654,8 +654,15 @@ int run_in_windowed_mode(RefPtr<Core::ConfigFile> config, String initial_locatio
|
|||
tree_view.update();
|
||||
}
|
||||
|
||||
go_forward_action->set_enabled(directory_view.path_history_position()
|
||||
< directory_view.path_history_size() - 1);
|
||||
struct stat st;
|
||||
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);
|
||||
open_parent_directory_action->set_enabled(new_path != "/");
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue