PRO rdkihd,file,header ; ; This procedure accepts the name of an image file written by KI ; (v1.0), reads in the image header, byte-reverses it, and returns it. ; ; Modified 93/07/08 by DPS: ; If the file name passed ends in '.z' or '.gz', the routine spawns ; a process to 'gunzip' the file, reads it in, and spawns another ; process to 'gzip' it again. This requires that the user be ; 'cnsr3', as all images now belong to that user. ON_IOERROR,bad_file zip=STRPOS(file,'.z') gzip=STRPOS(file,'.gz') IF (zip GT 0) OR (gzip GT 0) THEN BEGIN command='gzcat '+file+' > ! tmp' SPAWN,command sfile='tmp' ENDIF ELSE sfile=file OPENR,unit,sfile,/GET_LUN filestat=FSTAT(unit) IF filestat.SIZE LT 512 THEN BEGIN CLOSE,unit & FREE_LUN,unit MESSAGE,'Too few bytes found in file '+file+'; aborting',/INFORMATIONAL header=-1 RETURN ENDIF header=BYTARR(512) READU,unit,header CLOSE,unit & FREE_LUN,unit IF (zip GT 0) OR (gzip GT 0) THEN SPAWN,'rm tmp' ; reverse byte order IF (STRLOWCASE(STRMID(!VERSION.OS,0,3)) NE 'win') THEN BYTEORDER,header RETURN bad_file: MESSAGE,'I/O error reading '+file,/INFORMATIONAL header=-1 image=-1 RETURN END