diff --git a/rtc_base/system/file_wrapper.cc b/rtc_base/system/file_wrapper.cc index 5409d74ef6..2828790e09 100644 --- a/rtc_base/system/file_wrapper.cc +++ b/rtc_base/system/file_wrapper.cc @@ -118,4 +118,10 @@ bool FileWrapper::Close() { return success; } +FILE* FileWrapper::Release() { + FILE* file = file_; + file_ = nullptr; + return file; +} + } // namespace webrtc diff --git a/rtc_base/system/file_wrapper.h b/rtc_base/system/file_wrapper.h index 63d1c17c11..24c333a6c3 100644 --- a/rtc_base/system/file_wrapper.h +++ b/rtc_base/system/file_wrapper.h @@ -66,6 +66,12 @@ class FileWrapper final { // Calling Close on an already closed file does nothing and returns success. bool Close(); + // Releases and returns the wrapped file without closing it. This call passes + // the ownership of the file to the caller, and the wrapper is no longer + // responsible for closing it. Similarly the previously wrapped file is no + // longer available for the wrapper to use in any aspect. + FILE* Release(); + // Write any buffered data to the underlying file. Returns true on success, // false on write error. Note: Flushing when closing, is not required. bool Flush();