mirror of
https://github.com/slsdetectorgroup/aare.git
synced 2026-02-20 12:28:42 +01:00
formatted main branch
This commit is contained in:
@@ -6,10 +6,12 @@
|
||||
|
||||
namespace aare {
|
||||
|
||||
FilePtr::FilePtr(const std::filesystem::path& fname, const std::string& mode = "rb") {
|
||||
FilePtr::FilePtr(const std::filesystem::path &fname,
|
||||
const std::string &mode = "rb") {
|
||||
fp_ = fopen(fname.c_str(), mode.c_str());
|
||||
if (!fp_)
|
||||
throw std::runtime_error(fmt::format("Could not open: {}", fname.c_str()));
|
||||
throw std::runtime_error(
|
||||
fmt::format("Could not open: {}", fname.c_str()));
|
||||
}
|
||||
|
||||
FilePtr::FilePtr(FilePtr &&other) { std::swap(fp_, other.fp_); }
|
||||
@@ -24,15 +26,16 @@ FILE *FilePtr::get() { return fp_; }
|
||||
ssize_t FilePtr::tell() {
|
||||
auto pos = ftell(fp_);
|
||||
if (pos == -1)
|
||||
throw std::runtime_error(fmt::format("Error getting file position: {}", error_msg()));
|
||||
throw std::runtime_error(
|
||||
fmt::format("Error getting file position: {}", error_msg()));
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
FilePtr::~FilePtr() {
|
||||
if (fp_)
|
||||
fclose(fp_); // check?
|
||||
}
|
||||
|
||||
std::string FilePtr::error_msg(){
|
||||
std::string FilePtr::error_msg() {
|
||||
if (feof(fp_)) {
|
||||
return "End of file reached";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user