mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 10:47:35 +00:00
LibCore+Everywhere: Move OpenMode out of IODevice
...and make it an enum class so people don't omit "OpenMode".
This commit is contained in:
parent
422ef7904e
commit
a91a49337c
113 changed files with 180 additions and 177 deletions
|
@ -170,7 +170,7 @@ void Editor::show_documentation_tooltip_if_available(const String& hovered_token
|
|||
|
||||
dbgln_if(EDITOR_DEBUG, "opening {}", it->value);
|
||||
auto file = Core::File::construct(it->value);
|
||||
if (!file->open(Core::File::ReadOnly)) {
|
||||
if (!file->open(Core::OpenMode::ReadOnly)) {
|
||||
dbgln("failed to open {}, {}", it->value, file->error_string());
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -149,7 +149,7 @@ void GitWidget::show_diff(const LexicalPath& file_path)
|
|||
{
|
||||
if (!m_git_repo->is_tracked(file_path)) {
|
||||
auto file = Core::File::construct(file_path.string());
|
||||
if (!file->open(Core::IODevice::ReadOnly)) {
|
||||
if (!file->open(Core::OpenMode::ReadOnly)) {
|
||||
perror("open");
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
|
|
@ -340,7 +340,7 @@ NonnullRefPtr<GUI::Action> HackStudioWidget::create_new_file_action()
|
|||
filepath = String::formatted("{}{}", filepath, filename);
|
||||
|
||||
auto file = Core::File::construct(filepath);
|
||||
if (!file->open((Core::IODevice::OpenMode)(Core::IODevice::WriteOnly | Core::IODevice::MustBeNew))) {
|
||||
if (!file->open((Core::OpenMode)(Core::OpenMode::WriteOnly | Core::OpenMode::MustBeNew))) {
|
||||
GUI::MessageBox::show(window(), String::formatted("Failed to create '{}'", filepath), "Error", GUI::MessageBox::Type::Error);
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -73,7 +73,7 @@ String FileDB::to_absolute_path(const String& filename) const
|
|||
|
||||
RefPtr<GUI::TextDocument> FileDB::create_from_filesystem(const String& filename) const
|
||||
{
|
||||
auto file = Core::File::open(to_absolute_path(filename), Core::IODevice::ReadOnly);
|
||||
auto file = Core::File::open(to_absolute_path(filename), Core::OpenMode::ReadOnly);
|
||||
if (file.is_error()) {
|
||||
dbgln("failed to create document for {} from filesystem", filename);
|
||||
return nullptr;
|
||||
|
@ -84,7 +84,7 @@ RefPtr<GUI::TextDocument> FileDB::create_from_filesystem(const String& filename)
|
|||
RefPtr<GUI::TextDocument> FileDB::create_from_fd(int fd) const
|
||||
{
|
||||
auto file = Core::File::construct();
|
||||
if (!file->open(fd, Core::IODevice::ReadOnly, Core::File::ShouldCloseFileDescriptor::Yes)) {
|
||||
if (!file->open(fd, Core::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescriptor::Yes)) {
|
||||
errno = file->error();
|
||||
perror("open");
|
||||
dbgln("Failed to open project file");
|
||||
|
|
|
@ -55,7 +55,7 @@ void ProjectFile::create_document_if_needed() const
|
|||
return;
|
||||
|
||||
m_document = CodeDocument::create(m_name);
|
||||
auto file_or_error = Core::File::open(m_name, Core::File::ReadOnly);
|
||||
auto file_or_error = Core::File::open(m_name, Core::OpenMode::ReadOnly);
|
||||
if (file_or_error.is_error()) {
|
||||
warnln("Couldn't open '{}': {}", m_name, file_or_error.error());
|
||||
// This is okay though, we'll just go with an empty document and create the file when saving.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue