mirror of
https://git.gfz-potsdam.de/naaice/iphreeqc.git
synced 2025-12-15 16:18:22 +01:00
38 lines
1012 B
C++
38 lines
1012 B
C++
/*
|
|
* This project is subject to the original PHREEQC license. `litephreeqc` is a
|
|
* version of the PHREEQC code that has been modified to be used as a library.
|
|
*
|
|
* It adds a C++ interface on top of the original PHREEQC code, with small
|
|
* changes to the original code base.
|
|
*
|
|
* Authors of Modifications:
|
|
* - Max Luebke (mluebke@uni-potsdam.de) - University of Potsdam
|
|
* - Marco De Lucia (delucia@gfz.de) - GFZ Helmholz Centre for Geosciences
|
|
*
|
|
*/
|
|
|
|
#include "utils.hpp"
|
|
|
|
#include <fstream>
|
|
#include <linux/limits.h>
|
|
#include <sstream>
|
|
#include <string>
|
|
|
|
std::string readFile(const std::string &path) {
|
|
std::string string_rpath(PATH_MAX, '\0');
|
|
|
|
if (realpath(path.c_str(), string_rpath.data()) == nullptr) {
|
|
throw std::runtime_error("Failed to resolve the realpath to file " + path);
|
|
}
|
|
|
|
std::ifstream file(string_rpath);
|
|
|
|
if (!file.is_open()) {
|
|
throw std::runtime_error("Failed to open file: " + path);
|
|
}
|
|
|
|
std::stringstream buffer;
|
|
buffer << file.rdbuf();
|
|
|
|
return buffer.str();
|
|
} |