From 4842e8a1429c988949d24720cb3a062f84cfe86a Mon Sep 17 00:00:00 2001 From: "Kevin F. Ortega" Date: Mon, 25 Nov 2024 10:41:21 -0800 Subject: [PATCH] fcntl here is the equivalent of dup. Using fcntl because it's supported in VxWorks too --- Os/Posix/File.cpp | 8 ++------ Os/Posix/File.hpp | 18 ++---------------- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/Os/Posix/File.cpp b/Os/Posix/File.cpp index 4cd27d1904..e305c949c5 100644 --- a/Os/Posix/File.cpp +++ b/Os/Posix/File.cpp @@ -45,21 +45,17 @@ static_assert(std::numeric_limits::min() <= std::numeric_limit "Minimum value of FwSizeType larger than the minimum value of ssize_t. Configure a larger type."); //!\brief default copy constructor -#ifndef TGT_OS_TYPE_VXWORKS PosixFile::PosixFile(const PosixFile& other) { // Must properly duplicate the file handle - this->m_handle.m_file_descriptor = ::dup(other.m_handle.m_file_descriptor); + this->m_handle.m_file_descriptor = fcntl(other.m_handle.m_file_descriptor, F_DUPFD, 0); } -#endif -#ifndef TGT_OS_TYPE_VXWORKS PosixFile& PosixFile::operator=(const PosixFile& other) { if (this != &other) { - this->m_handle.m_file_descriptor = ::dup(other.m_handle.m_file_descriptor); + this->m_handle.m_file_descriptor = fcntl(other.m_handle.m_file_descriptor, F_DUPFD, 0); } return *this; } -#endif PosixFile::Status PosixFile::open(const char* filepath, PosixFile::Mode requested_mode, diff --git a/Os/Posix/File.hpp b/Os/Posix/File.hpp index 1c851f38f4..7ff76a88ed 100644 --- a/Os/Posix/File.hpp +++ b/Os/Posix/File.hpp @@ -33,24 +33,10 @@ class PosixFile : public FileInterface { PosixFile() = default; //! \brief copy constructor -#ifdef TGT_OS_TYPE_VXWORKS - // Adding this pound-if-define code to allow building VxWorks for POSIX. - // Better than the alternative of copying this entire file to the VxWorks repo - // and removing this line. - PosixFile(const PosixFile& other) = delete; -#else PosixFile(const PosixFile& other); -#endif - -//! \brief assignment operator that copies the internal representation -#ifdef TGT_OS_TYPE_VXWORKS - // Adding this pound-if-define code to allow building VxWorks for POSIX. - // Better than the alternative of copying this entire file to the VxWorks repo - // and removing this line. - PosixFile& operator=(const PosixFile& other) = delete; -#else + + //! \brief assignment operator that copies the internal representation PosixFile& operator=(const PosixFile& other); -#endif //! \brief destructor //!