FUNCTION IsSymLink, file ;+ ; NAME: ; IsSymLink ; PURPOSE: ; Checks whether a file or directory is a symbolic link ; CATEGORY: ; Environment ; CALLING SEQUENCE: ; B = IsSymLink(file) ; INPUTS: ; file scalar; type: string ; name of file or directory to be tested ; OUTPUTS: ; B scalar; type: integer ; 0: not a symbolic link ; 1: it's symbolic link ; On non-Unix systems, always 0 is returned ; INCLUDE: @compile_opt.pro ; On error, return to caller ; RESTRICTIONS: ; > Has only been tested on Linux (bash shell) under IDL 5.3 and 5.5 ; > The islink script is needed for IDL version <= 5.4 and must be in the Linux path ; > Does not work on a path that contains a symbolic link, e.g. ; if /usr/local/rsi is a symbolic link then /usr/local/rsi/lib will ; return zero. ; PROCEDURE: ; > Only useful on Unix/Linux systems. ; If !version.os_family is not 'unix' then always 0 is returned. ; ; > If !version.os_family is 'unix' then: ; - for IDL 5.3 and earlier the script islink is spawned. The ; output from this script (0 or 1) is captured in the 'result' ; argument of spawn. ; - for IDL 5.4 and later, a 'test -L' is spawned, and the ; exit_status keyword is used directly (this makes the test ; independent of the islink script). ; MODIFICATION HISTORY: ; JULY-2001, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- CASE !version.os_family OF 'unix': BEGIN IF !version.release LT 5.4 THEN BEGIN spawn, 'which islink', prog ; Search for script b = prog[0] EQ '' CASE b OF 0: spawn, prog[0]+' '+file[0], b 1: message, /info, 'script "islink" not found in path' ENDCASE ENDIF ELSE $ spawn, 'test -L "'+file[0]+'"', exit_status=b b = fix(b[0]) IF NOT b THEN message, /info, 'symbolic link, '+file[0] END ELSE : b = 1 ENDCASE RETURN, 1-b & END