Delete class PlatformFile.
Add seek methods to FileWrapper, and refactor WavReader to use that
class instead.
Bug: webrtc:6463
Change-Id: Ifbb1989a072da6280ea5fc04b4beff991614dd53
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/147265
Commit-Queue: Niels Moller <nisse@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28770}
diff --git a/rtc_base/system/file_wrapper.cc b/rtc_base/system/file_wrapper.cc
index 9d99cef..5409d74 100644
--- a/rtc_base/system/file_wrapper.cc
+++ b/rtc_base/system/file_wrapper.cc
@@ -9,6 +9,7 @@
*/
#include "rtc_base/system/file_wrapper.h"
+#include "rtc_base/numerics/safe_conversions.h"
#include <cerrno>
@@ -78,9 +79,14 @@
return *this;
}
-bool FileWrapper::Rewind() {
+bool FileWrapper::SeekRelative(int64_t offset) {
RTC_DCHECK(file_);
- return fseek(file_, 0, SEEK_SET) == 0;
+ return fseek(file_, rtc::checked_cast<long>(offset), SEEK_CUR) == 0;
+}
+
+bool FileWrapper::SeekTo(int64_t position) {
+ RTC_DCHECK(file_);
+ return fseek(file_, rtc::checked_cast<long>(position), SEEK_SET) == 0;
}
bool FileWrapper::Flush() {
@@ -93,6 +99,11 @@
return fread(buf, 1, length, file_);
}
+bool FileWrapper::ReadEof() const {
+ RTC_DCHECK(file_);
+ return feof(file_);
+}
+
bool FileWrapper::Write(const void* buf, size_t length) {
RTC_DCHECK(file_);
return fwrite(buf, 1, length, file_) == length;