- if(!Fp)
- {
- if(exception_on_error)
- {
- throw gdcmFileError("gdcmDocument::gdcmDocument(const char *, bool)");
- }
- else
- {
- dbg.Verbose(0, "gdcmDocument::OpenFile cannot open file: ",
- Filename.c_str());
- return NULL;
- }
- }
-
- if ( Fp )
- {
- uint16_t zero;
- fread(&zero, (size_t)2, (size_t)1, Fp);
-
- //ACR -- or DICOM with no Preamble --
- if( zero == 0x0008 || zero == 0x0800 || zero == 0x0002 || zero == 0x0200 )
- {
- return Fp;
- }
-
- //DICOM
- fseek(Fp, 126L, SEEK_CUR);
- char dicm[4];
- fread(dicm, (size_t)4, (size_t)1, Fp);
- if( memcmp(dicm, "DICM", 4) == 0 )
- {
- return Fp;
- }
-
- fclose(Fp);
- dbg.Verbose(0, "gdcmDocument::OpenFile not DICOM/ACR", Filename.c_str());
- }
- else
- {
- dbg.Verbose(0, "gdcmDocument::OpenFile cannot open file", Filename.c_str());
- }
-
- return 0;
+ if(!Fp)
+ {
+ dbg.Verbose( 0,
+ "gdcmDocument::OpenFile cannot open file: ",
+ Filename.c_str());
+ return 0;
+ }
+
+ uint16_t zero;
+ fread(&zero, (size_t)2, (size_t)1, Fp);
+
+ //ACR -- or DICOM with no Preamble --
+ if( zero == 0x0008 || zero == 0x0800 || zero == 0x0002 || zero == 0x0200 )
+ {
+ return Fp;
+ }
+
+ //DICOM
+ fseek(Fp, 126L, SEEK_CUR);
+ char dicm[4];
+ fread(dicm, (size_t)4, (size_t)1, Fp);
+ if( memcmp(dicm, "DICM", 4) == 0 )
+ {
+ return Fp;
+ }
+
+ fclose(Fp);
+ dbg.Verbose( 0,
+ "gdcmDocument::OpenFile not DICOM/ACR (missing preamble)",
+ Filename.c_str());
+
+ return 0;