diff options
author | Linus Groh <mail@linusgroh.de> | 2020-10-25 11:31:27 +0000 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-10-25 13:59:41 +0100 |
commit | 82956a08b386206247787bb08ff89b139e54ff1c (patch) | |
tree | fe42d84a6d4d23da00136cd207a126de23b90383 /Libraries/LibCore | |
parent | 664794b19e657fbcd8c7e59c369499cc4b675a44 (diff) | |
download | serenity-82956a08b386206247787bb08ff89b139e54ff1c.zip |
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 :^)
Diffstat (limited to 'Libraries/LibCore')
-rw-r--r-- | Libraries/LibCore/Command.cpp | 2 | ||||
-rw-r--r-- | Libraries/LibCore/File.cpp | 10 | ||||
-rw-r--r-- | Libraries/LibCore/File.h | 6 |
3 files changed, 9 insertions, 9 deletions
diff --git a/Libraries/LibCore/Command.cpp b/Libraries/LibCore/Command.cpp index 5ecc5d940d..61ed2178f8 100644 --- a/Libraries/LibCore/Command.cpp +++ b/Libraries/LibCore/Command.cpp @@ -101,7 +101,7 @@ String command(const String& program, const Vector<String>& arguments, Optional< auto read_all_from_pipe = [](int pipe[2]) { 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"); ASSERT_NOT_REACHED(); } diff --git a/Libraries/LibCore/File.cpp b/Libraries/LibCore/File.cpp index 0aa317ead2..81d9513c31 100644 --- a/Libraries/LibCore/File.cpp +++ b/Libraries/LibCore/File.cpp @@ -55,11 +55,11 @@ File::File(const StringView& filename, Object* parent) File::~File() { - if (m_should_close_file_descriptor == ShouldCloseFileDescription::Yes && mode() != NotOpen) + if (m_should_close_file_descriptor == ShouldCloseFileDescriptor::Yes && mode() != NotOpen) 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_mode(mode); @@ -245,7 +245,7 @@ NonnullRefPtr<File> File::stdin() { if (!stdin_file) { 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; } @@ -254,7 +254,7 @@ NonnullRefPtr<File> File::stdout() { if (!stdout_file) { 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; } @@ -263,7 +263,7 @@ NonnullRefPtr<File> File::stderr() { if (!stderr_file) { 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; } diff --git a/Libraries/LibCore/File.h b/Libraries/LibCore/File.h index 3fdbc04496..de328957aa 100644 --- a/Libraries/LibCore/File.h +++ b/Libraries/LibCore/File.h @@ -52,11 +52,11 @@ public: virtual bool open(IODevice::OpenMode) override; - enum class ShouldCloseFileDescription { + enum class ShouldCloseFileDescriptor { No = 0, Yes }; - bool open(int fd, IODevice::OpenMode, ShouldCloseFileDescription); + bool open(int fd, IODevice::OpenMode, ShouldCloseFileDescriptor); static NonnullRefPtr<File> stdin(); static NonnullRefPtr<File> stdout(); @@ -72,7 +72,7 @@ private: bool open_impl(IODevice::OpenMode, mode_t); String m_filename; - ShouldCloseFileDescription m_should_close_file_descriptor { ShouldCloseFileDescription::Yes }; + ShouldCloseFileDescriptor m_should_close_file_descriptor { ShouldCloseFileDescriptor::Yes }; }; } |