summaryrefslogtreecommitdiff
path: root/Servers
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-09-21 20:50:06 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-09-21 20:50:06 +0200
commit8d550c174edad68726b8e9c3cd5cd950bf1bf16a (patch)
tree2c6ed4bd36844e7df4bfc787ea6b23d71902f346 /Servers
parent31b38ed88f3db123c498379f4615d2dce1ded406 (diff)
downloadserenity-8d550c174edad68726b8e9c3cd5cd950bf1bf16a.zip
LibCore: Convert CFile to ObjectPtr
Diffstat (limited to 'Servers')
-rw-r--r--Servers/AudioServer/ASMixer.cpp8
-rw-r--r--Servers/AudioServer/ASMixer.h2
-rw-r--r--Servers/LookupServer/main.cpp8
-rw-r--r--Servers/SystemServer/main.cpp8
4 files changed, 13 insertions, 13 deletions
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 <limits>
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<NonnullRefPtr<ASBufferQueue>> m_pending_mixing;
- CFile m_device;
+ ObjectPtr<CFile> 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<String>& 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