function existdir, test_dir, rtcode=rtcode ;+ ; function existdir, test_dir, rtcode=rtcode ; function: checks existence of DIRECTORY ; -------------------------------------------------------------------------- ; START OF DESCRIPTION ; ; function IPI, U Hannover 06'94 ; 06'94: ; ; METHOD: checks existence of DIRECTORY ; uses: OPENR,...,ERROR=ERROR ; ; INPUT PARAMETER: test_dir directory to test ; ; RETURNS: 1: exists ; 0: does NOT exists ; ; INPUT KEYWORDS : none ; ; OUTPUT KEYWORDS : rtcode Return-code : 0 for o.k., -1 for ERROR ; ; EXAMPLE: ; ; print, existdir('$HOME') ; ; END OF DESCRIPTION ; -------------------------------------------------------------------------- ;- ret_val = 0 ; return - value rtcode = 0 ; Return - code ; -------------------------------------------------------------------------- ; test input if n_params() ne 1 then begin print,"The number of parameters was wrong:",n_params() doc_library,"existdir" return, ret_val endif if n_elements(test_dir) eq 0 then begin message, 'TEST_+DIR UNDEFINED : ', /info return, ret_val endif ; -------------------------------------------------------------------------- ; OS ? case !version.os of 'windows': dir_delim = '\' else: dir_delim = '/' endcase ; -------------------------------------------------------------------------- ; re-store test = test_dir ; -------------------------------------------------------------------------- ; length len = strlen(test) ; -------------------------------------------------------------------------- ; delimiter at end? if strmid(test, len-1, 1) eq dir_delim $ then test = strmid(test, 0, len-1) ; -------------------------------------------------------------------------- ; open openr, uni, test, /get_lun, error=error ; -------------------------------------------------------------------------- ; check if error ne 0 then return, 0 ; -------------------------------------------------------------------------- ; close free_lun, uni ; -------------------------------------------------------------------------- ; return & end rtcode = 0 return, 1 end