summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/TextEditor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibGUI/TextEditor.cpp')
-rw-r--r--Userland/Libraries/LibGUI/TextEditor.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp
index 3a9617d0e8..bf7e18fa4d 100644
--- a/Userland/Libraries/LibGUI/TextEditor.cpp
+++ b/Userland/Libraries/LibGUI/TextEditor.cpp
@@ -1198,7 +1198,7 @@ void TextEditor::timer_event(Core::TimerEvent&)
update_cursor();
}
-bool TextEditor::write_to_file(const String& path)
+bool TextEditor::write_to_file(String const& path)
{
int fd = open(path.characters(), O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd < 0) {
@@ -1206,6 +1206,11 @@ bool TextEditor::write_to_file(const String& path)
return false;
}
+ return write_to_file_and_close(fd);
+}
+
+bool TextEditor::write_to_file_and_close(int fd)
+{
ScopeGuard fd_guard = [fd] { close(fd); };
off_t file_size = 0;