; docformat = 'rst' ; ; NAME: ; DIR_EXIST ; PURPOSE: ; This function tests for the presence of a directory. ; ;+ ; :Description: ; This function tests for the presence of a directory. ; ; :Categories: ; Disk I/O ; ; :Params: ; DIR: in, required, type=string ; String holding the name of the directory you want to test ; the existence of. ; ; :Returns: This function returns 1 if the specified directory exists or ; 0 if the specified directory does NOT exist. ; ; :Examples: ; To check the existence of a '/TMP' directory type:: ; IDL > iss = DIR_EXIST('/TMP') ; IDL > if (iss eq 1) then print,'TMP directory EXISTs.' $ ; else print,'TMP directory does NOT exist.' ; ; :Author: ; Han Wen, Copied from !News TECH TIPS ; ; :History: ; Change History:: ; Written in June 1995, Han Wen ; 2013-Nov.: B.Carry (IMCCE) - IdlDoc Header ;- function DIR_EXIST, DIR ;--I-- Save Current Directory CD, CUR=cur ;--II-- An error will occur if we cd to DIR and it doesn't exist CATCH, error_status if (error_status NE 0) then return, 0 ;--III-- Try to cd to DIR CD, dir ;--IV-- If DIR exists, cd back to Current Directory CD, cur return, 1 end