editor: Fix creation of new files
All checks were successful
Build and test / build (push) Successful in 1m38s
All checks were successful
Build and test / build (push) Successful in 1m38s
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().
This commit is contained in:
parent
d6f7069589
commit
f3d9d4bcc0
@ -23,9 +23,9 @@ EditorWidget::EditorWidget(SharedPtr<ui::Font> font) : ui::TextInput(), m_font(f
|
|||||||
Result<void> EditorWidget::load_file(const os::Path& path)
|
Result<void> EditorWidget::load_file(const os::Path& path)
|
||||||
{
|
{
|
||||||
struct stat st;
|
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());
|
os::eprintln("editor: not loading %s as it is not a regular file", path.name().chars());
|
||||||
return {};
|
return {};
|
||||||
|
Loading…
Reference in New Issue
Block a user