1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 04:17:35 +00:00

HackStudio: Use Core::System APIs where possible

This commit is contained in:
Sam Atkins 2024-01-11 16:55:49 +00:00 committed by Andrew Kaster
parent 16543a1918
commit 336b8ed80b
4 changed files with 23 additions and 15 deletions

View file

@ -480,11 +480,12 @@ void Editor::set_document(GUI::TextDocument& doc)
// Otherwise, if the file has already been opened before in some Editor instance, it should exist in the LanguageServer's
// FileDB, and the LanguageServer should already have its up-to-date content.
// So it's OK to just pass an fd here (rather than the TextDocument's content).
int fd = open(code_document.file_path().characters(), O_RDONLY | O_NOCTTY);
if (fd < 0) {
perror("open");
auto maybe_fd = Core::System::open(code_document.file_path(), O_RDONLY | O_NOCTTY);
if (maybe_fd.is_error()) {
warnln("Failed to open `{}`: {}", code_document.file_path(), maybe_fd.release_error());
return;
}
auto fd = maybe_fd.release_value();
m_language_client->open_file(code_document.file_path(), fd);
close(fd);
} else {