use platform code for reading/writing of compressed text file via a pipe
This commit is contained in:
@ -79,7 +79,10 @@ NEBSpin::~NEBSpin()
|
||||
MPI_Comm_free(&roots);
|
||||
memory->destroy(all);
|
||||
delete[] rdist;
|
||||
if (fp) fclose(fp);
|
||||
if (fp) {
|
||||
if (compressed) platform::pclose(fp);
|
||||
else fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
@ -690,22 +693,10 @@ int NEBSpin::initial_rotation(double *spi, double *sploc, double fraction)
|
||||
void NEBSpin::open(char *file)
|
||||
{
|
||||
compressed = 0;
|
||||
char *suffix = file + strlen(file) - 3;
|
||||
if (suffix > file && strcmp(suffix,".gz") == 0) compressed = 1;
|
||||
if (!compressed) fp = fopen(file,"r");
|
||||
else {
|
||||
#ifdef LAMMPS_GZIP
|
||||
auto gunzip = std::string("gzip -c -d ") + file;
|
||||
#ifdef _WIN32
|
||||
fp = _popen(gunzip.c_str(),"rb");
|
||||
#else
|
||||
fp = popen(gunzip.c_str(),"r");
|
||||
#endif
|
||||
|
||||
#else
|
||||
error->one(FLERR,"Cannot open gzipped file");
|
||||
#endif
|
||||
}
|
||||
if (platform::has_zip_extension(file)) {
|
||||
fp = platform::zip_read(file);
|
||||
if (!fp) error->one(FLERR,"Cannot open compressed file");
|
||||
} else fp = fopen(file,"r");
|
||||
|
||||
if (fp == nullptr)
|
||||
error->one(FLERR,"Cannot open file {}: {}",file,utils::getsyserror());
|
||||
|
||||
Reference in New Issue
Block a user