read write cluster file (#60)

* Read and write cluster files (save work)

* add reading test

* use define for examples env variable and fix ci

* read and write cluster files (working)

* fix cluster CI
This commit is contained in:
Bechir Braham
2024-04-16 13:14:41 +02:00
committed by GitHub
parent 9dfd388927
commit 28d7e8c07a
28 changed files with 554 additions and 28 deletions

View File

@ -0,0 +1,37 @@
#include <algorithm>
#include <filesystem>
#include <fstream>
#include <iterator>
#include <string>
namespace aare {
/**
* @brief Compare two files
*
* @param p1 path to the first file
* @param p2 path to the second file
* @return true if the files are the same, false otherwise
*/
bool compare_files(const std::string &p1, const std::string &p2) {
std::ifstream f1(p1, std::ifstream::binary | std::ifstream::ate);
std::ifstream f2(p2, std::ifstream::binary | std::ifstream::ate);
if (f1.fail() || f2.fail()) {
return false; // file problem
}
if (f1.tellg() != f2.tellg()) {
return false; // size mismatch
}
// seek back to beginning and use std::equal to compare contents
f1.seekg(0, std::ifstream::beg);
f2.seekg(0, std::ifstream::beg);
return std::equal(std::istreambuf_iterator<char>(f1.rdbuf()), std::istreambuf_iterator<char>(),
std::istreambuf_iterator<char>(f2.rdbuf()));
}
bool compare_files(const std::filesystem::path &p1, const std::filesystem::path &p2) {
return compare_files(p1.string(), p2.string());
}
} // namespace aare

View File

@ -244,7 +244,7 @@ extern aare::logger::Logger logger_instance; // NOLINT
* @param s arguments to log
* @return void
*/
template <LOGGING_LEVEL level, typename... Strings> void log(const Strings... s) {
template <LOGGING_LEVEL level, typename... Strings> void log(const Strings... s) noexcept {
internal::logger_instance.log<level>(s...);
}
/**