;+ ; NAME: ; gzip_file ; PURPOSE: ; Unzip .gz. file ; CATEGORY: ; gen/idl/util ; CALLING SEQUENCE: FUNCTION gzip_file, file, zipfile, check=check, isgz=isgz, nozip=nozip, force=force ; INPUTS: ; file scalar; type: string ; file to be unzipped ; OPTIONAL INPUT PARAMETERS: ; /check if set then check whether the file exists ; /nozip skip the actual zipping; only return the name ; of the zipped file if it had been zipped ; /force force gzip if file already exists ; OUTPUTS: ; status 0: zip not successfull ; 1: file succesfully zipped into file 'zipfile' ; zipfile scalar; type: string ; name of zipped file (if status=1) or the blank ; string (if status=0) ; OPTIONAL OUTPUTS: ; isgz=isgz 1 if input file was .gz file; 0 if not. ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; InitVar, GetFileSpec ; PROCEDURE: ; If the input file 'zipfile' does not exist or is not a .gz file then ; status = 0 is returned. ; MODIFICATION HISTORY: ; OCT-2003, Paul Hick (UCSD/CASS) ; NOV-2003, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ; Added /nozip keyword ;- InitVar, check, /key InitVar, nozip, /key InitVar, force, /key IF NOT nozip THEN $ IF check THEN $ IF (file_search(file))[0] EQ '' THEN $ RETURN, 0 isgz = strlowcase(GetFileSpec(file,part='type')) EQ '.gz' IF isgz THEN BEGIN zipfile = file message, /info, 'already zipped: '+file RETURN, 1 ; Already zipped ENDIF zipfile = file+'.gz' CASE nozip OF 0: BEGIN CASE !version.os_family OF 'unix': gzip = 'gzip' ; Should be in the PATH 'win ': gzip = filepath(root=getenv('SSW_SMEI_UCSD'), subdir= $ ['gen','exe','win'], 'gzip.exe') ELSE : message, 'not implemented on '+!version.os_family ENDCASE gzip = gzip+(['',' -f'])[force]+' '+file CASE !version.os_family OF 'unix':spawn, gzip 'win': spawn, /hide, gzip ENDCASE status = (file_search(zipfile))[0] NE '' IF status EQ 0 THEN BEGIN message, /info, 'zipped file not found: '+zipfile zipfile = '' ENDIF END 1: status = 1 ENDCASE RETURN, status & END