diff options
Diffstat (limited to 'Source/Core/Common')
| -rw-r--r-- | Source/Core/Common/IOFile.cpp | 9 | ||||
| -rw-r--r-- | Source/Core/Common/IOFile.h | 2 |
2 files changed, 11 insertions, 0 deletions
diff --git a/Source/Core/Common/IOFile.cpp b/Source/Core/Common/IOFile.cpp index cf7762ea68..cc22979bbe 100644 --- a/Source/Core/Common/IOFile.cpp +++ b/Source/Core/Common/IOFile.cpp @@ -101,6 +101,15 @@ bool IOFile::Close() return m_good; } +IOFile IOFile::Duplicate(const char openmode[]) const +{ +#ifdef _WIN32 + return IOFile(_fdopen(_dup(_fileno(m_file)), openmode)); +#else // _WIN32 + return IOFile(fdopen(dup(fileno(m_file)), openmode)); +#endif // _WIN32 +} + void IOFile::SetHandle(std::FILE* file) { Close(); diff --git a/Source/Core/Common/IOFile.h b/Source/Core/Common/IOFile.h index 62fdd7186e..4b12c31888 100644 --- a/Source/Core/Common/IOFile.h +++ b/Source/Core/Common/IOFile.h @@ -51,6 +51,8 @@ public: SharedAccess sh = SharedAccess::Default); bool Close(); + IOFile Duplicate(const char openmode[]) const; + template <typename T> bool ReadArray(T* elements, size_t count, size_t* num_read = nullptr) { |
