mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:38:11 +00:00
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:
parent
41ce2debda
commit
73ae5200a9
6 changed files with 109 additions and 18 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue