Remove FileAccessIface::WritePos()

Make the sole caller implement it using SetPosition() and Write()
instead.

Change-Id: I10ab38a8646bc0d57612c5017ec18f178b90618c
Reviewed-on: https://pdfium-review.googlesource.com/c/pdfium/+/123471
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Reviewed-by: Tom Sepez <tsepez@google.com>
diff --git a/core/fxcrt/cfx_fileaccess_posix.cpp b/core/fxcrt/cfx_fileaccess_posix.cpp
index 9844e67..2f6309e 100644
--- a/core/fxcrt/cfx_fileaccess_posix.cpp
+++ b/core/fxcrt/cfx_fileaccess_posix.cpp
@@ -67,24 +67,28 @@
   }
   return lseek(m_nFD, 0, SEEK_CUR);
 }
+
 FX_FILESIZE CFX_FileAccess_Posix::SetPosition(FX_FILESIZE pos) {
   if (m_nFD < 0) {
     return (FX_FILESIZE)-1;
   }
   return lseek(m_nFD, pos, SEEK_SET);
 }
+
 size_t CFX_FileAccess_Posix::Read(pdfium::span<uint8_t> buffer) {
   if (m_nFD < 0) {
     return 0;
   }
   return read(m_nFD, buffer.data(), buffer.size());
 }
+
 size_t CFX_FileAccess_Posix::Write(pdfium::span<const uint8_t> buffer) {
   if (m_nFD < 0) {
     return 0;
   }
   return write(m_nFD, buffer.data(), buffer.size());
 }
+
 size_t CFX_FileAccess_Posix::ReadPos(pdfium::span<uint8_t> buffer,
                                      FX_FILESIZE pos) {
   if (m_nFD < 0) {
@@ -98,16 +102,6 @@
   }
   return Read(buffer);
 }
-size_t CFX_FileAccess_Posix::WritePos(pdfium::span<const uint8_t> buffer,
-                                      FX_FILESIZE pos) {
-  if (m_nFD < 0) {
-    return 0;
-  }
-  if (SetPosition(pos) == (FX_FILESIZE)-1) {
-    return 0;
-  }
-  return Write(buffer);
-}
 
 bool CFX_FileAccess_Posix::Flush() {
   if (m_nFD < 0)
diff --git a/core/fxcrt/cfx_fileaccess_posix.h b/core/fxcrt/cfx_fileaccess_posix.h
index c52b055..853cc03 100644
--- a/core/fxcrt/cfx_fileaccess_posix.h
+++ b/core/fxcrt/cfx_fileaccess_posix.h
@@ -32,7 +32,6 @@
   size_t Read(pdfium::span<uint8_t> buffer) override;
   size_t Write(pdfium::span<const uint8_t> buffer) override;
   size_t ReadPos(pdfium::span<uint8_t> buffer, FX_FILESIZE pos) override;
-  size_t WritePos(pdfium::span<const uint8_t> buffer, FX_FILESIZE pos) override;
   bool Flush() override;
   bool Truncate(FX_FILESIZE szFile) override;
 
diff --git a/core/fxcrt/cfx_fileaccess_windows.cpp b/core/fxcrt/cfx_fileaccess_windows.cpp
index 933bd4d..c133027 100644
--- a/core/fxcrt/cfx_fileaccess_windows.cpp
+++ b/core/fxcrt/cfx_fileaccess_windows.cpp
@@ -118,17 +118,6 @@
   return Read(buffer);
 }
 
-size_t CFX_FileAccess_Windows::WritePos(pdfium::span<const uint8_t> buffer,
-                                        FX_FILESIZE pos) {
-  if (!m_hFile) {
-    return 0;
-  }
-  if (SetPosition(pos) == (FX_FILESIZE)-1) {
-    return 0;
-  }
-  return Write(buffer);
-}
-
 bool CFX_FileAccess_Windows::Flush() {
   if (!m_hFile)
     return false;
diff --git a/core/fxcrt/cfx_fileaccess_windows.h b/core/fxcrt/cfx_fileaccess_windows.h
index 737e233..f14d96c 100644
--- a/core/fxcrt/cfx_fileaccess_windows.h
+++ b/core/fxcrt/cfx_fileaccess_windows.h
@@ -33,7 +33,6 @@
   size_t Read(pdfium::span<uint8_t> buffer) override;
   size_t Write(pdfium::span<const uint8_t> buffer) override;
   size_t ReadPos(pdfium::span<uint8_t> buffer, FX_FILESIZE pos) override;
-  size_t WritePos(pdfium::span<const uint8_t> buffer, FX_FILESIZE pos) override;
   bool Flush() override;
   bool Truncate(FX_FILESIZE szFile) override;
 
diff --git a/core/fxcrt/fileaccess_iface.h b/core/fxcrt/fileaccess_iface.h
index 72c40ea..59113d1 100644
--- a/core/fxcrt/fileaccess_iface.h
+++ b/core/fxcrt/fileaccess_iface.h
@@ -26,8 +26,6 @@
   virtual size_t Read(pdfium::span<uint8_t> buffer) = 0;
   virtual size_t Write(pdfium::span<const uint8_t> buffer) = 0;
   virtual size_t ReadPos(pdfium::span<uint8_t> buffer, FX_FILESIZE pos) = 0;
-  virtual size_t WritePos(pdfium::span<const uint8_t> buffer,
-                          FX_FILESIZE pos) = 0;
   virtual bool Flush() = 0;
   virtual bool Truncate(FX_FILESIZE szFile) = 0;
 };
diff --git a/core/fxcrt/fx_stream.cpp b/core/fxcrt/fx_stream.cpp
index d6494dc..ded828b 100644
--- a/core/fxcrt/fx_stream.cpp
+++ b/core/fxcrt/fx_stream.cpp
@@ -29,7 +29,10 @@
     return m_pFile->Read(buffer);
   }
   bool WriteBlock(pdfium::span<const uint8_t> buffer) override {
-    return !!m_pFile->WritePos(buffer, GetSize());
+    if (m_pFile->SetPosition(GetSize()) == static_cast<FX_FILESIZE>(-1)) {
+      return false;
+    }
+    return !!m_pFile->Write(buffer);
   }
   bool Flush() override { return m_pFile->Flush(); }