------------------------------------------------------------------------------
| 1578 | |
| 1579 | //------------------------------------------------------------------------------ |
| 1580 | int vtkXMLReader::CanReadFile(const char* name) |
| 1581 | { |
| 1582 | // First make sure the file exists. This prevents an empty file |
| 1583 | // from being created on older compilers. |
| 1584 | vtksys::SystemTools::Stat_t fs; |
| 1585 | if (vtksys::SystemTools::Stat(name, &fs) != 0) |
| 1586 | { |
| 1587 | return 0; |
| 1588 | } |
| 1589 | |
| 1590 | // Test if the file with the given name is a VTKFile with the given |
| 1591 | // type. |
| 1592 | vtkXMLFileReadTester* tester = vtkXMLFileReadTester::New(); |
| 1593 | tester->SetFileName(name); |
| 1594 | |
| 1595 | int result = 0; |
| 1596 | if (tester->TestReadFile() && tester->GetFileDataType()) |
| 1597 | { |
| 1598 | if (this->CanReadFileWithDataType(tester->GetFileDataType())) |
| 1599 | { |
| 1600 | result = 1; |
| 1601 | } |
| 1602 | } |
| 1603 | |
| 1604 | tester->Delete(); |
| 1605 | // sizeof(long) == 4 on _WIN32, check for Expat config that uses 'long long' instead |
| 1606 | if (VTK_SIZEOF_LONG == 4 && result) |
| 1607 | { |
| 1608 | auto fileSize = fs.st_size; |
| 1609 | if (fileSize > VTK_LONG_MAX && !vtkXMLParser::hasLargeOffsets()) |
| 1610 | { |
| 1611 | vtkErrorMacro("Unable to read file, Expat must be configured with XML_LARGE_SIZE to read " |
| 1612 | "files > 2Gb: " |
| 1613 | << name); |
| 1614 | result = 0; |
| 1615 | } |
| 1616 | } |
| 1617 | return result; |
| 1618 | } |
| 1619 | |
| 1620 | //------------------------------------------------------------------------------ |
| 1621 | int vtkXMLReader::CanReadFileWithDataType(const char* dsname) |