----------------------------------------------------------------------------
| 32 | |
| 33 | //---------------------------------------------------------------------------- |
| 34 | bool vtkIOSSFilesScanner::IsMetaFile(const std::string& filename) |
| 35 | { |
| 36 | vtksys::ifstream metafile(filename.c_str()); |
| 37 | if (!metafile.good()) |
| 38 | { |
| 39 | return false; |
| 40 | } |
| 41 | |
| 42 | std::string s; |
| 43 | std::getline(metafile, s); |
| 44 | rtrim(s); // strip trailing white-spaces |
| 45 | if (s.empty() || |
| 46 | s.size() != |
| 47 | static_cast<size_t>(std::count_if( |
| 48 | s.begin(), s.end(), [](unsigned char c) { return std::isprint(c) || std::isspace(c); }))) |
| 49 | { |
| 50 | return false; |
| 51 | } |
| 52 | |
| 53 | // let's just check that the first value is a valid filename. |
| 54 | auto metafile_path = |
| 55 | vtksys::SystemTools::GetFilenamePath(vtksys::SystemTools::CollapseFullPath(filename)); |
| 56 | auto fpath = vtksys::SystemTools::CollapseFullPath(s, metafile_path); |
| 57 | return (vtksys::SystemTools::FileExists(fpath, /*isFile=*/true)); |
| 58 | } |
| 59 | |
| 60 | //---------------------------------------------------------------------------- |
| 61 | std::set<std::string> vtkIOSSFilesScanner::GetFilesFromMetaFile(const std::string& filename) |