TextEditor+LibGUI: Use unveil and FileSystemAccessServer

Making use of the new FileSystemAccessServer we are able to use
unveil without restricting our ability to open and save files.
A file argument will be unveiled automatically however all other files
require user action via the FileSystemAccessServer to gain access.
This commit is contained in:
Timothy
2021-06-30 06:13:06 -07:00
committed by Andreas Kling
parent 41ce2debda
commit 73ae5200a9
6 changed files with 109 additions and 18 deletions

View File

@@ -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;