Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dup to fcntl #3047

Merged
merged 3 commits into from
Nov 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions Os/Posix/File.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,21 +45,17 @@
"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);
Dismissed Show dismissed Hide dismissed
}
#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,
Expand Down
18 changes: 2 additions & 16 deletions Os/Posix/File.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
//!
Expand Down
Loading