Remove fillins/file_util

Move the file reader into the anonymous namespace in test_helpers
which is the only user.

Bug: 668
Change-Id: Idd650d14fb7f9e0b7b15a7fd08e21f9a7081cc14
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/64168
Reviewed-by: Adam Langley <agl@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
Auto-Submit: Bob Beck <bbe@google.com>
diff --git a/pki/fillins/file_util.cc b/pki/fillins/file_util.cc
deleted file mode 100644
index e2d28fd..0000000
--- a/pki/fillins/file_util.cc
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright 2023 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "file_util.h"
-
-#include <fstream>
-#include <iostream>
-#include <streambuf>
-#include <string>
-
-namespace bssl {
-
-namespace fillins {
-
-bool ReadFileToString(const FilePath &path, std::string *out) {
-  std::ifstream file(path.value(), std::ios::binary);
-  file.unsetf(std::ios::skipws);
-
-  file.seekg(0, std::ios::end);
-  if (file.tellg() <= 0) {
-    return false;
-  }
-  out->reserve(file.tellg());
-  file.seekg(0, std::ios::beg);
-
-  out->assign(std::istreambuf_iterator<char>(file),
-              std::istreambuf_iterator<char>());
-
-  return true;
-}
-
-}  // namespace fillins
-
-}  // namespace bssl
diff --git a/pki/fillins/file_util.h b/pki/fillins/file_util.h
deleted file mode 100644
index 23e9b1a..0000000
--- a/pki/fillins/file_util.h
+++ /dev/null
@@ -1,24 +0,0 @@
-// Copyright 2023 The Chromium Authors
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef BSSL_FILLINS_FILE_UTIL_H
-#define BSSL_FILLINS_FILE_UTIL_H
-
-#include <openssl/base.h>
-
-#include "path_service.h"
-
-#include <string>
-
-namespace bssl {
-
-namespace fillins {
-
-bool ReadFileToString(const FilePath &path, std::string *out);
-
-}  // namespace fillins
-
-}  // namespace bssl
-
-#endif  // BSSL_FILLINS_FILE_UTIL_H
diff --git a/pki/path_builder_unittest.cc b/pki/path_builder_unittest.cc
index ebb940a..b612b75 100644
--- a/pki/path_builder_unittest.cc
+++ b/pki/path_builder_unittest.cc
@@ -6,7 +6,6 @@
 
 #include <algorithm>
 
-#include "fillins/file_util.h"
 #include "fillins/path_service.h"
 
 #include "cert_error_params.h"
diff --git a/pki/signature_algorithm_unittest.cc b/pki/signature_algorithm_unittest.cc
index 5343e28..dc0bfa6 100644
--- a/pki/signature_algorithm_unittest.cc
+++ b/pki/signature_algorithm_unittest.cc
@@ -7,7 +7,6 @@
 #include <memory>
 
 #include <gtest/gtest.h>
-#include "fillins/file_util.h"
 #include "input.h"
 #include "parser.h"
 
diff --git a/pki/test_helpers.cc b/pki/test_helpers.cc
index b7369d9..4f033ab 100644
--- a/pki/test_helpers.cc
+++ b/pki/test_helpers.cc
@@ -4,10 +4,13 @@
 
 #include "test_helpers.h"
 
+#include <fstream>
+#include <iostream>
 #include <sstream>
+#include <streambuf>
+#include <string>
 #include <string_view>
 
-#include "fillins/file_util.h"
 #include "fillins/path_service.h"
 
 #include <gtest/gtest.h>
@@ -90,6 +93,23 @@
   return out;
 }
 
+bool ReadFileToString(const fillins::FilePath &path, std::string *out) {
+  std::ifstream file(path.value(), std::ios::binary);
+  file.unsetf(std::ios::skipws);
+
+  file.seekg(0, std::ios::end);
+  if (file.tellg() == -1) {
+    return false;
+  }
+  out->reserve(file.tellg());
+  file.seekg(0, std::ios::beg);
+
+  out->assign(std::istreambuf_iterator<char>(file),
+              std::istreambuf_iterator<char>());
+
+  return true;
+}
+
 }  // namespace
 
 namespace der {
@@ -422,7 +442,7 @@
 
   // Read the full contents of the file.
   std::string file_data;
-  if (!fillins::ReadFileToString(filepath, &file_data)) {
+  if (!ReadFileToString(filepath, &file_data)) {
     ADD_FAILURE() << "Couldn't read file: " << filepath.value();
     return std::string();
   }
diff --git a/pki/test_helpers.h b/pki/test_helpers.h
index 7b16e86..3274be5 100644
--- a/pki/test_helpers.h
+++ b/pki/test_helpers.h
@@ -19,6 +19,8 @@
 #include "trust_store.h"
 #include "verify_certificate_chain.h"
 
+#include "fillins/path_service.h"
+
 namespace bssl {
 
 namespace der {
diff --git a/sources.cmake b/sources.cmake
index a8b4c54..3b3b343 100644
--- a/sources.cmake
+++ b/sources.cmake
@@ -395,7 +395,6 @@
   pki/crl_unittest.cc
   pki/encode_values_unittest.cc
   pki/extended_key_usage_unittest.cc
-  pki/fillins/file_util.cc
   pki/fillins/path_service.cc
   pki/general_names_unittest.cc
   pki/input_unittest.cc