Viewing contents of file '../idllib/contrib/buie/exists.pro'
;+
; NAME:
;     exists
; PURPOSE: (one line)
;     Check for file (or directory) existence.
; DESCRIPTION:
; CATEGORY:
;     File I/O
; CALLING SEQUENCE:
;     flag = exists(file)
; INPUTS:
;     file - string containing file name to look for.
; OPTIONAL INPUT PARAMETERS:
; KEYWORD PARAMETERS:
; OUTPUTS:
;     Return value is 1 (true) if file exists.  0 if it doesn't.
; COMMON BLOCKS:
; SIDE EFFECTS:
; RESTRICTIONS:
; PROCEDURE:
;     Calls OPENR recasts answer for a simple boolean flag.
; MODIFICATION HISTORY:
;    93/03/29 - Written by Marc W. Buie, Lowell Observatory
;    96/10/17, MWB, modified to use OPENR for Unix
;    97/02/16, MWB, fixed DOS bug for dirs with trailing \
;-
function exists,file

if !version.os_family eq 'Windows' then begin
   if strmid(file,strlen(file)-1,1) eq '\' then $
      ans = findfile(strmid(file,0,strlen(file)-1),count=count) $
   else $
      ans = findfile(file,count=count)
   if count ge 1 then return,1 else return,0
endif else begin
   openr,lun,file,error=error,/get_lun
   if error eq 0 then free_lun,lun
   return,(error eq 0)
endelse


end