From 4f0be557706eeb1aa7f0584ac6a7f2456a066eea Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 19 Feb 2021 23:46:54 +0100 Subject: LibGUI: Remove GUI::FilePicker::file_exists() I have no idea why this existed but everyone should just use Core::File::exists() instead. :^) --- Userland/Libraries/LibGUI/FilePicker.cpp | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) (limited to 'Userland/Libraries/LibGUI/FilePicker.cpp') diff --git a/Userland/Libraries/LibGUI/FilePicker.cpp b/Userland/Libraries/LibGUI/FilePicker.cpp index ac933f5636..c73697b908 100644 --- a/Userland/Libraries/LibGUI/FilePicker.cpp +++ b/Userland/Libraries/LibGUI/FilePicker.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include #include @@ -219,7 +220,7 @@ void FilePicker::on_file_return() { LexicalPath path(String::formatted("{}/{}", m_model->root_path(), m_filename_textbox->text())); - if (FilePicker::file_exists(path.string()) && m_mode == Mode::Save) { + if (Core::File::exists(path.string()) && 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; @@ -229,20 +230,6 @@ void FilePicker::on_file_return() done(ExecOK); } -bool FilePicker::file_exists(const StringView& path) -{ - struct stat st; - int rc = stat(path.to_string().characters(), &st); - if (rc < 0) { - if (errno == ENOENT) - return false; - } - if (rc == 0) { - return true; - } - return false; -} - void FilePicker::set_path(const String& path) { auto new_path = LexicalPath(path).string(); -- cgit v1.2.3