diff --git a/Userland/Applications/FileManager/PropertiesWindow.cpp b/Userland/Applications/FileManager/PropertiesWindow.cpp index 8c0ff9f74e..04603268c4 100644 --- a/Userland/Applications/FileManager/PropertiesWindow.cpp +++ b/Userland/Applications/FileManager/PropertiesWindow.cpp @@ -199,7 +199,7 @@ bool PropertiesWindow::apply_changes() String new_name = m_name_box->text(); String new_file = make_full_path(new_name).characters(); - if (GUI::FilePicker::file_exists(new_file)) { + if (Core::File::exists(new_file)) { GUI::MessageBox::show(this, String::formatted("A file \"{}\" already exists!", new_name), "Error", GUI::MessageBox::Type::Error); return false; } diff --git a/Userland/DevTools/HackStudio/HackStudioWidget.cpp b/Userland/DevTools/HackStudio/HackStudioWidget.cpp index 823595d80b..f2cfdf2a8d 100644 --- a/Userland/DevTools/HackStudio/HackStudioWidget.cpp +++ b/Userland/DevTools/HackStudio/HackStudioWidget.cpp @@ -538,7 +538,7 @@ void HackStudioWidget::reveal_action_tab(GUI::Widget& widget) NonnullRefPtr HackStudioWidget::create_debug_action() { return GUI::Action::create("Debug", Gfx::Bitmap::load_from_file("/res/icons/16x16/debug-run.png"), [this](auto&) { - if (!GUI::FilePicker::file_exists(get_project_executable_path())) { + if (!Core::File::exists(get_project_executable_path())) { GUI::MessageBox::show(window(), String::formatted("Could not find file: {}. (did you build the project?)", get_project_executable_path()), "Error", GUI::MessageBox::Type::Error); return; } 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(); diff --git a/Userland/Libraries/LibGUI/FilePicker.h b/Userland/Libraries/LibGUI/FilePicker.h index d5a6b9c523..f2119fc24f 100644 --- a/Userland/Libraries/LibGUI/FilePicker.h +++ b/Userland/Libraries/LibGUI/FilePicker.h @@ -49,7 +49,6 @@ public: static Optional get_open_filepath(Window* parent_window, const String& window_title = {}); static Optional get_save_filepath(Window* parent_window, const String& title, const String& extension); - static bool file_exists(const StringView& path); virtual ~FilePicker() override;