make use of SafeFilePtr

This commit is contained in:
Axel Kohlmeyer
2025-02-12 21:47:02 -05:00
parent 926f336962
commit 63d8915562

View File

@ -34,6 +34,7 @@
#include "random_mars.h"
#include "random_park.h"
#include "region.h"
#include "safe_pointers.h"
#include "special.h"
#include "text_file_reader.h"
#include "variable.h"
@ -1082,8 +1083,9 @@ void CreateAtoms::add_mesh(const char *filename)
molid = maxmol + 1;
}
FILE *fp = fopen(filename, "rb");
if (fp == nullptr) error->one(FLERR, "Cannot open file {}: {}", filename, utils::getsyserror());
SafeFilePtr fp = fopen(filename, "rb");
if (fp == nullptr)
error->one(FLERR, "Cannot open STL mesh file {}: {}", filename, utils::getsyserror());
// first try reading the file in ASCII format
@ -1184,7 +1186,7 @@ void CreateAtoms::add_mesh(const char *filename)
}
}
} else {
error->all(FLERR, "Error reading triangles from file {}: {}", filename, e.what());
error->all(FLERR, "Error reading triangles from STL mesh file {}: {}", filename, e.what());
}
}
@ -1195,7 +1197,6 @@ void CreateAtoms::add_mesh(const char *filename)
utils::logmesg(lmp, " read {} triangles with {:.2f} atoms per triangle added in {} mode\n",
ntriangle, ratio, mesh_name[mesh_style]);
}
if (fp) fclose(fp);
}
/* ----------------------------------------------------------------------