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>
chromium-stable
Bob Beck 12 months ago committed by Boringssl LUCI CQ
parent 410247096a
commit d11c31c7df
  1. 35
      pki/fillins/file_util.cc
  2. 24
      pki/fillins/file_util.h
  3. 1
      pki/path_builder_unittest.cc
  4. 1
      pki/signature_algorithm_unittest.cc
  5. 24
      pki/test_helpers.cc
  6. 2
      pki/test_helpers.h
  7. 1
      sources.cmake

@ -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

@ -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

@ -6,7 +6,6 @@
#include <algorithm>
#include "fillins/file_util.h"
#include "fillins/path_service.h"
#include "cert_error_params.h"

@ -7,7 +7,6 @@
#include <memory>
#include <gtest/gtest.h>
#include "fillins/file_util.h"
#include "input.h"
#include "parser.h"

@ -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 @@ std::vector<std::string> SplitString(std::string_view str) {
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 @@ std::string ReadTestFileToString(const std::string &file_path_ascii) {
// 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();
}

@ -19,6 +19,8 @@
#include "trust_store.h"
#include "verify_certificate_chain.h"
#include "fillins/path_service.h"
namespace bssl {
namespace der {

@ -395,7 +395,6 @@ set(
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

Loading…
Cancel
Save