25 bool resetFile(std::ifstream& file, std::vector<char>& buffer,
const std::string_view& path) {
28 buffer.resize(1024,
'\0');
29 file = std::ifstream(path.data(), std::ios::binary);
31 perror(std::string(path).append(
": Error opening file").c_str());
38 file.read(buffer.data(), buffer.size());
40 perror(std::string(path).append(
": Error reading file").c_str());
46 buffer.resize(buffer.size() * 2,
'\0');
49 file.read(buffer.data(), buffer.size());
51 buffer.resize(buffer.size() * 2,
'\0');
55 bool readFile(std::ifstream& file, std::vector<char>& buffer,
const std::string_view& path) {
59 file.read(buffer.data(), buffer.size());
61 perror(std::string(path).append(
": Error reading file").c_str());
65 buffer[file.gcount()] =
'\0';
71 enum mode_t { STRING, NUMBER } mode = STRING;
76 while ((l_char = *l) && (r_char = *r)) {
77 const bool l_digit = std::isdigit(l_char);
78 const bool r_digit = std::isdigit(r_char);
79 if (l_digit && r_digit) {
87 const int diff = l_char - r_char;
96 unsigned long l_int = std::strtoul(l, &end, 0);
98 unsigned long r_int = std::strtoul(r, &end, 0);
100 const long diff = l_int - r_int;
bool readFile(std::ifstream &file, std::vector< char > &buffer, const std::string_view &path)
Attempts to read file into buffer.
Namespace for sources of metrics objects and operations.
int alphanumCompare(const char *l, const char *r)
Alphanumeric string comparison.
bool resetFile(std::ifstream &file, std::vector< char > &buffer, const std::string_view &path)
Attempts to open a file and set buffer size accordingly.