;----------------------------------------------------------------------------- ;+ ; NAME: ; ; ISDIR (function) ; ; PURPOSE: ; ; Find all elements of a list that are directories. ; ; CATEGORY: ; ; Utilities ; ; CALLING SEQUENCE: ; ; index = isdir (list, COUNT = count) ; ; INPUTS: ; ; list : Input STRING or STRARR to test ; ; KEYWORD PARAMETERS: ; ; COUNT : Return the number of list elements that are directories ; ; OUTPUTS: ; ; index : Array of length N_ELEMENTS (list). Element[i] = 1 if ; list[i] is a directory, otherwise list[i] = 0 ; ; RESTRICTIONS: ; ; None ; ; DEPENDENCIES: ; ; None ; ; MODIFICATION HISTORY: ; ; Written, 1999 May, Robert.Mallozzi@msfc.nasa.gov ; ;- ;----------------------------------------------------------------------------- FUNCTION ISDIR, list, COUNT = count CD, CURRENT = origDir n = N_ELEMENTS (list) isdir = LONARR (n) i = -1L ; Error handler for attempting to CD into a non-directory ; CATCH, error IF (error NE 0) THEN BEGIN isdir[i] = 0 IF (i EQ n - 1) THEN $ GOTO, done ENDIF ; Attempt to CD to the directory ; REPEAT BEGIN i = i + 1L CD, list[i], CURRENT = currentDir isdir[i] = 1 CD, currentDir ENDREP UNTIL (i EQ n - 1) DONE: w = WHERE (isdir, count) IF (count EQ 0) THEN $ isdir = -1L CATCH, /CANCEL CD, origDir RETURN, isdir END