Add a Release method for file wrapper
This CL adds a Release method for the FileWrapper class that allows it to release the wrapped FILE* object without closing it. Bug: b/155316201 Change-Id: If9ef4345724705dc7c66183f17bd8daadbdd00b6 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/174720 Commit-Queue: Per Åhgren <peah@webrtc.org> Reviewed-by: Karl Wiberg <kwiberg@webrtc.org> Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org> Reviewed-by: Niels Moller <nisse@webrtc.org> Cr-Commit-Position: refs/heads/master@{#31183}
This commit is contained in:
parent
3b6afeeed0
commit
b8a9630e9e
@ -118,4 +118,10 @@ bool FileWrapper::Close() {
|
||||
return success;
|
||||
}
|
||||
|
||||
FILE* FileWrapper::Release() {
|
||||
FILE* file = file_;
|
||||
file_ = nullptr;
|
||||
return file;
|
||||
}
|
||||
|
||||
} // namespace webrtc
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user