;Remove path information, and optionally a suffix. Works like `basename` command in unix function basename,fn_,suffix=suffix path=strsplit(fn_,'[/\]',/extract) fn=path[n_elements(path)-1] if n_elements(suffix) gt 0 then fn=strrep(fn,suffix+'$','',/regex) return,fn end ; Decompress a gzipped file into a temporary file ; Works for linux, mac, and windows ; ; :Params: ; fn : string ; full path of file to decompress ; ; :Keywords: ; tmp : string ; temporary path for files created and deleted during the proces. /tmp in unix by default ; debug: boolean ; if keyword debug is set then print debug output ; ; :Returns: ; the full path of the uncompressed file ; function decompress,fn,tmp=tmp, debug=debug if (!version.os eq "linux") or (!version.os eq "darwin") then begin if n_elements(tmp) eq 0 then tmp='/tmp' tn=tmp+'/'+basename(fn,suffix='.gz') decompress_cmd = 'gzip -cd ' + fn + ' > '+tn if keyword_set(debug) then $ print, get_routine_name() + ' decompress_cmd: ' + decompress_cmd spawn, decompress_cmd,result,exit_status=exit_status if exit_status ne 0 then $ print, get_routine_name() + ' GZIP exit_status: ' + strcompress(string(exit_status), /remove_all) end else begin if n_elements(tmp) eq 0 then tmp='C:\Temp' tn=basename(fn,suffix='.gz') decompress_cmd= '"'+!7Z_PATH+'\7za.exe" e -aoa -o'+tmp+' "'+fn+'"' print, get_routine_name() + ' decompress_cmd: ' + decompress_cmd tn=tmp+'\'+tn spawn,decompress_cmd,/noshell,result,exit_status=exit_status end if exit_status ne 0 then begin print,result message,'decompress didnt work '+decompress_cmd end return,tn end