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

LibCore: Rename File::ShouldCloseFile{Description => Descriptor}

From https://youtu.be/YNSAZIW3EM0?t=1474:

"Hmm... I don't think that name is right! From the perspective of
userspace, this is a file descriptor. File description is what the
kernel internally keeps track of, but as far as userspace is concerned,
he just has a file descriptor. [...] Maybe that name should be changed."

Core::File even has a member of this enum type... called
m_should_close_file_descriptor - so let's just rename it :^)
This commit is contained in:
Linus Groh 2020-10-25 11:31:27 +00:00 committed by Andreas Kling
parent 664794b19e
commit 82956a08b3
9 changed files with 16 additions and 16 deletions

View file

@ -69,11 +69,11 @@ Engine::Engine(const StringView& command)
close(rpipefds[1]); close(rpipefds[1]);
auto infile = Core::File::construct(); auto infile = Core::File::construct();
infile->open(rpipefds[0], Core::IODevice::ReadOnly, Core::File::ShouldCloseFileDescription::Yes); infile->open(rpipefds[0], Core::IODevice::ReadOnly, Core::File::ShouldCloseFileDescriptor::Yes);
set_in(infile); set_in(infile);
auto outfile = Core::File::construct(); auto outfile = Core::File::construct();
outfile->open(wpipefds[1], Core::IODevice::WriteOnly, Core::File::ShouldCloseFileDescription::Yes); outfile->open(wpipefds[1], Core::IODevice::WriteOnly, Core::File::ShouldCloseFileDescriptor::Yes);
set_out(outfile); set_out(outfile);
send_command(Chess::UCI::UCICommand()); send_command(Chess::UCI::UCICommand());

View file

