;+
; Project:
;               EGSO            
; Name:
;               EGSO_TEMP_DIR
; Purpose:
;               Return name of temporary directory for caching of local EGSO data
; Calling Sequence:
;               dir=egso_temp_dir( [/create] )
;
; Keyword Input:  
;               create   create temporary directory if it does not exist                                        
; Outputs:     
;               dir      directory name
;                   
; History     : 25-Aug-2003, RDB (MSSL/UCL), based on routines by Zarro
;
; Contact     : rdb@mssl.ucl.ac.uk
;-    

function egso_temp_dir, create=create

if not keyword_set(create) then begin
  if test_dir('$EGSO_DATA_USER',out=out,/quiet) then return,out
  return,concat_dir(get_temp_dir(),'egso')

endif else begin
  temp_dir=egso_temp_dir()
  if not is_dir(temp_dir) then begin
     mk_dir,temp_dir
     chmod,temp_dir,/a_write
  endif
  return, temp_dir
endelse

end

