diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-04-26 02:22:21 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-04-26 02:22:21 +0200 |
commit | 0a68e0046fe01ada175cb4813be6ab5fb447d35b (patch) | |
tree | 99f0f581b161a29bf818272603a7815a9b06882f /LibCore/CFile.cpp | |
parent | c392c0d799d763edee18a452c189c48376a4f33f (diff) | |
download | serenity-0a68e0046fe01ada175cb4813be6ab5fb447d35b.zip |
LibCore: Make it possible to create a CFile for an existing file descriptor.
Diffstat (limited to 'LibCore/CFile.cpp')
-rw-r--r-- | LibCore/CFile.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/LibCore/CFile.cpp b/LibCore/CFile.cpp index fa6c0d6a8d..47cee94f15 100644 --- a/LibCore/CFile.cpp +++ b/LibCore/CFile.cpp @@ -10,10 +10,18 @@ CFile::CFile(const String& filename) CFile::~CFile() { - if (mode() != NotOpen) + if (m_should_close_file_descriptor == ShouldCloseFileDescriptor::Yes && mode() != NotOpen) close(); } +bool CFile::open(int fd, CIODevice::OpenMode mode, ShouldCloseFileDescriptor should_close) +{ + set_fd(fd); + set_mode(mode); + m_should_close_file_descriptor = should_close; + return true; +} + bool CFile::open(CIODevice::OpenMode mode) { int flags = 0; |