diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-09-21 20:50:06 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-09-21 20:50:06 +0200 |
commit | 8d550c174edad68726b8e9c3cd5cd950bf1bf16a (patch) | |
tree | 2c6ed4bd36844e7df4bfc787ea6b23d71902f346 /Applications | |
parent | 31b38ed88f3db123c498379f4615d2dce1ded406 (diff) | |
download | serenity-8d550c174edad68726b8e9c3cd5cd950bf1bf16a.zip |
LibCore: Convert CFile to ObjectPtr
Diffstat (limited to 'Applications')
-rw-r--r-- | Applications/Piano/main.cpp | 8 | ||||
-rw-r--r-- | Applications/SystemMonitor/DevicesModel.cpp | 6 | ||||
-rw-r--r-- | Applications/SystemMonitor/MemoryStatsWidget.cpp | 8 | ||||
-rw-r--r-- | Applications/SystemMonitor/MemoryStatsWidget.h | 2 | ||||
-rw-r--r-- | Applications/SystemMonitor/ProcessStacksWidget.cpp | 8 | ||||
-rw-r--r-- | Applications/TextEditor/TextEditorWidget.cpp | 6 |
6 files changed, 19 insertions, 19 deletions
diff --git a/Applications/Piano/main.cpp b/Applications/Piano/main.cpp index f7a874c58f..e46a92132a 100644 --- a/Applications/Piano/main.cpp +++ b/Applications/Piano/main.cpp @@ -27,16 +27,16 @@ int main(int argc, char** argv) window->set_icon(load_png("/res/icons/16x16/app-piano.png")); LibThread::Thread sound_thread([piano_widget = piano_widget.ptr()] { - CFile audio("/dev/audio"); - if (!audio.open(CIODevice::WriteOnly)) { - dbgprintf("Can't open audio device: %s", audio.error_string()); + auto audio = CFile::construct("/dev/audio"); + if (!audio->open(CIODevice::WriteOnly)) { + dbgprintf("Can't open audio device: %s", audio->error_string()); return 1; } for (;;) { u8 buffer[4096]; piano_widget->fill_audio_buffer(buffer, sizeof(buffer)); - audio.write(buffer, sizeof(buffer)); + audio->write(buffer, sizeof(buffer)); GEventLoop::current().post_event(*piano_widget, make<CCustomEvent>(0)); GEventLoop::wake(); } diff --git a/Applications/SystemMonitor/DevicesModel.cpp b/Applications/SystemMonitor/DevicesModel.cpp index 0e0ff6bab6..fc67e60fc0 100644 --- a/Applications/SystemMonitor/DevicesModel.cpp +++ b/Applications/SystemMonitor/DevicesModel.cpp @@ -95,11 +95,11 @@ GVariant DevicesModel::data(const GModelIndex& index, Role) const void DevicesModel::update() { - CFile proc_devices { "/proc/devices" }; - if (!proc_devices.open(CIODevice::OpenMode::ReadOnly)) + auto proc_devices = CFile::construct("/proc/devices"); + if (!proc_devices->open(CIODevice::OpenMode::ReadOnly)) ASSERT_NOT_REACHED(); - auto json = JsonValue::from_string(proc_devices.read_all()).as_array(); + auto json = JsonValue::from_string(proc_devices->read_all()).as_array(); m_devices.clear(); json.for_each([this](auto& value) { diff --git a/Applications/SystemMonitor/MemoryStatsWidget.cpp b/Applications/SystemMonitor/MemoryStatsWidget.cpp index 889bea9114..1c0594591c 100644 --- a/Applications/SystemMonitor/MemoryStatsWidget.cpp +++ b/Applications/SystemMonitor/MemoryStatsWidget.cpp @@ -11,9 +11,9 @@ MemoryStatsWidget::MemoryStatsWidget(GraphWidget& graph, GWidget* parent) : GWidget(parent) , m_graph(graph) - , m_proc_memstat("/proc/memstat") + , m_proc_memstat(CFile::construct("/proc/memstat")) { - if (!m_proc_memstat.open(CIODevice::OpenMode::ReadOnly)) + if (!m_proc_memstat->open(CIODevice::OpenMode::ReadOnly)) ASSERT_NOT_REACHED(); set_size_policy(SizePolicy::Fill, SizePolicy::Fixed); set_preferred_size(0, 72); @@ -59,9 +59,9 @@ static inline size_t bytes_to_kb(size_t bytes) void MemoryStatsWidget::refresh() { - m_proc_memstat.seek(0); + m_proc_memstat->seek(0); - auto file_contents = m_proc_memstat.read_all(); + auto file_contents = m_proc_memstat->read_all(); auto json = JsonValue::from_string(file_contents).as_object(); unsigned kmalloc_eternal_allocated = json.get("kmalloc_eternal_allocated").to_u32(); diff --git a/Applications/SystemMonitor/MemoryStatsWidget.h b/Applications/SystemMonitor/MemoryStatsWidget.h index 7762da38c9..32b5f27bf6 100644 --- a/Applications/SystemMonitor/MemoryStatsWidget.h +++ b/Applications/SystemMonitor/MemoryStatsWidget.h @@ -22,5 +22,5 @@ private: ObjectPtr<GLabel> m_supervisor_physical_pages_label; ObjectPtr<GLabel> m_kmalloc_label; ObjectPtr<GLabel> m_kmalloc_count_label; - CFile m_proc_memstat; + ObjectPtr<CFile> m_proc_memstat; }; diff --git a/Applications/SystemMonitor/ProcessStacksWidget.cpp b/Applications/SystemMonitor/ProcessStacksWidget.cpp index c54ffba358..73c94c4329 100644 --- a/Applications/SystemMonitor/ProcessStacksWidget.cpp +++ b/Applications/SystemMonitor/ProcessStacksWidget.cpp @@ -28,11 +28,11 @@ void ProcessStacksWidget::set_pid(pid_t pid) void ProcessStacksWidget::refresh() { - CFile file(String::format("/proc/%d/stack", m_pid)); - if (!file.open(CIODevice::ReadOnly)) { - m_stacks_editor->set_text(String::format("Unable to open %s", file.filename().characters())); + auto file = CFile::construct(String::format("/proc/%d/stack", m_pid)); + if (!file->open(CIODevice::ReadOnly)) { + m_stacks_editor->set_text(String::format("Unable to open %s", file->filename().characters())); return; } - m_stacks_editor->set_text(file.read_all()); + m_stacks_editor->set_text(file->read_all()); } diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp index c149b36c06..50ba9b5b4c 100644 --- a/Applications/TextEditor/TextEditorWidget.cpp +++ b/Applications/TextEditor/TextEditorWidget.cpp @@ -270,14 +270,14 @@ void TextEditorWidget::update_title() void TextEditorWidget::open_sesame(const String& path) { - CFile file(path); - if (!file.open(CIODevice::ReadOnly)) { + auto file = CFile::construct(path); + if (!file->open(CIODevice::ReadOnly)) { GMessageBox::show(String::format("Opening \"%s\" failed: %s", path.characters(), strerror(errno)), "Error", GMessageBox::Type::Error, GMessageBox::InputType::OK, window()); return; } m_document_dirty = false; - m_editor->set_text(file.read_all()); + m_editor->set_text(file->read_all()); set_path(FileSystemPath(path)); } |