From 8d550c174edad68726b8e9c3cd5cd950bf1bf16a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 21 Sep 2019 20:50:06 +0200 Subject: LibCore: Convert CFile to ObjectPtr --- Servers/AudioServer/ASMixer.cpp | 8 ++++---- Servers/AudioServer/ASMixer.h | 2 +- Servers/LookupServer/main.cpp | 8 ++++---- Servers/SystemServer/main.cpp | 8 ++++---- 4 files changed, 13 insertions(+), 13 deletions(-) (limited to 'Servers') diff --git a/Servers/AudioServer/ASMixer.cpp b/Servers/AudioServer/ASMixer.cpp index 1b5219d171..7ca7839bf6 100644 --- a/Servers/AudioServer/ASMixer.cpp +++ b/Servers/AudioServer/ASMixer.cpp @@ -4,14 +4,14 @@ #include ASMixer::ASMixer() - : m_device("/dev/audio", this) + : m_device(CFile::construct("/dev/audio", this)) , m_sound_thread([this] { mix(); return 0; }) { - if (!m_device.open(CIODevice::WriteOnly)) { - dbgprintf("Can't open audio device: %s\n", m_device.error_string()); + if (!m_device->open(CIODevice::WriteOnly)) { + dbgprintf("Can't open audio device: %s\n", m_device->error_string()); return; } @@ -88,7 +88,7 @@ void ASMixer::mix() if (stream.offset() != 0) { buffer.trim(stream.offset()); - m_device.write(buffer); + m_device->write(buffer); } } } diff --git a/Servers/AudioServer/ASMixer.h b/Servers/AudioServer/ASMixer.h index 0f2e869c05..9dfa618217 100644 --- a/Servers/AudioServer/ASMixer.h +++ b/Servers/AudioServer/ASMixer.h @@ -63,7 +63,7 @@ public: private: Vector> m_pending_mixing; - CFile m_device; + ObjectPtr m_device; LibThread::Lock m_lock; LibThread::Thread m_sound_thread; diff --git a/Servers/LookupServer/main.cpp b/Servers/LookupServer/main.cpp index 740657d53d..1c3dec89c5 100644 --- a/Servers/LookupServer/main.cpp +++ b/Servers/LookupServer/main.cpp @@ -35,11 +35,11 @@ static String parse_dns_name(const u8*, int& offset, int max_offset); static void load_etc_hosts() { dbgprintf("LookupServer: Loading hosts from /etc/hosts\n"); - CFile file("/etc/hosts"); - if (!file.open(CIODevice::ReadOnly)) + auto file = CFile::construct("/etc/hosts"); + if (!file->open(CIODevice::ReadOnly)) return; - while (!file.eof()) { - auto line = file.read_line(1024); + while (!file->eof()) { + auto line = file->read_line(1024); if (line.is_empty()) break; auto str_line = String((const char*)line.pointer(), line.size() - 1, Chomp); diff --git a/Servers/SystemServer/main.cpp b/Servers/SystemServer/main.cpp index a70d70bbd1..68974780c6 100644 --- a/Servers/SystemServer/main.cpp +++ b/Servers/SystemServer/main.cpp @@ -58,12 +58,12 @@ void start_process(const String& program, const Vector& arguments, int p static void check_for_test_mode() { - CFile f("/proc/cmdline"); - if (!f.open(CIODevice::ReadOnly)) { - dbg() << "Failed to read command line: " << f.error_string(); + auto f = CFile::construct("/proc/cmdline"); + if (!f->open(CIODevice::ReadOnly)) { + dbg() << "Failed to read command line: " << f->error_string(); ASSERT(false); } - const String cmd = String::copy(f.read_all()); + const String cmd = String::copy(f->read_all()); dbg() << "Read command line: " << cmd; if (cmd.matches("*testmode=1*")) { // Eventually, we should run a test binary and wait for it to finish -- cgit v1.2.3