From ade1e60eb5f294b060e38c97c98403c48a106115 Mon Sep 17 00:00:00 2001 From: apio Date: Fri, 29 Mar 2024 20:41:16 +0100 Subject: [PATCH] editor: Fix creation of new files The editor is supposed to create files if they don't exist, however before this commit stat() would fail and exit load_file() before we even got to File::open_or_create(). --- editor/EditorWidget.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/editor/EditorWidget.cpp b/editor/EditorWidget.cpp index 833e7076..901c3058 100644 --- a/editor/EditorWidget.cpp +++ b/editor/EditorWidget.cpp @@ -23,9 +23,9 @@ EditorWidget::EditorWidget(SharedPtr font) : ui::TextInput(), m_font(f Result EditorWidget::load_file(const os::Path& path) { struct stat st; - TRY(os::FileSystem::stat(path, st, true)); + auto rc = os::FileSystem::stat(path, st, true); - if (!S_ISREG(st.st_mode)) + if (!rc.has_error() && !S_ISREG(st.st_mode)) { os::eprintln("editor: not loading %s as it is not a regular file", path.name().chars()); return {};