Example #1
0
// TrajectoryFile::DetectFormat()
TrajectoryIO* TrajectoryFile::DetectFormat(FileName const& fname, TrajFormatType& ttype) {
  CpptrajFile file;
  if (file.SetupRead(fname, 0) == 0) {
    for (int i = 0; i < (int)UNKNOWN_TRAJ; i++) {
      ttype = (TrajFormatType)i;
      TrajectoryIO* IO = (TrajectoryIO*)FileTypes::AllocIO(TF_AllocArray, ttype, true );
      if (IO != 0 && IO->ID_TrajFormat( file ))
        return IO;
      delete IO;
    }
  }
  ttype = UNKNOWN_TRAJ;
  return 0;
}
Example #2
0
// ParmFile::DetectFormat()
ParmIO* ParmFile::DetectFormat(FileName const& fname, ParmFormatType& ptype) {
  CpptrajFile file;
  if (file.SetupRead(fname, 0) == 0) {
    for (int i = 0; i < (int)UNKNOWN_PARM; i++) {
      ptype = (ParmFormatType)i;
      ParmIO* IO = (ParmIO*)FileTypes::AllocIO(PF_AllocArray, ptype, true );
      if (IO != 0 && IO->ID_ParmFormat( file ))
        return IO;
      delete IO;
    }
  }
  ptype = UNKNOWN_PARM;
  return 0;
}