Move detail::read_file() to test/test.cc (#2092)

The unit test code is the only user of the function.

read_file() now throws an exception if the file isn't found.
This commit is contained in:
Florian Albrechtskirchinger 2025-03-06 17:58:55 +01:00 committed by GitHub
parent f2928d7152
commit 85b5cdd78d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 15 additions and 16 deletions

View file

@ -240,7 +240,6 @@ using socket_t = int;
#include <errno.h>
#include <exception>
#include <fcntl.h>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
@ -2387,8 +2386,6 @@ std::string encode_query_param(const std::string &value);
std::string decode_url(const std::string &s, bool convert_plus_to_space);
void read_file(const std::string &path, std::string &out);
std::string trim_copy(const std::string &s);
void divide(
@ -2916,15 +2913,6 @@ inline std::string decode_url(const std::string &s,
return result;
}
inline void read_file(const std::string &path, std::string &out) {
std::ifstream fs(path, std::ios_base::binary);
fs.seekg(0, std::ios_base::end);
auto size = fs.tellg();
fs.seekg(0);
out.resize(static_cast<size_t>(size));
fs.read(&out[0], static_cast<std::streamsize>(size));
}
inline std::string file_extension(const std::string &path) {
std::smatch m;
static auto re = std::regex("\\.([a-zA-Z0-9]+)$");