ClosePlatformFile() on non-Windows: Return true on success, false on failure

We already did this on Windows, but elsewhere we were returning false
on success and true on failure, because close() returns 0 on success
and -1 on failure, and we were letting that value implicitly convert
to bool.

Bug: webrtc:8719
Change-Id: I417ff207db8d1fa4cf73a49f1d53762a8066da6c
Reviewed-on: https://webrtc-review.googlesource.com/56660
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22150}
This commit is contained in:
Karl Wiberg 2018-02-22 11:41:25 +01:00 committed by Commit Bot
parent 518716fd73
commit 0404225d15
2 changed files with 2 additions and 2 deletions

View File

@ -63,7 +63,7 @@ FILE* FdopenPlatformFileForWriting(PlatformFile file) {
}
bool ClosePlatformFile(PlatformFile file) {
return close(file);
return close(file) == 0;
}
bool RemoveFile(const std::string& path) {

View File

@ -35,7 +35,7 @@ extern const PlatformFile kInvalidPlatformFileValue;
// the PlatformFile should no longer be used.
FILE* FdopenPlatformFileForWriting(PlatformFile file);
// Closes a PlatformFile.
// Closes a PlatformFile. Returns true on success, false on failure.
// Don't use ClosePlatformFile to close a file opened with FdopenPlatformFile.
// Use fclose instead.
bool ClosePlatformFile(PlatformFile file);