mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 18:17:45 +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
|
@ -20,7 +20,7 @@ static constexpr size_t maximum_wav_size = 1 * GiB; // FIXME: is there a more ap
|
|||
WavLoaderPlugin::WavLoaderPlugin(const StringView& path)
|
||||
: m_file(Core::File::construct(path))
|
||||
{
|
||||
if (!m_file->open(Core::IODevice::ReadOnly)) {
|
||||
if (!m_file->open(Core::OpenMode::ReadOnly)) {
|
||||
m_error_string = String::formatted("Can't open file: {}", m_file->error_string());
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ WavWriter::~WavWriter()
|
|||
void WavWriter::set_file(const StringView& path)
|
||||
{
|
||||
m_file = Core::File::construct(path);
|
||||
if (!m_file->open(Core::IODevice::ReadWrite)) {
|
||||
if (!m_file->open(Core::OpenMode::ReadWrite)) {
|
||||
m_error_string = String::formatted("Can't open file: {}", m_file->error_string());
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ String command(const String& program, const Vector<String>& arguments, Optional<
|
|||
|
||||
auto read_all_from_pipe = [](int pipe[2]) {
|
||||
auto result_file = Core::File::construct();
|
||||
if (!result_file->open(pipe[0], Core::IODevice::ReadOnly, Core::File::ShouldCloseFileDescriptor::Yes)) {
|
||||
if (!result_file->open(pipe[0], Core::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescriptor::Yes)) {
|
||||
perror("open");
|
||||
VERIFY_NOT_REACHED();
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ void ConfigFile::reparse()
|
|||
m_groups.clear();
|
||||
|
||||
auto file = File::construct(m_filename);
|
||||
if (!file->open(IODevice::OpenMode::ReadOnly))
|
||||
if (!file->open(OpenMode::ReadOnly))
|
||||
return;
|
||||
|
||||
HashMap<String, String>* current_group = nullptr;
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
namespace Core {
|
||||
|
||||
Result<NonnullRefPtr<File>, String> File::open(String filename, IODevice::OpenMode mode, mode_t permissions)
|
||||
Result<NonnullRefPtr<File>, String> File::open(String filename, OpenMode mode, mode_t permissions)
|
||||
{
|
||||
auto file = File::construct(move(filename));
|
||||
if (!file->open_impl(mode, permissions))
|
||||
|
@ -42,11 +42,11 @@ File::File(String filename, Object* parent)
|
|||
|
||||
File::~File()
|
||||
{
|
||||
if (m_should_close_file_descriptor == ShouldCloseFileDescriptor::Yes && mode() != NotOpen)
|
||||
if (m_should_close_file_descriptor == ShouldCloseFileDescriptor::Yes && mode() != OpenMode::NotOpen)
|
||||
close();
|
||||
}
|
||||
|
||||
bool File::open(int fd, IODevice::OpenMode mode, ShouldCloseFileDescriptor should_close)
|
||||
bool File::open(int fd, OpenMode mode, ShouldCloseFileDescriptor should_close)
|
||||
{
|
||||
set_fd(fd);
|
||||
set_mode(mode);
|
||||
|
@ -54,30 +54,30 @@ bool File::open(int fd, IODevice::OpenMode mode, ShouldCloseFileDescriptor shoul
|
|||
return true;
|
||||
}
|
||||
|
||||
bool File::open(IODevice::OpenMode mode)
|
||||
bool File::open(OpenMode mode)
|
||||
{
|
||||
return open_impl(mode, 0666);
|
||||
}
|
||||
|
||||
bool File::open_impl(IODevice::OpenMode mode, mode_t permissions)
|
||||
bool File::open_impl(OpenMode mode, mode_t permissions)
|
||||
{
|
||||
VERIFY(!m_filename.is_null());
|
||||
int flags = 0;
|
||||
if ((mode & IODevice::ReadWrite) == IODevice::ReadWrite) {
|
||||
if (has_flag(mode, OpenMode::ReadWrite)) {
|
||||
flags |= O_RDWR | O_CREAT;
|
||||
} else if (mode & IODevice::ReadOnly) {
|
||||
} else if (has_flag(mode, OpenMode::ReadOnly)) {
|
||||
flags |= O_RDONLY;
|
||||
} else if (mode & IODevice::WriteOnly) {
|
||||
} else if (has_flag(mode, OpenMode::WriteOnly)) {
|
||||
flags |= O_WRONLY | O_CREAT;
|
||||
bool should_truncate = !((mode & IODevice::Append) || (mode & IODevice::MustBeNew));
|
||||
bool should_truncate = !(has_flag(mode, OpenMode::Append) || has_flag(mode, OpenMode::MustBeNew));
|
||||
if (should_truncate)
|
||||
flags |= O_TRUNC;
|
||||
}
|
||||
if (mode & IODevice::Append)
|
||||
if (has_flag(mode, OpenMode::Append))
|
||||
flags |= O_APPEND;
|
||||
if (mode & IODevice::Truncate)
|
||||
if (has_flag(mode, OpenMode::Truncate))
|
||||
flags |= O_TRUNC;
|
||||
if (mode & IODevice::MustBeNew)
|
||||
if (has_flag(mode, OpenMode::MustBeNew))
|
||||
flags |= O_EXCL;
|
||||
int fd = ::open(m_filename.characters(), flags, permissions);
|
||||
if (fd < 0) {
|
||||
|
@ -238,7 +238,7 @@ NonnullRefPtr<File> File::standard_input()
|
|||
{
|
||||
if (!stdin_file) {
|
||||
stdin_file = File::construct();
|
||||
stdin_file->open(STDIN_FILENO, IODevice::ReadOnly, ShouldCloseFileDescriptor::No);
|
||||
stdin_file->open(STDIN_FILENO, OpenMode::ReadOnly, ShouldCloseFileDescriptor::No);
|
||||
}
|
||||
return *stdin_file;
|
||||
}
|
||||
|
@ -247,7 +247,7 @@ NonnullRefPtr<File> File::standard_output()
|
|||
{
|
||||
if (!stdout_file) {
|
||||
stdout_file = File::construct();
|
||||
stdout_file->open(STDOUT_FILENO, IODevice::WriteOnly, ShouldCloseFileDescriptor::No);
|
||||
stdout_file->open(STDOUT_FILENO, OpenMode::WriteOnly, ShouldCloseFileDescriptor::No);
|
||||
}
|
||||
return *stdout_file;
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ NonnullRefPtr<File> File::standard_error()
|
|||
{
|
||||
if (!stderr_file) {
|
||||
stderr_file = File::construct();
|
||||
stderr_file->open(STDERR_FILENO, IODevice::WriteOnly, ShouldCloseFileDescriptor::No);
|
||||
stderr_file->open(STDERR_FILENO, OpenMode::WriteOnly, ShouldCloseFileDescriptor::No);
|
||||
}
|
||||
return *stderr_file;
|
||||
}
|
||||
|
@ -297,7 +297,7 @@ Result<void, File::CopyError> File::copy_file_or_directory(const String& dst_pat
|
|||
}
|
||||
}
|
||||
|
||||
auto source_or_error = File::open(src_path, IODevice::ReadOnly);
|
||||
auto source_or_error = File::open(src_path, OpenMode::ReadOnly);
|
||||
if (source_or_error.is_error())
|
||||
return CopyError { OSError(errno), false };
|
||||
|
||||
|
|
|
@ -19,7 +19,7 @@ class File final : public IODevice {
|
|||
public:
|
||||
virtual ~File() override;
|
||||
|
||||
static Result<NonnullRefPtr<File>, String> open(String filename, IODevice::OpenMode, mode_t = 0644);
|
||||
static Result<NonnullRefPtr<File>, String> open(String filename, OpenMode, mode_t = 0644);
|
||||
|
||||
String filename() const { return m_filename; }
|
||||
void set_filename(const String filename) { m_filename = move(filename); }
|
||||
|
@ -67,13 +67,13 @@ public:
|
|||
};
|
||||
static Result<void, RemoveError> remove(const String& path, RecursionMode, bool force);
|
||||
|
||||
virtual bool open(IODevice::OpenMode) override;
|
||||
virtual bool open(OpenMode) override;
|
||||
|
||||
enum class ShouldCloseFileDescriptor {
|
||||
No = 0,
|
||||
Yes
|
||||
};
|
||||
bool open(int fd, IODevice::OpenMode, ShouldCloseFileDescriptor);
|
||||
bool open(int fd, OpenMode, ShouldCloseFileDescriptor);
|
||||
|
||||
static NonnullRefPtr<File> standard_input();
|
||||
static NonnullRefPtr<File> standard_output();
|
||||
|
@ -86,7 +86,7 @@ private:
|
|||
}
|
||||
explicit File(String filename, Object* parent = nullptr);
|
||||
|
||||
bool open_impl(IODevice::OpenMode, mode_t);
|
||||
bool open_impl(OpenMode, mode_t);
|
||||
|
||||
String m_filename;
|
||||
ShouldCloseFileDescriptor m_should_close_file_descriptor { ShouldCloseFileDescriptor::Yes };
|
||||
|
|
|
@ -20,9 +20,9 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
static Result<InputFileStream, String> open(StringView filename, IODevice::OpenMode mode = IODevice::OpenMode::ReadOnly, mode_t permissions = 0644)
|
||||
static Result<InputFileStream, String> open(StringView filename, OpenMode mode = OpenMode::ReadOnly, mode_t permissions = 0644)
|
||||
{
|
||||
VERIFY((mode & 0xf) == IODevice::OpenMode::ReadOnly || (mode & 0xf) == IODevice::OpenMode::ReadWrite);
|
||||
VERIFY(has_flag(mode, OpenMode::ReadOnly));
|
||||
|
||||
auto file_result = File::open(filename, mode, permissions);
|
||||
|
||||
|
@ -32,9 +32,9 @@ public:
|
|||
return InputFileStream { file_result.value() };
|
||||
}
|
||||
|
||||
static Result<Buffered<InputFileStream>, String> open_buffered(StringView filename, IODevice::OpenMode mode = IODevice::OpenMode::ReadOnly, mode_t permissions = 0644)
|
||||
static Result<Buffered<InputFileStream>, String> open_buffered(StringView filename, OpenMode mode = OpenMode::ReadOnly, mode_t permissions = 0644)
|
||||
{
|
||||
VERIFY((mode & 0xf) == IODevice::OpenMode::ReadOnly || (mode & 0xf) == IODevice::OpenMode::ReadWrite);
|
||||
VERIFY(has_flag(mode, OpenMode::ReadOnly));
|
||||
|
||||
auto file_result = File::open(filename, mode, permissions);
|
||||
|
||||
|
@ -84,9 +84,9 @@ public:
|
|||
{
|
||||
}
|
||||
|
||||
static Result<OutputFileStream, String> open(StringView filename, IODevice::OpenMode mode = IODevice::OpenMode::WriteOnly, mode_t permissions = 0644)
|
||||
static Result<OutputFileStream, String> open(StringView filename, OpenMode mode = OpenMode::WriteOnly, mode_t permissions = 0644)
|
||||
{
|
||||
VERIFY((mode & 0xf) == IODevice::OpenMode::WriteOnly || (mode & 0xf) == IODevice::OpenMode::ReadWrite);
|
||||
VERIFY(has_flag(mode, OpenMode::WriteOnly));
|
||||
|
||||
auto file_result = File::open(filename, mode, permissions);
|
||||
|
||||
|
@ -96,9 +96,9 @@ public:
|
|||
return OutputFileStream { file_result.value() };
|
||||
}
|
||||
|
||||
static Result<Buffered<OutputFileStream>, String> open_buffered(StringView filename, IODevice::OpenMode mode = IODevice::OpenMode::WriteOnly, mode_t permissions = 0644)
|
||||
static Result<Buffered<OutputFileStream>, String> open_buffered(StringView filename, OpenMode mode = OpenMode::WriteOnly, mode_t permissions = 0644)
|
||||
{
|
||||
VERIFY((mode & 0xf) == IODevice::OpenMode::WriteOnly || (mode & 0xf) == IODevice::OpenMode::ReadWrite);
|
||||
VERIFY(has_flag(mode, OpenMode::WriteOnly));
|
||||
|
||||
auto file_result = File::open(filename, mode, permissions);
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ bool IODevice::populate_read_buffer() const
|
|||
|
||||
bool IODevice::close()
|
||||
{
|
||||
if (fd() < 0 || mode() == NotOpen)
|
||||
if (fd() < 0 || m_mode == OpenMode::NotOpen)
|
||||
return false;
|
||||
int rc = ::close(fd());
|
||||
if (rc < 0) {
|
||||
|
@ -217,7 +217,7 @@ bool IODevice::close()
|
|||
return false;
|
||||
}
|
||||
set_fd(-1);
|
||||
set_mode(IODevice::NotOpen);
|
||||
set_mode(OpenMode::NotOpen);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <AK/EnumBits.h>
|
||||
#include <AK/Forward.h>
|
||||
#include <LibCore/Object.h>
|
||||
|
||||
|
@ -33,24 +34,26 @@ private:
|
|||
String m_buffer;
|
||||
};
|
||||
|
||||
enum class OpenMode : unsigned {
|
||||
NotOpen = 0,
|
||||
ReadOnly = 1,
|
||||
WriteOnly = 2,
|
||||
ReadWrite = 3,
|
||||
Append = 4,
|
||||
Truncate = 8,
|
||||
MustBeNew = 16,
|
||||
};
|
||||
|
||||
AK_ENUM_BITWISE_OPERATORS(OpenMode)
|
||||
|
||||
class IODevice : public Object {
|
||||
C_OBJECT_ABSTRACT(IODevice)
|
||||
public:
|
||||
enum OpenMode {
|
||||
NotOpen = 0,
|
||||
ReadOnly = 1,
|
||||
WriteOnly = 2,
|
||||
ReadWrite = 3,
|
||||
Append = 4,
|
||||
Truncate = 8,
|
||||
MustBeNew = 16,
|
||||
};
|
||||
|
||||
virtual ~IODevice() override;
|
||||
|
||||
int fd() const { return m_fd; }
|
||||
unsigned mode() const { return m_mode; }
|
||||
bool is_open() const { return m_mode != NotOpen; }
|
||||
OpenMode mode() const { return m_mode; }
|
||||
bool is_open() const { return m_mode != OpenMode::NotOpen; }
|
||||
bool eof() const { return m_eof; }
|
||||
|
||||
int error() const { return m_error; }
|
||||
|
@ -81,7 +84,7 @@ public:
|
|||
|
||||
bool seek(i64, SeekMode = SeekMode::SetPosition, off_t* = nullptr);
|
||||
|
||||
virtual bool open(IODevice::OpenMode) = 0;
|
||||
virtual bool open(OpenMode) = 0;
|
||||
virtual bool close();
|
||||
|
||||
LineIterator line_begin() & { return LineIterator(*this); }
|
||||
|
@ -102,7 +105,7 @@ private:
|
|||
bool can_read_from_fd() const;
|
||||
|
||||
int m_fd { -1 };
|
||||
OpenMode m_mode { NotOpen };
|
||||
OpenMode m_mode { OpenMode::NotOpen };
|
||||
mutable int m_error { 0 };
|
||||
mutable bool m_eof { false };
|
||||
mutable Vector<u8> m_buffered_data;
|
||||
|
|
|
@ -24,7 +24,7 @@ LocalSocket::LocalSocket(int fd, Object* parent)
|
|||
// NOTE: This constructor is used by LocalServer::accept(), so the socket is already connected.
|
||||
m_connected = true;
|
||||
set_fd(fd);
|
||||
set_mode(IODevice::ReadWrite);
|
||||
set_mode(OpenMode::ReadWrite);
|
||||
set_error(0);
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ LocalSocket::LocalSocket(Object* parent)
|
|||
set_error(errno);
|
||||
} else {
|
||||
set_fd(fd);
|
||||
set_mode(IODevice::ReadWrite);
|
||||
set_mode(OpenMode::ReadWrite);
|
||||
set_error(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ Optional<HashMap<pid_t, Core::ProcessStatistics>> ProcessStatisticsReader::get_a
|
|||
}
|
||||
} else {
|
||||
proc_all_file = Core::File::construct("/proc/all");
|
||||
if (!proc_all_file->open(Core::IODevice::ReadOnly)) {
|
||||
if (!proc_all_file->open(Core::OpenMode::ReadOnly)) {
|
||||
fprintf(stderr, "ProcessStatisticsReader: Failed to open /proc/all: %s\n", proc_all_file->error_string());
|
||||
return {};
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ protected:
|
|||
virtual bool common_connect(const struct sockaddr*, socklen_t);
|
||||
|
||||
private:
|
||||
virtual bool open(IODevice::OpenMode) override { VERIFY_NOT_REACHED(); }
|
||||
virtual bool open(OpenMode) override { VERIFY_NOT_REACHED(); }
|
||||
void ensure_read_notifier();
|
||||
|
||||
Type m_type { Type::Invalid };
|
||||
|
|
|
@ -20,7 +20,7 @@ TCPSocket::TCPSocket(int fd, Object* parent)
|
|||
// NOTE: This constructor is used by TCPServer::accept(), so the socket is already connected.
|
||||
m_connected = true;
|
||||
set_fd(fd);
|
||||
set_mode(IODevice::ReadWrite);
|
||||
set_mode(OpenMode::ReadWrite);
|
||||
set_error(0);
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ TCPSocket::TCPSocket(Object* parent)
|
|||
set_error(errno);
|
||||
} else {
|
||||
set_fd(fd);
|
||||
set_mode(IODevice::ReadWrite);
|
||||
set_mode(OpenMode::ReadWrite);
|
||||
set_error(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ UDPSocket::UDPSocket(Object* parent)
|
|||
set_error(errno);
|
||||
} else {
|
||||
set_fd(fd);
|
||||
set_mode(IODevice::ReadWrite);
|
||||
set_mode(OpenMode::ReadWrite);
|
||||
set_error(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -392,7 +392,7 @@ Optional<DebugSession::InsertBreakpointAtSourcePositionResult> DebugSession::ins
|
|||
void DebugSession::update_loaded_libs()
|
||||
{
|
||||
auto file = Core::File::construct(String::formatted("/proc/{}/vm", m_debuggee_pid));
|
||||
bool rc = file->open(Core::IODevice::ReadOnly);
|
||||
bool rc = file->open(Core::OpenMode::ReadOnly);
|
||||
VERIFY(rc);
|
||||
|
||||
auto file_contents = file->read_all();
|
||||
|
|
|
@ -41,7 +41,7 @@ static void initialize_if_needed()
|
|||
void CommonLocationsProvider::load_from_json(const String& json_path)
|
||||
{
|
||||
auto file = Core::File::construct(json_path);
|
||||
if (!file->open(Core::IODevice::ReadOnly)) {
|
||||
if (!file->open(Core::OpenMode::ReadOnly)) {
|
||||
dbgln("Unable to open {}", file->filename());
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace GUI {
|
|||
void JsonArrayModel::update()
|
||||
{
|
||||
auto file = Core::File::construct(m_json_path);
|
||||
if (!file->open(Core::IODevice::ReadOnly)) {
|
||||
if (!file->open(Core::OpenMode::ReadOnly)) {
|
||||
dbgln("Unable to open {}", file->filename());
|
||||
m_array.clear();
|
||||
did_update();
|
||||
|
@ -32,7 +32,7 @@ void JsonArrayModel::update()
|
|||
bool JsonArrayModel::store()
|
||||
{
|
||||
auto file = Core::File::construct(m_json_path);
|
||||
if (!file->open(Core::IODevice::WriteOnly)) {
|
||||
if (!file->open(Core::OpenMode::WriteOnly)) {
|
||||
dbgln("Unable to open {}", file->filename());
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ Optional<CharacterMapData> CharacterMapFile::load_from_file(const String& filena
|
|||
}
|
||||
|
||||
auto file = Core::File::construct(path);
|
||||
file->open(Core::IODevice::ReadOnly);
|
||||
file->open(Core::OpenMode::ReadOnly);
|
||||
if (!file->is_open()) {
|
||||
dbgln("Failed to open {}: {}", filename, file->error_string());
|
||||
return {};
|
||||
|
|
|
@ -220,7 +220,7 @@ void Editor::add_to_history(const String& line)
|
|||
bool Editor::load_history(const String& path)
|
||||
{
|
||||
auto history_file = Core::File::construct(path);
|
||||
if (!history_file->open(Core::IODevice::ReadOnly))
|
||||
if (!history_file->open(Core::OpenMode::ReadOnly))
|
||||
return false;
|
||||
auto data = history_file->read_all();
|
||||
auto hist = StringView { data.data(), data.size() };
|
||||
|
@ -279,7 +279,7 @@ bool Editor::save_history(const String& path)
|
|||
{
|
||||
Vector<HistoryEntry> final_history { { "", 0 } };
|
||||
{
|
||||
auto file_or_error = Core::File::open(path, Core::IODevice::ReadWrite, 0600);
|
||||
auto file_or_error = Core::File::open(path, Core::OpenMode::ReadWrite, 0600);
|
||||
if (file_or_error.is_error())
|
||||
return false;
|
||||
auto file = file_or_error.release_value();
|
||||
|
@ -294,7 +294,7 @@ bool Editor::save_history(const String& path)
|
|||
[](const HistoryEntry& left, const HistoryEntry& right) { return left.timestamp < right.timestamp; });
|
||||
}
|
||||
|
||||
auto file_or_error = Core::File::open(path, Core::IODevice::WriteOnly, 0600);
|
||||
auto file_or_error = Core::File::open(path, Core::OpenMode::WriteOnly, 0600);
|
||||
if (file_or_error.is_error())
|
||||
return false;
|
||||
auto file = file_or_error.release_value();
|
||||
|
|
|
@ -569,7 +569,7 @@ void Editor::edit_in_external_editor()
|
|||
}
|
||||
|
||||
{
|
||||
auto file_or_error = Core::File::open(file_path, Core::IODevice::OpenMode::ReadOnly);
|
||||
auto file_or_error = Core::File::open(file_path, Core::OpenMode::ReadOnly);
|
||||
if (file_or_error.is_error())
|
||||
return;
|
||||
|
||||
|
|
|
@ -63,7 +63,7 @@ Vector<Symbol> symbolicate_thread(pid_t pid, pid_t tid)
|
|||
{
|
||||
|
||||
auto stack_path = String::formatted("/proc/{}/stacks/{}", pid, tid);
|
||||
auto file_or_error = Core::File::open(stack_path, Core::IODevice::ReadOnly);
|
||||
auto file_or_error = Core::File::open(stack_path, Core::OpenMode::ReadOnly);
|
||||
if (file_or_error.is_error()) {
|
||||
warnln("Could not open {}: {}", stack_path, file_or_error.error());
|
||||
return {};
|
||||
|
@ -83,7 +83,7 @@ Vector<Symbol> symbolicate_thread(pid_t pid, pid_t tid)
|
|||
|
||||
{
|
||||
auto vm_path = String::formatted("/proc/{}/vm", pid);
|
||||
auto file_or_error = Core::File::open(vm_path, Core::IODevice::ReadOnly);
|
||||
auto file_or_error = Core::File::open(vm_path, Core::OpenMode::ReadOnly);
|
||||
if (file_or_error.is_error()) {
|
||||
warnln("Could not open {}: {}", vm_path, file_or_error.error());
|
||||
return {};
|
||||
|
|
|
@ -867,7 +867,7 @@ TLSv12::TLSv12(Core::Object* parent, Options options)
|
|||
set_error(errno);
|
||||
} else {
|
||||
set_fd(fd);
|
||||
set_mode(IODevice::ReadWrite);
|
||||
set_mode(Core::OpenMode::ReadWrite);
|
||||
set_error(0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -207,13 +207,13 @@ GlyphHorizontalMetrics Hmtx::get_glyph_horizontal_metrics(u32 glyph_id) const
|
|||
|
||||
RefPtr<Font> Font::load_from_file(String path, unsigned index)
|
||||
{
|
||||
auto file_or_error = Core::File::open(move(path), Core::IODevice::ReadOnly);
|
||||
auto file_or_error = Core::File::open(move(path), Core::OpenMode::ReadOnly);
|
||||
if (file_or_error.is_error()) {
|
||||
dbgln("Could not open file: {}", file_or_error.error());
|
||||
return nullptr;
|
||||
}
|
||||
auto file = file_or_error.value();
|
||||
if (!file->open(Core::IODevice::ReadOnly)) {
|
||||
if (!file->open(Core::OpenMode::ReadOnly)) {
|
||||
dbgln("Could not open file");
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
auto file = Core::File::construct(argv[1]);
|
||||
if (!file->open(Core::IODevice::ReadOnly))
|
||||
if (!file->open(Core::OpenMode::ReadOnly))
|
||||
return 1;
|
||||
|
||||
auto json = JsonValue::from_string(file->read_all());
|
||||
|
|
|
@ -34,7 +34,7 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
auto file = Core::File::construct(argv[1]);
|
||||
if (!file->open(Core::IODevice::ReadOnly))
|
||||
if (!file->open(Core::OpenMode::ReadOnly))
|
||||
return 1;
|
||||
|
||||
auto json = JsonValue::from_string(file->read_all());
|
||||
|
|
|
@ -34,7 +34,7 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
auto file = Core::File::construct(argv[1]);
|
||||
if (!file->open(Core::IODevice::ReadOnly))
|
||||
if (!file->open(Core::OpenMode::ReadOnly))
|
||||
return 1;
|
||||
|
||||
auto json = JsonValue::from_string(file->read_all());
|
||||
|
|
|
@ -34,7 +34,7 @@ int main(int argc, char** argv)
|
|||
return 1;
|
||||
}
|
||||
auto file = Core::File::construct(argv[1]);
|
||||
if (!file->open(Core::IODevice::ReadOnly))
|
||||
if (!file->open(Core::OpenMode::ReadOnly))
|
||||
return 1;
|
||||
|
||||
auto json = JsonValue::from_string(file->read_all());
|
||||
|
|
|
@ -394,7 +394,7 @@ int main(int argc, char** argv)
|
|||
args_parser.add_positional_argument(path, "IDL file", "idl-file");
|
||||
args_parser.parse(argc, argv);
|
||||
|
||||
auto file_or_error = Core::File::open(path, Core::IODevice::ReadOnly);
|
||||
auto file_or_error = Core::File::open(path, Core::OpenMode::ReadOnly);
|
||||
if (file_or_error.is_error()) {
|
||||
fprintf(stderr, "Cannot open %s\n", path);
|
||||
return 1;
|
||||
|
|
|
@ -133,7 +133,7 @@ void ResourceLoader::load(const LoadRequest& request, Function<void(ReadonlyByte
|
|||
if (url.protocol() == "file") {
|
||||
auto f = Core::File::construct();
|
||||
f->set_filename(url.path());
|
||||
if (!f->open(Core::IODevice::OpenMode::ReadOnly)) {
|
||||
if (!f->open(Core::OpenMode::ReadOnly)) {
|
||||
dbgln("ResourceLoader::load: Error: {}", f->error_string());
|
||||
if (error_callback)
|
||||
error_callback(f->error_string(), {});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue