summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-05-20 20:53:32 +0200
committerAndreas Kling <kling@serenityos.org>2021-05-20 20:55:29 +0200
commit54f6ac1854f33053565ba3eb246f08e4d54fcd13 (patch)
treec282891591dfabefa589dd18adc445645c4cbe3f /Userland
parent9b9966b63bcf0d22dae3044bea30d9640038b9a1 (diff)
downloadserenity-54f6ac1854f33053565ba3eb246f08e4d54fcd13.zip
LibGUI: Don't mark "open" FilePicker as done if the file is not found
If you type in a filename that doesn't exist, show an error message instead of closing the FilePicker "successfully."
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibGUI/FilePicker.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGUI/FilePicker.cpp b/Userland/Libraries/LibGUI/FilePicker.cpp
index 77912d47d1..f914c97d35 100644
--- a/Userland/Libraries/LibGUI/FilePicker.cpp
+++ b/Userland/Libraries/LibGUI/FilePicker.cpp
@@ -252,7 +252,14 @@ void FilePicker::on_file_return()
path = LexicalPath::join(m_model->root_path(), path).string();
}
- if (Core::File::exists(path) && m_mode == Mode::Save) {
+ bool file_exists = Core::File::exists(path);
+
+ if (!file_exists && (m_mode == Mode::Open || m_mode == Mode::OpenFolder)) {
+ MessageBox::show(this, String::formatted("No such file or directory: {}", m_filename_textbox->text()), "File not found", MessageBox::Type::Error, MessageBox::InputType::OK);
+ return;
+ }
+
+ if (file_exists && m_mode == Mode::Save) {
auto result = MessageBox::show(this, "File already exists. Overwrite?", "Existing File", MessageBox::Type::Warning, MessageBox::InputType::OKCancel);
if (result == MessageBox::ExecCancel)
return;