@ -101,7 +101,7 @@ String command(const String& program, const Vector<String>& arguments, Optional<
auto read_all_from_pipe = [](int pipe[2]) { auto read_all_from_pipe = [](int pipe[2]) {
auto result_file = Core::File::construct(); auto result_file = Core::File::construct();
if (!result_file->open(pipe[0], Core::IODevice::ReadOnly, Core::File::ShouldCloseFileDescription::Yes)) { if (!result_file->open(pipe[0], Core::IODevice::ReadOnly, Core::File::ShouldCloseFileDescriptor::Yes)) {
perror("open"); perror("open");
ASSERT_NOT_REACHED(); ASSERT_NOT_REACHED();
} }

View file

@ -55,11 +55,11 @@ File::File(const StringView& filename, Object* parent)
File::~File() File::~File()
{ {
if (m_should_close_file_descriptor == ShouldCloseFileDescription::Yes && mode() != NotOpen) if (m_should_close_file_descriptor == ShouldCloseFileDescriptor::Yes && mode() != NotOpen)
close(); close();
} }
bool File::open(int fd, IODevice::OpenMode mode, ShouldCloseFileDescription should_close) bool File::open(int fd, IODevice::OpenMode mode, ShouldCloseFileDescriptor should_close)
{ {
set_fd(fd); set_fd(fd);
set_mode(mode); set_mode(mode);
@ -245,7 +245,7 @@ NonnullRefPtr<File> File::stdin()
{ {
if (!stdin_file) { if (!stdin_file) {
stdin_file = File::construct(); stdin_file = File::construct();
stdin_file->open(STDIN_FILENO, IODevice::ReadOnly, ShouldCloseFileDescription::No); stdin_file->open(STDIN_FILENO, IODevice::ReadOnly, ShouldCloseFileDescriptor::No);
} }
return *stdin_file; return *stdin_file;
} }
@ -254,7 +254,7 @@ NonnullRefPtr<File> File::stdout()
{ {
if (!stdout_file) { if (!stdout_file) {
stdout_file = File::construct(); stdout_file = File::construct();
stdout_file->open(STDOUT_FILENO, IODevice::WriteOnly, ShouldCloseFileDescription::No); stdout_file->open(STDOUT_FILENO, IODevice::WriteOnly, ShouldCloseFileDescriptor::No);
} }
return *stdout_file; return *stdout_file;
} }
@ -263,7 +263,7 @@ NonnullRefPtr<File> File::stderr()
{ {
if (!stderr_file) { if (!stderr_file) {
stderr_file = File::construct(); stderr_file = File::construct();
stderr_file->open(STDERR_FILENO, IODevice::WriteOnly, ShouldCloseFileDescription::No); stderr_file->open(STDERR_FILENO, IODevice::WriteOnly, ShouldCloseFileDescriptor::No);
} }
return *stderr_file; return *stderr_file;
} }

View file

@ -52,11 +52,11 @@ public:
virtual bool open(IODevice::OpenMode) override; virtual bool open(IODevice::OpenMode) override;
enum class ShouldCloseFileDescription { enum class ShouldCloseFileDescriptor {
No = 0, No = 0,
Yes Yes
}; };
bool open(int fd, IODevice::OpenMode, ShouldCloseFileDescription); bool open(int fd, IODevice::OpenMode, ShouldCloseFileDescriptor);
static NonnullRefPtr<File> stdin(); static NonnullRefPtr<File> stdin();
static NonnullRefPtr<File> stdout(); static NonnullRefPtr<File> stdout();
@ -72,7 +72,7 @@ private:
bool open_impl(IODevice::OpenMode, mode_t); bool open_impl(IODevice::OpenMode, mode_t);
String m_filename; String m_filename;
ShouldCloseFileDescription m_should_close_file_descriptor { ShouldCloseFileDescription::Yes }; ShouldCloseFileDescriptor m_should_close_file_descriptor { ShouldCloseFileDescriptor::Yes };
}; };
} }

View file

@ -54,7 +54,7 @@ int main(int argc, char** argv)
bool success = file->open( bool success = file->open(
STDIN_FILENO, STDIN_FILENO,
Core::IODevice::OpenMode::ReadOnly, Core::IODevice::OpenMode::ReadOnly,
Core::File::ShouldCloseFileDescription::Yes); Core::File::ShouldCloseFileDescriptor::Yes);
ASSERT(success); ASSERT(success);
buffer = file->read_all(); buffer = file->read_all();
} else { } else {

View file

@ -75,7 +75,7 @@ int main(int argc, char** argv)
for (auto path : paths) { for (auto path : paths) {
if (StringView { path } == "-") { if (StringView { path } == "-") {
success = file->open(STDIN_FILENO, Core::IODevice::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescription::No); success = file->open(STDIN_FILENO, Core::IODevice::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescriptor::No);
} else { } else {
file->set_filename(path); file->set_filename(path);
success = file->open(Core::IODevice::OpenMode::ReadOnly); success = file->open(Core::IODevice::OpenMode::ReadOnly);

View file

@ -58,7 +58,7 @@ static Options parse_options(int argc, char* argv[])
bool success = c_stdin->open( bool success = c_stdin->open(
STDIN_FILENO, STDIN_FILENO,
Core::IODevice::OpenMode::ReadOnly, Core::IODevice::OpenMode::ReadOnly,
Core::File::ShouldCloseFileDescription::No); Core::File::ShouldCloseFileDescriptor::No);
ASSERT(success); ASSERT(success);
auto buffer = c_stdin->read_all(); auto buffer = c_stdin->read_all();
dbg() << "Read size " << buffer.size(); dbg() << "Read size " << buffer.size();

View file

@ -44,7 +44,7 @@ int main(int argc, char** argv)
URL url; URL url;
bool success; bool success;
if (argc < 2) { if (argc < 2) {
success = f->open(STDIN_FILENO, Core::IODevice::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescription::No); success = f->open(STDIN_FILENO, Core::IODevice::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescriptor::No);
} else { } else {
url = URL::create_with_file_protocol(argv[1]); url = URL::create_with_file_protocol(argv[1]);
f->set_filename(argv[1]); f->set_filename(argv[1]);

View file

@ -67,7 +67,7 @@ int main(int argc, char* argv[])
auto file = Core::File::construct(); auto file = Core::File::construct();
bool success; bool success;
if (file_name == nullptr) { if (file_name == nullptr) {
success = file->open(STDIN_FILENO, Core::IODevice::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescription::No); success = file->open(STDIN_FILENO, Core::IODevice::OpenMode::ReadOnly, Core::File::ShouldCloseFileDescriptor::No);
} else { } else {
file->set_filename(file_name); file->set_filename(file_name);
success = file->open(Core::IODevice::OpenMode::ReadOnly); success = file->open(Core::IODevice::OpenMode::ReadOnly);