mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 19:38:12 +00:00
LibGUI: Remove GUI::FilePicker::file_exists()
I have no idea why this existed but everyone should just use Core::File::exists() instead. :^)
This commit is contained in:
parent
a8e0671344
commit
4f0be55770
4 changed files with 4 additions and 18 deletions
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <AK/Function.h>
|
||||
#include <AK/LexicalPath.h>
|
||||
#include <LibCore/File.h>
|
||||
#include <LibCore/StandardPaths.h>
|
||||
#include <LibGUI/Action.h>
|
||||
#include <LibGUI/BoxLayout.h>
|
||||
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue