Skip to content

Commit 2129ff0

Browse files
authored
isDicomFile: fix for false positives from ImageReader::CanRead() (#4499)
1 parent 51648d0 commit 2129ff0

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

source/MRVoxels/MRDicom.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -729,9 +729,9 @@ DicomStatus isDicomFile( const std::filesystem::path& path, std::string* seriesU
729729
{
730730
std::ifstream ifs( path, std::ios_base::binary );
731731

732-
#ifdef __EMSCRIPTEN__
733-
// try to detect by ourselves
734-
// GDCM uses exceptions which causes problems on Wasm
732+
// try to detect by ourselves for the reasons as follows:
733+
// 1) GDCM uses exceptions which causes problems in Wasm,
734+
// 2) ImageReader::CanRead() reports false positives e.g. on some bindary STL files with empty header
735735
constexpr auto cDicomMagicNumberOffset = 0x80;
736736
constexpr std::array cDicomMagicNumber { 'D', 'I', 'C', 'M' };
737737
// NOTE: std::ifstream::get appends a null character
@@ -742,7 +742,6 @@ DicomStatus isDicomFile( const std::filesystem::path& path, std::string* seriesU
742742
return DicomStatusEnum::Invalid;
743743
ifs.seekg( 0, std::ios::beg );
744744
assert( ifs );
745-
#endif
746745

747746
gdcm::ImageReader ir;
748747
ir.SetStream( ifs );

0 commit comments

Comments
 (0)