1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:07:35 +00:00

LibCore: Convert CFile to ObjectPtr

This commit is contained in:
Andreas Kling 2019-09-21 20:50:06 +02:00
parent 31b38ed88f
commit 8d550c174e
30 changed files with 135 additions and 134 deletions

View file

@ -17,14 +17,14 @@ static String read_var(const String& name)
builder.append("/proc/sys/");
builder.append(name);
auto path = builder.to_string();
CFile f(path);
if (!f.open(CIODevice::ReadOnly)) {
fprintf(stderr, "open: %s", f.error_string());
auto f = CFile::construct(path);
if (!f->open(CIODevice::ReadOnly)) {
fprintf(stderr, "open: %s", f->error_string());
exit(1);
}
const auto& b = f.read_all();
if (f.error() < 0) {
fprintf(stderr, "read: %s", f.error_string());
const auto& b = f->read_all();
if (f->error() < 0) {
fprintf(stderr, "read: %s", f->error_string());
exit(1);
}
return String((const char*)b.pointer(), b.size(), Chomp);
@ -36,14 +36,14 @@ static void write_var(const String& name, const String& value)
builder.append("/proc/sys/");
builder.append(name);
auto path = builder.to_string();
CFile f(path);
if (!f.open(CIODevice::WriteOnly)) {
fprintf(stderr, "open: %s", f.error_string());
auto f = CFile::construct(path);
if (!f->open(CIODevice::WriteOnly)) {
fprintf(stderr, "open: %s", f->error_string());
exit(1);
}
f.write(value);
if (f.error() < 0) {
fprintf(stderr, "write: %s", f.error_string());
f->write(value);
if (f->error() < 0) {
fprintf(stderr, "write: %s", f->error_string());
exit(1);
}
}